You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by sekaijin <jy...@yahoo.fr> on 2014/01/24 16:46:20 UTC

2.2.2 shell closure variables scope

Hello, 
I have a problem with the scope of variables in closures 

The variable used in the closure has a global scope. 
How to define a variable whose scope is local to the closure? 

Where is the documentation on this? 

Thank you.
A+JYT



--
View this message in context: http://karaf.922171.n3.nabble.com/2-2-2-shell-closure-variables-scope-tp4031326.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: 2.2.2 shell closure variables scope

Posted by sekaijin <jy...@yahoo.fr>.
Good morning. 

yes I have a closure /getRepositories/ that retrieves a list of repositories
from a pattern on its name 

I have another /findCurrentVersion/ that returns the version of a feature
from a pattern on its name 

both use a local variable *name* 

I was writing a closure /updateFeatures/, which takes a pattern name and
version parameters, which looking for the repositories corresponds to
pattern, uninstall these features, built the url of the new version, removes
the oldest URL, adds new URL, and reinstall the corresponding features. 

so I used the two closures /getRepositories/ and /findCurrentVersion/ 
But /updateFeatures/ I used a local variable *name* before calling 
getRepositories.

/getRepositories/ change the value of the variable *name*. in the remainder
of the variable *name* of /updateFeatures/ lost its value.

the variable *name* is not a local variable to each closure but overall the
session. 
how to limit the scope of the variable name  to the closure
/getRepositories/ without it affecting the value of *name* in
/updateFeatures/

A +



--
View this message in context: http://karaf.922171.n3.nabble.com/2-2-2-shell-closure-variables-scope-tp4031326p4031335.html
Sent from the Karaf - Dev mailing list archive at Nabble.com.

Re: 2.2.2 shell closure variables scope

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

do you have an example of what you want to do ?

Regards
JB

On 01/24/2014 04:46 PM, sekaijin wrote:
> Hello,
> I have a problem with the scope of variables in closures
>
> The variable used in the closure has a global scope.
> How to define a variable whose scope is local to the closure?
>
> Where is the documentation on this?
>
> Thank you.
> A+JYT
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/2-2-2-shell-closure-variables-scope-tp4031326.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com