Even stranger:
class SomeClass {
has $.scalar_attr;
has @.array_attr;
method trial () {
say "$.scalar_attr @.array_attr";
}
}
Calling trial yields the correct value of the scalar, but the literal '@.array_attr' instead of its value. Oddly, substituting $.array_attr yields the value with no complaint that there is no such scalar.
Am I missing something, or should I submit a test?
If the later, what folder should I put it in?
Phil
phil...@sunflower.com wrote:
> While trying to use say for debugging, I ran across an oddity. While
> I can:
> say "{@some_array}";
> and
> say @some_array;
> this doesn't work:
> say "@some_array";
Pugs is correct here, you need to use [] or {} to interpolate
aggregates:
say "$scalar @array[] %hash{}";
> Even stranger:
> class SomeClass {
> has $.scalar_attr;
> has @.array_attr;
> method trial () {
> say "$.scalar_attr @.array_attr";
> }
> }
> Calling trial yields the correct value of the scalar, but the literal
> '@.array_attr' instead of its value. Oddly, substituting $.array_attr
> yields the value with no complaint that there is no such scalar.
Ah, that's probably because under the current runcore, all $.vars are
merely keys for a hash, and the sigil seems to get stripped away.
(Under the new PIL runcore, Stevan's metamodel will be/is integrated,
i.e. we'll have "real" OO, and accessing
$.attributes_which_do_not_exist will fail at compile-time.)
> Am I missing something, or should I submit a test?
Yes, please do so! :)
> If the later, what folder should I put it in?
t/oo/attributes/, probably.
--Ingo
--
Linux, the choice of a GNU | self-reference, n. - See self-reference
generation on a dual AMD |
Athlon! |
If you're expecting to see the contents of @some_array, you probably
mean:
say "@some_array[]";
See S02.
Pm