[ 
https://issues.apache.org/jira/browse/FELIX-1493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Derek Baum reassigned FELIX-1493:
---------------------------------

    Assignee: Derek Baum

> [gogo] automatic expansion of $args in Closure stops direct access to $args 
> list
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-1493
>                 URL: https://issues.apache.org/jira/browse/FELIX-1493
>             Project: Felix
>          Issue Type: Bug
>          Components: Gogo
>            Reporter: Derek Baum
>            Assignee: Derek Baum
>
> individual arguments to Closures can be accessed as $0, $1, $2
> all arguments can be accessed as the List $args.
> > x = { echo hello $args }
> > x a b
> used to produce:
> hello [a b]
> because the $args List was passed directly as a single argument to echo.
> This is not desirable in most cases, so the parser was changed to expand 
> $args in Closures by expanding the $args List,
> thus producing:
> hello a b
> Unfortunately, this also broke the ability for a closure to access the $args 
> list directly:
> % loop = { each $args { echo arg is $it }}
> % loop a b
> IllegalArgumentException: Cannot coerce each[1, 2, 3, 
> org.apache.felix.gogo.runtime.shell.clos...@b1deea] to any of 
> [(CommandSession, Collection, Function)]
> A simple fix would be to introduce an alternative Closure variable name e.g. 
> argv that is NOT expanded, but remains as a list:
> % loop = { each $argv { echo arg is $it }}
> % loop a b
> arg is a
> arg is b

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to