On Sat, Sep 06, 2008 at 07:06:30PM +1100, Илья wrote: : Hello there, : what :foo<> should exactly produce? : At first I was expecting: : foo => "" : but in Rakudo: : foo => [] : and it looks like the right thing on the other hand. : : (I have started this topic in the November mail list : http://groups.google.com/group/november-wiki/browse_thread/thread/939216e836f69baa : )
As mentioned on irc, it should do the same thing as "foo" => (). The question is whether () in item context promotes to []. I don't think it ought to, since () is really the only way we have of writing NIL in Perl 6, and [] isn't really NIL. And I think it would be odd to have *two* discontinuities: item (1,2) # [1,2] item (1) # (1) item () # []??? One discontinuity is bad enough: item (1,2) # [1,2] item (1) # (1) item () # () Essentially, the () value lazily produces undef if you actually try to access its (first) value, whereas () in list context merely interpolates nothing. On the other hand, if () isn't NIL, then we have item (1,2) # [1,2] item (1) # (1) item () # Failure of some sort But basically I think NIL is a mild form of failure anyway, so it's fine with me if () is a form of failure that is smart enough to be itself in item context but interpolate nothing into list context. Another view is that it's a kind of empty capture that is smart enough to convert to failure in item context. Possibly the right side of a pair should be capture context rather than item context. Not sure about that... Larry