On Thu, Aug 25, 2005 at 20:23:55 +1000, Stuart Cook wrote:
> Here's a suggestion:
<snip>
> Within argument lists, both of them are special syntactic forms for
> named arguments:
> 
>   foo(a => 'b', :c<d>);  # both named args
<snip>
>   my $pair = :a<b>;
>   foo($pair);  # not a named-arg call
<snip>
> ...or else find new syntax to disambiguate:

For disambiguation I think we should have symmetric functions:

        foo(pairs(a => 'b', :c<d>));
        
        my $pair = :a<b>;
        foo(named($pair));

This can be implemented in a number of ways (NamedArg isa Pair,
macros, special construct).

Edge case:

        foo(my $x = :foo<bah>);
        bar($x);

As I see it in this example bar is getting a pair, not a named
argument.

foo() on the other hand could get either a named argument since
:foo<bah> was in it's parameters, or a pair, since (my $x =
:foo<bah>) is an expression.

If the named semantics are in the micro-lexical scope of the call to
the pair constructor, foo() gets a named. If not, it gets a pair.

In either condition, there should be a warning:

        "Possible unintended use of pair instead of named argument in
        :foo<bah>, call to foo() at ..."

and disambiguation can fix this:

        foo(named(my $x = :foo<bah>));
        foo(pair(my $x = :foo<bah>));

-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me groks YAML like the grasshopper: neeyah!!!!!!

Attachment: pgp4XME69xRIb.pgp
Description: PGP signature

Reply via email to