Hi,

I reached a point at which I don't think I am exactly understanding how
the racket compilation pipeline works.

My software has several compile time options that use environment
variables to be read (since I can't think of another way to do it) so I
define a compile time variable as:

(define-for-syntax enable-contracts?
  (and (getenv "S10_ENABLE_CONTRACTS") #true))

And then I create a macro to move this compile-time variable to runtime:
(define-syntax (compiled-with-contracts? stx)
  (datum->syntax stx enable-contracts?))

I have a few of these so when I create a distribution, I first create an
executable with (I use create-embedding-executable but for simplicity,
lets say I am using raco):
S10_ENABLE_CONTRACTS=1 raco exe ...

I have a bunch of other options that don't matter for the moment.

One of the things I noticed is that in some cases when I run my
executable, compile time code living inside begin-for-syntax to check if
a variable has been defined during compilation or not is triggered. At a
point, which I didn't expect any more syntax expansion to occur.

I can't really reproduce the issue with a small example yet but I
noticed something:

main.rkt:

#lang racket

(require (file "arch-choice.rkt"))

(module+ main
  (printf "arch: ~a~n" (get-path)))

arch-choice.rkt:

#lang racket

(provide get-path)

(begin-for-syntax

  (define arch-path (getenv "ARCH"))

  (unless arch-path
    (raise-user-error 'driver "Please define ARCH with a suitable path")))

(define-syntax (get-path stx)
  (datum->syntax stx arch-path))

Then just to make sure nothing is compiled I remove my zos:
$ find . -type f -name '*.zo' -exec \{\} \;

Then compile it:
$ ARCH=foo raco exe main.rkt

In this case if you run ./main you'll get 'arch: foo' back which is fine
so I can't reproduce what I see in my software which is with some
combinations of compile time options, I see:
'driver: Please define ARCH environment variable'

which should even be part of the executable because it's a compile time
string (or so I thought).

So I did on the above example:
$ strings main | grep ARCH
PLANET-ARCHIVE-FILTER
ARCH"
''Please define ARCH with a suitable path


OK, so, this agrees with what I see in my program: compile-time error
strings still exist in the code. Why is that? I thought that only fully
expanded code (compiled-code) would make it to the executable file.

Another thing that might help me understand what's going on, is there a
way to extract the bytecode from the executable and decompile it?

Thanks,


-- 
Paulo Matos
        

-- 
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.

Reply via email to