Code: Select all
:class FooClass
{del}Print x
:access public
[]<-x
{del}
And was interested to see the behaviour of arrays of objects when calling the method Print.
Code: Select all
Foo<-[]new #.FooClass
Foo.Print 'Hello'
Hello
{comment} OK this is expected!
(Foo Foo).Print 'Hello'
LENGTH ERROR
{comment} OK, makes sense to me -- I like it!
(Foo Foo).Print {enclose}'Hello'
Hello
Hello
{comment} This is great!
(,Foo).Print {enclose}'Hello'
Hello
{comment} Still lookin' good!
(,Foo).Print 'Hello'
H
e
l
l
o
{comment} What?!?! This can't be right - can it?
OK if this is going to scalar extend the 1-element vector and apply it to each element of the vector 'Hello' then by definition (Foo).Print 'Hello' must do the same thing as should Foo.Print 'Hello'. The current behaviour of Foo.Print 'Hello' is the most reasonable, thus the result of (,Foo).Print 'Hello' is wrong -- they must match. To get the errant behaviour (an implied each) the expression Foo.Display{each}'Hello' should be employed. The result of the last expression should be LENGTH ERROR!
I'd be curious as to others' opinions on this.