Re: How to get indirect access to a class attribute?

2015-03-25 Thread Tom Browder
On Wed, Mar 25, 2015 at 8:47 AM, Tom Browder wrote: > On Wed, Mar 25, 2015 at 8:29 AM, Moritz Lenz wrote: >> the indirect method call syntax is the right approach, you just got too >> many other details wrong to make it work. This syntax works in a method as you said: self."$elem"() Again I

Re: How to get indirect access to a class attribute?

2015-03-25 Thread Tom Browder
On Wed, Mar 25, 2015 at 8:29 AM, Moritz Lenz wrote: > the indirect method call syntax is the right approach, you just got too > many other details wrong to make it work. Fair enough--my fingers fumbled a few important things. I'll correct and recheck; Thanks, Moritz (and Bruce). Cheers! -Tom

Re: How to get indirect access to a class attribute?

2015-03-25 Thread Moritz Lenz
Hi, On 25.03.2015 13:44, Tom Browder wrote: > Given a class like: > > our %attrs = (age=>1,wgt=>2); > class foo { has $.age = rw;} should be 'has $.age is rw'. The "is" indicates a trait (not an assignment). > method a { > for %attrs.kv -> $k, $v { > my $aval = self."

Re: How to get indirect access to a class attribute?

2015-03-25 Thread Bruce Gray
On Mar 25, 2015, at 7:44 AM, Tom Browder wrote: —snip-- > 1. How can I indirectly refer to the attributes in a method? The > above doesn't work (with or without the '()’). —snip— use v6; our %attrs = ( age => 1, # wgt => 2, # Need to handle "No such method" before uncommenting. ); class

How to get indirect access to a class attribute?

2015-03-25 Thread Tom Browder
Given a class like: our %attrs = (age=>1,wgt=>2); class foo { has $.age = rw;} method a { for %attrs.kv -> $k, $v { my $aval = self."$k"(); # supposed to work for a method name say "attr { $k } has value '{ $aval }'"; } } Question: 1. How can I indirectly refer to the attributes