[racket-users] Re: Eval namespace revisited ...again

2015-09-26 Thread Jukka Tuominen

In case it should be of help to anyone, using #lang racket/load solved the
problems and things run smoothly now.

br, jukka


> Hi all,
>
> I'm working on a generic solution to distributed computing/ IoT/ M2M/
> scheduled task handling etc. basing on messaging. The emphasis is on
> usability so it is essential to allow running functions identically
> despite of where they are run. The obvious thing to expect is that when
> sending an expression like '(+ 1 2 3) to a remote computer, it will be
> evaluated something like (eval '(+ 1 2 3) custom-namespace) in the
> background and returns the expected "6".
>
> I've seen the numerous discussions warning about namespace conflicts, but
> as far as I understand it should be safe in Liitin environment, where I
> intend to use it ( liitin.org ). That is, the special environment is
> initiated always with identical start-up definitions. No new top-level
> definitions are allowed because of Liitin's own way of dealing with
> dynamic objects. Internal definitions, however, are allowed (say, internal
> define's within lambda expressions), but those should be safe, right?
>
> Instead of some standard base namespace, I need to use a custom one.
> I'v tried the following, but it doesn't seem to work:
>
> (define namespace (current-namespace))
> (parameterize ((current-namespace namespace))
>  ...
> (eval expression namespace))
>
> Any suggestions on how to make this work?
>
> br, jukka
>
>
>


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Eval namespace revisited ...again

2015-09-26 Thread Jens Axel Søgaard
An alternative to racket/load if you need something easier to control:

#lang racket

;; Make a new namespace
(define custom-namespace (make-base-empty-namespace))

;; Fill it with relevant bindings
(parameterize ([current-namespace custom-namespace])
  (namespace-require ''#%kernel)
  (namespace-require 'racket/base)
  (namespace-require/copy 'racket/list))

;; Use it in eval
(define (custom-eval expr)
  (eval expr custom-namespace))

;; Test it
(custom-eval '(+ 1 2 3))


2015-09-26 13:56 GMT+02:00 Jukka Tuominen :

>
> In case it should be of help to anyone, using #lang racket/load solved the
> problems and things run smoothly now.
>
> br, jukka
>
>
> > Hi all,
> >
> > I'm working on a generic solution to distributed computing/ IoT/ M2M/
> > scheduled task handling etc. basing on messaging. The emphasis is on
> > usability so it is essential to allow running functions identically
> > despite of where they are run. The obvious thing to expect is that when
> > sending an expression like '(+ 1 2 3) to a remote computer, it will be
> > evaluated something like (eval '(+ 1 2 3) custom-namespace) in the
> > background and returns the expected "6".
> >
> > I've seen the numerous discussions warning about namespace conflicts, but
> > as far as I understand it should be safe in Liitin environment, where I
> > intend to use it ( liitin.org ). That is, the special environment is
> > initiated always with identical start-up definitions. No new top-level
> > definitions are allowed because of Liitin's own way of dealing with
> > dynamic objects. Internal definitions, however, are allowed (say,
> internal
> > define's within lambda expressions), but those should be safe, right?
> >
> > Instead of some standard base namespace, I need to use a custom one.
> > I'v tried the following, but it doesn't seem to work:
> >
> > (define namespace (current-namespace))
> > (parameterize ((current-namespace namespace))
> >  ...
> > (eval expression namespace))
> >
> > Any suggestions on how to make this work?
> >
> > br, jukka
> >
> >
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Eval namespace revisited ...again

2015-09-26 Thread Jukka Tuominen

Thank you Jens, that's a very helpful example.

br, jukka


> An alternative to racket/load if you need something easier to control:
>
> #lang racket
>
> ;; Make a new namespace
> (define custom-namespace (make-base-empty-namespace))
>
> ;; Fill it with relevant bindings
> (parameterize ([current-namespace custom-namespace])
>   (namespace-require ''#%kernel)
>   (namespace-require 'racket/base)
>   (namespace-require/copy 'racket/list))
>
> ;; Use it in eval
> (define (custom-eval expr)
>   (eval expr custom-namespace))
>
> ;; Test it
> (custom-eval '(+ 1 2 3))
>
>
> 2015-09-26 13:56 GMT+02:00 Jukka Tuominen :
>
>>
>> In case it should be of help to anyone, using #lang racket/load solved
>> the
>> problems and things run smoothly now.
>>
>> br, jukka
>>
>>
>> > Hi all,
>> >
>> > I'm working on a generic solution to distributed computing/ IoT/ M2M/
>> > scheduled task handling etc. basing on messaging. The emphasis is on
>> > usability so it is essential to allow running functions identically
>> > despite of where they are run. The obvious thing to expect is that
>> when
>> > sending an expression like '(+ 1 2 3) to a remote computer, it will be
>> > evaluated something like (eval '(+ 1 2 3) custom-namespace) in the
>> > background and returns the expected "6".
>> >
>> > I've seen the numerous discussions warning about namespace conflicts,
>> but
>> > as far as I understand it should be safe in Liitin environment, where
>> I
>> > intend to use it ( liitin.org ). That is, the special environment is
>> > initiated always with identical start-up definitions. No new top-level
>> > definitions are allowed because of Liitin's own way of dealing with
>> > dynamic objects. Internal definitions, however, are allowed (say,
>> internal
>> > define's within lambda expressions), but those should be safe, right?
>> >
>> > Instead of some standard base namespace, I need to use a custom one.
>> > I'v tried the following, but it doesn't seem to work:
>> >
>> > (define namespace (current-namespace))
>> > (parameterize ((current-namespace namespace))
>> >  ...
>> > (eval expression namespace))
>> >
>> > Any suggestions on how to make this work?
>> >
>> > br, jukka
>> >
>> >
>> >
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> --
> Jens Axel Søgaard
>


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.