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

Derek Baum updated FELIX-1473:
------------------------------

    Attachment: FELIX-1473.patch

gogo command or method execution depends on the type of the command object,
as described in Closure.execute():

        // Now there are the following cases
        // <string> '=' statement // complex assignment
        // <string> statement // cmd call
        // <object> // value of <object>
        // <object> statement // method call

FELIX-1473.patch adds an experimental '.' operator to force the command
to be treated as a reflective method call.

This allows methods to be called on String objects:

% x = "hello world"    
hello world

% $x . startsWith hello
true

% $x . equals hello
false

% $x . matches h.*d    
true

% $x . split ' '       
hello
world

% $x . length
11

This experimental . operator is also useful for chaining method invocations:


% pwd = <new java.io.File .>
.

% $pwd . touri . resolve bin . resolve ../etc
file:/Users/derek/devl/Zebedee/etc

% <<$pwd touri> resolve bin> resolve ../etc  
file:/Users/derek/devl/Zebedee/etc

The first example (using .) is easier to type and read than the one using <>






> [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
>            Reporter: Guillaume Nodet
>         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.

Reply via email to