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

Main single positional #370

Closed
wants to merge 2 commits into from
Closed

Conversation

peschwa
Copy link
Member

@peschwa peschwa commented Feb 21, 2015

This PR brings handling of arguments to the programm more in line with what Getopt::Long would do. I.e. a parameter that is declared as Scalar (like in «sub MAIN(:$foo) { ... }») cannot be dispatched to by multiple occurences of a command line switch of the same name.

Previously a named array argument would fail to dispatch if the corresponding
command line switch only appeared once.
This mostly bypasses the dispatcher, but I don't see a different way to
solve it. Feedback and improvements welcome.
if %($n).grep: { .value ~~ Positional } -> @pairs {
for @pairs -> $pair {
for @matching_candidates -> $cand {
my @param = $cand.signature.params.grep: { .named_names eq $pair.key };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.named_names returns an array. E.g.:

sub foo(:name1(:name2(:$name3))) {}
say &foo.signature.params[0].named_names.perl

outputs Array.new("name3", "name2", "name1")

@peschwa
Copy link
Member Author

peschwa commented Apr 15, 2015

Closing this for now. I don't think the approach is the best, and as Mouq mentions there's a few cases that have to be speculated about first anyway.

@peschwa peschwa closed this Apr 15, 2015
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

Successfully merging this pull request may close these issues.

None yet

2 participants