I imagine Brandon was more referring to pass-by-reference, which was introduced into procedural HLLs by Algol-68.
On Monday, March 8, 2010, Carl Mäsak <cma...@gmail.com> wrote: > commitbot (>), Brandon (>>): >>> + has $!age is ref; # BUILD will automatically use ref binding, not >>> copy >> >> Perl6 isn't done until it has reinvented Algol 68? > > Unaware of what Algol 68 represents in programming language history, I > perused Wikipedia's article on Algol 68: > > <http://en.wikipedia.org/wiki/ALGOL_68> (]): > ] ALGOL 68 has been criticized, [...] for abandoning the simplicity of > ] ALGOL 60 [and instead] becoming a vehicle for complex or overly > ] general ideas, and doing little to make the compiler writer's task easy, > ] [...] > > I wish I knew how to follow up that with something witty, but it would > seem the quote more than speaks for itself. > > But instead of fruitlessly agreeing or disagreeing with a value > judgement, let me try to summarize the discussion on-channel that led > up to this particular spec change. > > When you initialize an Int attribute with an Int, you get that Int put > inside the attribute container. > > $ perl6 -e 'class A { has Int $.foo }; say A.new(:foo(42)).foo'42 > > Similarly, when you initialize a Hash attribute with a Hash, you get > that Hash put inside the attribute container. > > $ perl6 -e 'class A { has %.foo }; say A.new(:foo(bar => 42)).foo.perl' > {"bar" => 42} > > $ perl6 -e 'class A { has %.foo }; say A.new(:foo{bar => 42}).foo.perl' > {"bar" => 42} > > *However*, according to the way the old spec did things, and according > to current Rakudo alpha and Rakudo master, when you initialize an > Array attribute with an Array, you get that Array put inside *another* > Array inside the attribute container. > > $ perl6 -e 'class A { has @.foo }; say A.new(:foo[1,2,3]).foo.perl' > [[1, 2, 3]] > > (The reason for this has to do with attribute initialization having > ordinary assignment semantics, meaning that internally it translates > to something like `...@!foo = [1, 2, 3];`, which would indeed place the > [1, 2, 3] array as the first element in @!foo rather than make that > the whole array. Hashes don't suffer from this problem because `%!foo > = { bar => 42};` does the right thing and assigns the hash to %!foo.) > > The discussion, starting at [1] and continuing at [2] and [3], mostly > consisted of me repeating the same question until the above > unintuitive quirk went away. It should now just create one layer of > Array upon initialization. > > [1] http://irclog.perlgeek.de/perl6/2010-03-06#i_2070655 > [2] http://irclog.perlgeek.de/perl6/2010-03-07#i_2073494 > [3] http://irclog.perlgeek.de/perl6/2010-03-07#i_2073717 > > I'm not sure what exactly the repercussions of doing attribute > initialization with 'is ref' are apart from that. Brandon, if your > oblique reference to Algol 68 meant something more than what I > uncovered above, feel free to enrich the discussion by sharing what > you know about the possible consequences of spec'ing things this way. > > Now if you'll excuse me, I'll go back to doing little to make the > compiler writers' task easy. :-P > > // Carl > -- Mark J. Reed <markjr...@gmail.com>