HaloO, Jon Lang wrote:
Actually, note that both infix:<,> and circumfix:<[ ]> can be used to build lists; so [1] and [] can be used to construct single-element and empty lists, respectively.
I doubt that. Actually, circumfix:<[ ]> builds arrays. And note that there's no infix operator that concatenates arrays. '[1,2],[3,4]' is a two element list. The closest you can get is '[1,2].push: [3,4]' which preserves the identity of the first array whereas the lists in infix<,> behave like values. I.e. the concatenated list has got a new identity, not that of the left list.
Personally, I'd like to see '()' capture the concept of "nothing" in the same way that '*' captures the concept of "whatever". There _may_ even be justification for differentiating between this and "something that is undefined" (which 'undef' covers). Or not; I'm not sure of the intricacies of this. One possibility might be that '1, 2, undef' results in a three-item list '[1, 2, undef]', whereas '1, 2, ()' results in a two-item list '[1, 2]' - but that may be a can of worms that we don't want to open.
I see no can of worms. A *defined* () as "nothing" is just as well defined as 0 is for addition of numbers or '' for string concatenation. The thing that Larry's line of thought leads to is that my $a = () // (1,2); means that $x receives (1,2) not the "nothing" object. The question that arises when comparing () to * is how polymorph () is: my $b = 3 + (); # $b == 3? my $c = 'ab' ~ (); # $c eq 'ab'? my $d = 1,2 , (); # $d === (1,2) my $e = 3 * (); # $e == 0? my $f = 3 ** (); # $f == 1? my $g = () ?? 1 !! 2; # $g == 2? my $h; # $h === ()? scalar defaults to nothing Do the Nothing and Whatever have unique IDs? my %h; %h{()} = "Nothing"; %h{*} = "Whatever"; %h{*+3} = "Whatever plus three"; I guess for hashes there is no slicing implied by the latter two cases, so these would use the .WHICH to build the index. Regards, TSa. -- "The unavoidable price of reliability is simplicity" -- C.A.R. Hoare "Simplicity does not precede complexity, but follows it." -- A.J. Perlis 1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan