Isolates: Calling functions in an isolate with an argument

General APL language issues

Isolates: Calling functions in an isolate with an argument

Postby jwied on Wed Mar 21, 2018 2:13 pm

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?
jwied
 
Posts: 5
Joined: Wed Feb 24, 2010 7:30 am

Re: Isolates: Calling functions in an isolate with an argume

Postby Morten|Dyalog on Wed Mar 21, 2018 2:30 pm

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
User avatar
Morten|Dyalog
 
Posts: 453
Joined: Tue Sep 09, 2008 3:52 pm

Re: Isolates: Calling functions in an isolate with an argume

Postby jwied on Wed Mar 21, 2018 3:46 pm

Thank you, Morten.
That solves my problem.
jwied
 
Posts: 5
Joined: Wed Feb 24, 2010 7:30 am


Return to Language

Who is online

Users browsing this forum: Bing [Bot] and 1 guest