my $b = eval '$a but true'; # setting a true property
# API to do it without an eval?
A trait setter probably does not make sense but for the
implementer because it should not be set at run time.
Incidentally, in a interactive environment it would be cool
to access the documentation of variables and functions using
properties. Say "doc" and "udoc" respectively for the full and
one line version.
--
cognominal stef
My question is more generic than my example.
I may not know at compile time what is the value/trait name and its
value.
> >
> > A trait setter probably does not make sense but for the
> > implementer because it should not be set at run time.
> >
> > Incidentally, in a interactive environment it would be cool
> > to access the documentation of variables and functions using
> > properties. Say "doc" and "udoc" respectively for the full and
> > one line version.
> >
>
> --
> Mark Biggar
--
cognominal stef
Well, the value's pretty easy--just pass in a variable:
my $b = $a is foo($bar);
As for the name, I'd be surprised if the standard symbolic-ref syntax
didn't work:
my $b = $a is ::($foo)($bar);
--
Brent 'Dax' Royal-Gordon <br...@brentdax.com>
Perl and Parrot hacker
As we currently have it, that is not legal syntax. "is" may only
be applied to declarations. You must use "does" or "but" to mixin
things at run-time (where this includes the compiler's run-time bits).
Larry
And what about the getter part of my question? :)
>
> Larry
>
--
cognominal stef
Sorry, think-o. I meant 'but' in my examples (and Stéphane used 'but' in his).
Should I construe the fact that you didn't comment on the ::() to mean
that the symref syntax works here?
Offhand I don't see any reason for it not to.
Larry
A12 discusses the relationship of traits and properties in great
detail. Any trait's metadata can be stored as properties at compile
time, and such metadata can be retrieved as properties at any time.
But traits are allowed to do other things than just store metadata.
Larry
--
Mark Biggar
ma...@biggar.org
mark.a...@comcast.net
mbi...@paypal.com
> There is syntax to define trait and properties
> but is there an API?
>
> my $b = eval '$a but true'; # setting a true property
> # API to do it without an eval?
>
> A trait setter probably does not make sense but for the
> implementer because it should not be set at run time.
>
> Incidentally, in a interactive environment it would be cool
> to access the documentation of variables and functions using
> properties. Say "doc" and "udoc" respectively for the full and
> one line version.
>
>
> --
> cognominal stef