That's an ambiguous parse for 1 arg vs 2 arg form, are the parents a
function call or an expression. Space disambiguates it: f( a, a2) is
function, f (a, a2) is an expression whose result is passed to the function.

On Wed, Feb 17, 2016 at 11:43 AM, Greg London <[email protected]> wrote:

>
> Is perl6 whitespace sensitive?
> Or is this a bug?
>
> I have a multi() for 1 and 2 artuments
> But a 2 arg call ends up getting into the wrong sub
> Apparently because there is a space between the sub name and the
> Opening parenthesis?
>
>
>
> multi mysub($arg1) {
>                 say "mysub(one): $arg1";
> }
>
> multi mysub($arg1, $arg2) {
>                 say "mysub(two): '$arg1' then '$arg2'";
> }
>
>
>
> mysub(555);
> mysub(123, 456);
> mysub(999);
> mysub (123, 456);  # a space between sub and parenthesis
>
> output:
>
> mysub(one): 555
> mysub(two): '123' then '456'
> mysub(one): 999
> mysub(one): 123 456    <== whoops!
>
>
>
> --
>
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> http://mail.pm.org/mailman/listinfo/boston-pm
>



-- 
Bill Ricker
[email protected]
https://www.linkedin.com/in/n1vux

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to