Isolates: Calling functions in an isolate with an argument
3 posts
• Page 1 of 1
Isolates: Calling functions in an isolate with an argument
I have a question about isolates and how to give an argument (a local variable) to a function, called in an isolate.
Here´s some code, I tried out:
iss←isolate.New¨'' '' '' ⍝ Make 3 isolates
t←iss.⎕DL 1 1 1 ⍝ Do 3 short delays
t←iss.(#.Version) ⍝ Call a niladic function Version
t←iss.(#.foo 99) ⍝ Call a monadic function foo with a
myLocVar←'abc' 'defg' 'hi' ⍝ simple argument for demo
iss.myVar←myLocVar ⍝ simple argument for demo
t←iss.(#.foo myVar) ⍝ works as expected
iss.(⎕ex'myVar')
⍝ Trying to call the monadic function "direct"
⍝ without defining and expunging variables in the isolates:
t←iss.(#.foo) myLocVar ⍝ FUTURE ERROR: 2: SYNTAX ERROR
What is the correct syntax for calling foo with the elements of myLocVar?
Here´s some code, I tried out:
iss←isolate.New¨'' '' '' ⍝ Make 3 isolates
t←iss.⎕DL 1 1 1 ⍝ Do 3 short delays
t←iss.(#.Version) ⍝ Call a niladic function Version
t←iss.(#.foo 99) ⍝ Call a monadic function foo with a
myLocVar←'abc' 'defg' 'hi' ⍝ simple argument for demo
iss.myVar←myLocVar ⍝ simple argument for demo
t←iss.(#.foo myVar) ⍝ works as expected
iss.(⎕ex'myVar')
⍝ Trying to call the monadic function "direct"
⍝ without defining and expunging variables in the isolates:
t←iss.(#.foo) myLocVar ⍝ FUTURE ERROR: 2: SYNTAX ERROR
What is the correct syntax for calling foo with the elements of myLocVar?
- jwied
- Posts: 5
- Joined: Wed Feb 24, 2010 7:30 am
Re: Isolates: Calling functions in an isolate with an argume
At the moment, you can only call functions which are in the isolate namespace. If you need to call a function which is in the root of the isolate process workspace, you need to make an indirect call via a function in the space. The easiest way to do this is to define a dfn on the fly, as in:
- Code: Select all
iss.{#.foo ⍵} myVar
-
Morten|Dyalog - Posts: 453
- Joined: Tue Sep 09, 2008 3:52 pm
Re: Isolates: Calling functions in an isolate with an argume
Thank you, Morten.
That solves my problem.
That solves my problem.
- jwied
- Posts: 5
- Joined: Wed Feb 24, 2010 7:30 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group