Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different Behaviour With/Without Commas in Sub/Method Calls and slipped hashes #4988

Open
p6rt opened this issue Jan 3, 2016 · 4 comments
Open

Comments

@p6rt
Copy link

p6rt commented Jan 3, 2016

Migrated from rt.perl.org#127143 (status was 'open')

Searchable as RT127143$

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @zoffixznet

I think this is related to https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127134

The code below shows three scenarious​:
1) Subcall with two named args of same name without a comma between them, with the latter overriding the former
2) Subcall with a slipped hash and a named parameter of same name as the one in the hash, NOT separated by comma​: the named parameter does NOT override the value
3) Subcall with a slipped hash and a named parameter of same name as the one in the hash, SEPARATED by comma​: the named parameter DOES override the value

<Zoffix> m​: sub SUB(​:$foo) {say "[$foo]" }; my %args = :foo<foo>; SUB :foo<foo> :foo<newfoo>; SUB |%args :foo<newfoo>; SUB |%args, :foo<newfoo>;
<camelia> rakudo-moar 7d4cdb​: OUTPUT«[newfoo]␤[foo]␤[newfoo]␤»

The Expected Thing™ would be that slipped hash behaves same as regular named args or at least an error/warning is shown.

@p6rt
Copy link
Author

p6rt commented May 21, 2018

From @skids

Without the comma, the colonpair is in infix position, which means
it applies to the prefix unary | operator.

So whether this should be an error or "work" depends on what we can teach the |
operator to do with fake_infix adverbs it is passed.

Note if we fix | to use fake infix adverbs, then we create the problem
that |(1,1),(2,2),​:f :g will be 1,1,​:g,(2,2),​:f.

It might be best to teach | to throw when it is handed such things.

There are several other operators that will find themselves in the same
situation... especially we have other tickets about = which gets tricky
due to the difference between list and scalar assignment.

@p6rt
Copy link
Author

p6rt commented May 21, 2018

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 21, 2018

From @skids

On Mon, 21 May 2018 09​:13​:15 -0700, bri@​abrij.org wrote​:

Note if we fix | to use fake infix adverbs, then we create the problem
that |(1,1),(2,2),​:f :g will be 1,1,​:g,(2,2),​:f.

...sorry that might be OK due to the "first pair in term position"...
but

|(1,1),(2,2),1 :g will be 1,1,​:g,(2,2),1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant