You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Derek Baum (JIRA)" <ji...@apache.org> on 2010/06/29 22:34:49 UTC

[jira] Reopened: (FELIX-1473) [gogo] The syntax does not provide a way to call methods on a string

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

Derek Baum reopened FELIX-1473:
-------------------------------


a better solution to this issue has been proposed:

currently any command object that implements CharSequence is treated as a command, so it is impossible to call String methods. For example:

if {$HOSTNAME endsWith .com} {...} // this fails with 'command not found: my.host.name'

The current solution uses the period to force method invocation, for example:

if {$HOSTNAME . endsWith .com} {...}

The new proposal is to only treat 'bare' words as commands and to treat everything else as method calls. For example:

if {$HOSTNAME endsWith .com} {...} // $HOSTNAME is NOT a bareword as it is a variable expansion, so this works as expected

g! cmd = echo
g! $cmd hello // fails with 'can't coerce hello() to any of []'

The above fails, as there is no method "hello" on the String object 'echo';
To make the indirect command expansion above work, we need to introduce an osgi:eval command:

g! eval $cmd hello
hello




> [gogo] The syntax does not provide a way to call methods on a string
> --------------------------------------------------------------------
>
>                 Key: FELIX-1473
>                 URL: https://issues.apache.org/jira/browse/FELIX-1473
>             Project: Felix
>          Issue Type: Bug
>          Components: Gogo Runtime
>            Reporter: Guillaume Nodet
>            Assignee: Derek Baum
>             Fix For: gogo-0.6.0
>
>         Attachments: FELIX-1473.patch
>
>
> When the first argument is a string, gogo considers it to be a command.
> The problem is that it leads to unpredictible behavior when using variables
> > $a length
> Depending on the type of $a, it will either try to call a command named by the value of $a, or call the length method on the $a object.

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