http://qs321.pair.com?node_id=569165


in reply to Re: Should perl implement ,= or maybe overload .= (array context)
in thread Should perl implement ,= or maybe overload .= (array context)

I agree fully with the example on '+', and '.' operators and that's why I thought ,= was more consistent with perl philosophy; but favoring a function'al approach rather than an operator approach for arrays seems more consistent with PHP a la array_new. As a side note though the analogy doesn't hold entirely true, perl -e'print "4 foo"+"1"' will demonstrate a purpose for +'ing two strings.

I like '.=' more because it is clear what it should do in either context, and i don't really see a need for a ',='. Either operator would have a lower level of precedence too.



Evan Carroll
www.EvanCarroll.com
  • Comment on Re^2: Should perl implement ,= or maybe overload .= (array context)
  • Download Code

Replies are listed 'Best First'.
Re^3: Should perl implement ,= or maybe overload .= (array context)
by TimToady (Parson) on Aug 23, 2006 at 19:31 UTC
    We've debated adding ,= to Perl 6, but so far have decided it would too easy to confuse with the .= operator visually. I suppose we could add ,= just for completeness and then come back in six months and deprecate anyone who is using it. :-)

    As for unifying with the .= operator, that wouldn't work at all in Perl 6 because we've taken over dot for method calls, and .= already indicates that you want to turn a non-mutating method call into a mutating method call. The append operator in Perl 6 is the ~=, but in Perl 6 the ~ character has very strong implications of stringification, and we wouldn't want to break that.

    All that being said, it'd be trivial for you to add your own ,= operator to Perl 6, and that's probably where we should leave it.