Re: [racket] procedure to string

2014-05-02 Thread Alegria Baquero
Thank you! I will try that. Sorry for the delayed response. Got caught up in another project. On Sat, Jan 4, 2014 at 9:40 AM, Gustavo Massaccesi wrote: > There are more complex closures, that share an external variable. For > example: > ;- > #lang racket > (define-values (up! down!) > (let

Re: [racket] procedure to string

2014-01-04 Thread Gustavo Massaccesi
There are more complex closures, that share an external variable. For example: ;- #lang racket (define-values (up! down!) (let () (define counter 0) (define (up!) (set! counter (add1 counter)) counter) (define (down!) (set! counter (sub1 counter)) counter) (values up! down!)))

Re: [racket] procedure to string

2014-01-03 Thread Neil Toronto
What kind of inspection? If it's for security purposes, you're better off running the procedures in a sandbox (see the `racket/sandbox' module). You can even control the amount of time something is allowed to run. Also, `serial-lambda' might be something you could use, if the sender and receiv

Re: [racket] procedure to string

2014-01-03 Thread Alegria Baquero
Thank you for your kind responses. Your solutions are good ones but unfortunately don't fit my purpose. Imagine a mobile code scenario where you have no control of the definition of a closure. What I want to do is to be able to print the body of any incoming closure that arrives in a message. So if

Re: [racket] procedure to string

2013-12-31 Thread Alexander D. Knauth
Yes, you can do it with a struct with the property prop:procedure. #lang racket (require rackunit) (struct my-proc (proc str) #:property prop:procedure (struct-field-index proc)) (define f (my-proc (lambda (x) (+ x 1)) "(lambda (x) (+ x 1))")) (check-true (procedure? f)) (chec

Re: [racket] procedure to string

2013-12-31 Thread Laurent
Not sure that's what you really want, but you can use a simple macro to get both the procedure and the corresponding string when defining the procedure: #lang racket ;; Macro: (define-syntax-rule (lambda+string args body ...) (values (lambda args body ...) (~a '(lambda args body ...

[racket] procedure to string

2013-12-31 Thread Alegria Baquero
Hello, is there any way to transform a function's body to a string such as "(lambda(x)...)"? Thanks Alegria Racket Users list: http://lists.racket-lang.org/users