develooper Front page | perl.perl6.language | Postings from April 2005

calls and parens

Thread Next
From:
Juerd
Date:
April 25, 2005 12:33
Subject:
calls and parens
Message ID:
20050425193338.GQ26732@c4.convolution.nl
Which assumptions are wrong?
    
    foo (3) + 4;    # foo(7)
    foo(3) + 4;     # foo(3)
    foo.(3) + 4;    # foo(3)
    foo .(3) + 4;   # foo(3)

    $foo (3) + 4;   # syntax error
    $foo(3) + 4;    # $foo(3)
    $foo.(3) + 4;   # $foo(3)
    $foo .(3) + 4;  # $foo(3)

    $o.m (3) + 4;   # syntax error
    $o.m(3) + 4;    # m(3)

What do these mean?

    $o.m .(foo)     # m(foo) or m().(foo) ???
    $o.m.(foo)      # m(foo) or m().(foo) ???
    
In the case of m(foo), m().(foo) is the obvious way to call the returned
sub.

In the case of m().(foo), I would not have any idea how to put
whitespace in between method and opening paren.

This leads me to believe that $o.m.(foo) and $o.m .(foo) are $o.m(foo).

-

Parens cannot be used to group an expression which is then
used as a method name:

    $o.("on_" ~ %methods{$event}).();  # $o(...)

Is there a way to do this without temporary variable?

    
Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About