net-eval

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

net-eval

Post by newdep »

Hi Lutz,

The Str-Expr in net-eval is very strict it seems. Im unable to replace the
str-expr position with any variable else then something between {} or "".

but this does not work and is quite pitty..->

> (setq X {(+ 3 4)})
"(+ 3 4)"
> (net-eval '( ("host" 4444 X )) 5000)

string expected in function net-eval : X


Secondly: (This is a big wish!) Does 'net-eval return ALL the eval-return-data in 1 LIST! or only last result? Because thats a BIG
advantage above 'eval-string if net-eval could..! ;-)





Regards, Norman.
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Prepare the list(s) for net-eval before unsing functions like 'list' or 'expand':

Code: Select all

> (set 'X {(+ 3 4)})
"(+ 3 4)"
> (set 'L (expand '(("host" 444 X)) 'X))
(("host" 444 "(+ 3 4)"))

;; or

> (set 'L (list (list "host" 444 X)))
(("host" 444 "(+ 3 4)"))
> 
Typically you have a list of tasks to distribute to a list of nodes and then use something like 'map' and 'list' to construct the 'net-eval' list for multiple worker nodes.

If you want to return two results put them in a list:

Code: Select all

> (net-eval '(("localhost" 4711 {(list (+ 3 4) (+ 5 6))})) 1000)
((7 11))
> 
Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Thanks! im already on it ;-)
-- (define? (Cornflakes))

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

I still don't understand why this happens, though:

Code: Select all

(net-eval '(("10.0.1.3" 4711 "(+ 2 2)")) 1000 )
works fine, but

Code: Select all

(set 's "(+ 2 2)")
(net-eval '(("10.0.1.3" 4711 s)) 1000 )
doesn't. I saw your preparation , Lutz, but why does the language appear not to work correctly or predictably in this instance?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Currently all parts of the parameter list (<host> <port> <string>) in 'net-eval' must be given as constants. This may or may not change in the future. I will clarify this in the documentation.

Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

.... what can help in this instance is 'letex' or 'expand' as shown in this example:

Code: Select all

(letex ((host "localhost") (port 4711) (str "(+ 3 4)"))
    (net-eval '((host port str)) 1000))
The letex could be embedded ina function supplying "localhost" etc. in variables.

Lutz

ps: 8.8.9 required

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Code: Select all

(define (my-net-eval machine port strn timeout)
	(letex ((_host machine) (_port port) (_str strn))
   (net-eval '((_host _port _str)) timeout)))
seems to work OK when called like this:

Code: Select all

(set 's "(+ 23 23)")
(my-net-eval "10.0.1.3" 4711 s 1000 )
Thanks. A note in the manual would probably be a good idea - I thought I had lost it (the plot, not the manual) earlier... :-)

Locked