develooper Front page | perl.perl6.language | Postings from May 2001

Properties, deleting them, and dump

Thread Previous | Thread Next
From:
Carl Johan Berglund
Date:
May 22, 2001 02:48
Subject:
Properties, deleting them, and dump
Message ID:
p05010404b72fdec59d54@[192.168.0.6]
At 08.53 +0100 01-05-22, Graham Barr wrote:
>With the current approach I can see most code accessing properties 
>with $var.prop{name}
>because they want to make sure they get the property and not a method, whereas
>it would be shorter, in the common case, to have something like  $var'name

I would write $var.name and simply not define a prop method if I 
didn't want one.

Other than that, I think I like Larry's idea to have one variable_is 
and one value_is method. I would also very much have Data::Dumper 
built in as 'dump', so that I could say

print dump $var;

and get a complete printout of value, variable properties and value 
properties of the $var variable. (And not a core dump, as I would get 
in Perl 5.)

Tangentially, would it be possible to have

dump $var;

in void context automatically call print (or warn (or carp)), while 
it in scalar context returns what it in void context would have 
printed?

Regarding deleting properties, I don't see a need for deleting 
variable properties, and value properties die when we replace a value 
with a new one. To get rid of all properties while preserving the 
value, one could do something like:

$var = $var.value

To delete a single run-time property, we could reuse the existing 
'delete' keyword, that deletes hash elements:

delete $var.name;

These thougts are just my $0.02. I'm sure Damian and Larry have 
thought this out in much more detail.

Cajo.
-- 
Carl Johan Berglund, carl.johan.berglund@adverb.se, 0708-136 236
Adverb Information, http://www.adverb.se, 08-555 788 80

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About