Maybe it would be good to have official support for safe 3D values.

I realized after I wrote the `images/compile-time' module that it was just a special case. It could be extended to handle anything serializable. Having to serialize values at expansion time and unserialize them at runtime makes 3D values pretty safe.

Neil ⊥

On 07/27/2012 05:56 AM, Matthias Felleisen wrote:

I am almost sure there are additional explanations of 3d syntax and its 
problems between then and now.

When we (re)discovered 3d syntax at IU in 1984, we thought it was better than 
sliced bread. So it is natural that many other people re-discover it and want 
to use it in Racket.



On Jul 27, 2012, at 5:35 AM, Tobias Hammer wrote:

Thanks for the explanation. I think i understand now what i did wrong.
The 3D syntax was a good hint for further reading. I digged up a thread*
where you already had to explain it 10 years ago :)

Tobias

* http://www.cs.utah.edu/plt/mailarch/plt-scheme-2002/msg00111.html


On Thu, 26 Jul 2012 15:36:44 +0200, Matthew Flatt <mfl...@cs.utah.edu> wrote:

I agree that it's a bug, in a sense, that your program runs even though
it cannot be compiled.

This is an example of "3-D syntax": you're embedding a value (i.e., an
instance of `s') that you can't write as a literal into the result of a
macro expansion. I think 3-D syntax probably should not be allowed, but
the macro system currently allows it.

Most likely, using 3-D syntax is a bad idea. It's possible that you
want to replace `#:transparent' with `#:prefab' in your example, since
a prefab structure can be written as a literal. More likely, I think
you want to generate an expression that constructs an `s' instead of
generating an `s' instance in the macro expansion.

At Thu, 26 Jul 2012 14:59:41 +0200, Tobias Hammer wrote:
Hi,

i have the following two files, one that only requires the other and
calls a macro and the other one that defines that macro:

=== main.rkt
#lang racket

(require "err.rkt")
(a)

=== err.rkt
#lang racket

(begin-for-syntax
  (struct s (arg) #:transparent)

  (define (fun arg)
    (printf "arg: ~a\n" arg)))

(define-syntax (a stx)
   (syntax-case stx ()
     [(_)
      (with-syntax ([v #`#,(s 123)])
        #'(begin
            (begin-for-syntax
             (fun v))))]))

(provide a)

When executing 'racket main.rkt' directly i get the expected output
arg: #(struct:s 123)
but when i try to call 'raco make main.rkt' instead, i get this strange
error:

arg: #(struct:s 123)
write: cannot marshal value that is embedded in compiled code
   value: (s 123)
   context...:
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:388:6

/home_local/hamm_to/racket/racket-5.3.0.16/collects/racket/private/more-scheme.r
kt:151:2:
call-with-break-parameterization
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:188:5
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:508:26
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:501:42
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:466:0:
maybe-compile-zo
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:579:2:
do-check
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/cm.rkt:653:4

/home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/commands/make.rkt:7
7:8:
for-loop

/home_local/hamm_to/racket/racket-5.3.0.16/collects/compiler/commands/make.rkt:

[running body]
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/raco/raco.rkt:
[running body]
    /home_local/hamm_to/racket/racket-5.3.0.16/collects/raco/main.rkt:
[running body]

I think i need a little help to understand what is happening here
and what i am doing wrong. I had expected that running and compiling
works on the same set of programs.

Thanks for any clarification.

Tobias



--
---------------------------------------------------------
Tobias Hammer
DLR / Institute of Robotics and Mechatronics
Tel.: 08153/28-1487
Mail: tobias.ham...@dlr.de
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev
_________________________
Racket Developers list:
http://lists.racket-lang.org/dev


_________________________
   Racket Developers list:
   http://lists.racket-lang.org/dev


_________________________
 Racket Developers list:
 http://lists.racket-lang.org/dev

Reply via email to