develooper Front page | perl.perl6.language | Postings from December 2003

RE: Properties -- distributive, predeclared, post-applied....??

Thread Next
From:
Hodges, Paul
Date:
December 4, 2003 16:12
Subject:
RE: Properties -- distributive, predeclared, post-applied....??
Message ID:
9C375DDD9B669243A2D78FCD607E894003E4FD37@bremo-jg
How about

  use Baz; # assume object type
  my property foo;
  my @bar of Baz is false but foo; # maybe not what you meant?

If you apply a trait like false to an array, I expect it to apply to the
"array instance object" itself and not the content, so that 
  push @bar, Baz.new();
  if @bar    { print "stuff"; } else { print "empty"; } # oops! false!
  if @bar[0] { print " oops"; } else { print " ok";   } # oops! not false!
would print "empty oops" instead of "stuff ok". 

I'd *like* to be able to predeclare a trait or property to be distributed
across any values placed in this array, but only this array. For example, it
would be nice if I could have the default aspects of false and foo be
applied to any Baz that gets stuck into @bar, but obviously this isn't the
syntax to do it. I could make Baz's new() do it, but I don't want *ALL* Baz
objects to be false and foo...just the ones in @bar. So, what I need is
something more like

  my @bar of Baz;
  @bar.STORE.wrap { my $r = call; return $r >>but=<< (false,foo); }

But I'm not sure C<$r >>but=<< (false,foo)> works, and I really wanted to
figure out a way to do it all in the declaration. Maybe it could be

  my @bar of Baz will do STORE.wrap { call >>but=<< (false,foo); }

but I'm not sure call will behave as an lvalue and still set up the
appropriate return, I don't expect @bar to accept "will do", and I don't
think "will do" is where the wrap should go. I'm just trying to wrap my
brain around this brick and I can't find all the references that tell me all
the little pieces so that I can compare them for a closer approximation,
lol....


*****
"The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential, proprietary, and/or
privileged material.  Any review, retransmission, dissemination or other use
of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.  If you received
this in error, please contact the sender and delete the material from all
computers.61"

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