On Fri, May 18, 2001 at 08:08:54PM -0700, Daniel S. Wilkerson wrote:
> Damian Conway wrote:
>
> > You may also be wondering what happens if a variable and the value it
> > contains both have a property of the same name. The answer is that we
> > always get back the variable's property in preference to the value's:
> >
> > my $var is Purpose("var demo") = 1 is Purpose("val demo");
> >
> > print $var.Purpose; # prints "var demo", not "val demo"
> >
> > To be sure of getting the value's property instead, we simply I<evaluate>
> > the variable first:
> >
> > print (+$var).Purpose; # prints "val demo", not "var demo"
eaagggh! convolution alert..
I really think this is the wrong, wrong, way to go.
Why can't variable properties and value properties be the same thing?
$ARGS is chomped;
$ARGS.chomped = 1; # same difference
my $string = "value";
print $string.value; # prints 'value'
my $num = 0 is true;
print $num.true; # prints 1;
print %{$num.prop} # prints all of the properties/attributes associated
# with an object.
Agreed that this makes the namespace for each built-in variable a bit polluted,
but hell, the amount of confusion that this would save would be tremendous.
Either that, or properties are stored in their own hash:
$ARGS is chomped;
$ARGS.prop.chomped = 1;
my $string = "value";
print $string.prop.value; # prints 'value'
my $num = 0 is true;
print $num.prop.true; # prints 1;
> write (+$var).Purpose. First, I think it can be argued that this is much uglier
> than the $var->{value} syntax that we used to use (under more restricted
very much agreed. I'd be typing "(+$var).whatever" a hell of a lot.
> different semantics. Perhaps "." for value properties and "has" for variable
> properties. This syntax would also allow the verb "has" to have a *declarative*
simpler solution: merge the two concepts, 'attributes' and 'properties', and
make 'properties' a specialized form of attributes.
> Epilogue: I notice that it was rather a bit of effort to write the above paragraphs
> and keep my English straight as to whether I was talking about the properties of
> the variable $var or of the value of $var. I submit that the fact that it is
> difficult to talk clearly about this should be a red flag. Mixing program and data
damn straight.
> as we are (also called "level-crossing") is very powerful, but making it so
> difficult to syntactically disambiguate between them is a recipe for debugging
> pain.
likewise true.
Ed