Rod Adams wrote: > It used to be > > &foo<Array,Int> > &foo<Hash,Int> > > but I seem to recall that there was a mild change that occurred. Or > maybe I'm thinking about the adding of the colon for operators. I'm not > certain, but it's something very close to the above. Well, it doesn't seem ambiguous to me. Operators would be in the form &infix:<-><Num,Num> . But then, I don't design grammars... If enough people think this syntax could work, I'll add "unspecced" tests to pugs for it.
> In my mind, the more interesting question is what does &foo without the > <> specifiers return when foo is multi? I see the following three options: > > 1) undef/error, since there's no single sub called foo, and multi's need > a postfix <>. At first I thought this was the right way, but then... > 2) the name 'foo', and then performs in effect call by name when > deferenced, using the dereferencing scope to determine which flavors of > foo are available at this time, and dispatching accordingly. > > 3) a dispatch table of all the foo's currently in scope at the time the > reference is made. ...one of these is actually necessary. Example: - I write a module that exports a 'foo' (a sub) - You use my module, and use that '&foo' to get a ref, which you subsequently use as you please - I then change my module so that 'foo' is a multi-sub (this is an implementation detail, not an API change) - Your code *must not* break so we can't return undef. Your #3 seem useful (for introspection, at least), but what about: multi sub foo(Array $a) {return 1} multi sub foo(Hash $a) {return 2} my $foo_A_H=&foo; multi sub foo(Str $a) {return 3} print $foo_A_H.('a'); should that print 3? Or coerce 'a' into ['a'] and print 1? What about (thinking aloud): my $foo_static=&foo; my $foo_dynamic:=&foo; where the first one has "snapshot" semantic, as in your #3, and the second one has 'name' semantic, as in your #2, in the same way that: my $a=1; my $b=$a; my $c:=$a; $a=2; print $b,$c; prints 1 2 ? -- Dakkar - <Mobilis in mobile> GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88
signature.asc
Description: OpenPGP digital signature