
hello all! I was wondering if you can help me with the following problem. Here is a much distilled and silly example:
(define-syntax (test stx)
(syntax-parse stx
[(_ ex)
#'(define z ex)
]))
(test 0)
z
z
appears as unbound. I understand this is probably to do with contexts, phase-levels and such. I have experimented and read a lot, and learnt tons, but I have been unable to get this to work. This is obviously a silly example, in the real thing the returned syntax expression is some racket s-exp that has been parsed in a chunk from my #lang. The idea is to pass the racket code through untouched and have it expand into the top level of the module, so that the stuff in it can be later evaluated by other in-line expressions in my language.
Any pointers would be greatly appreciated :slightly_smiling_face:

@pezi_pink: The name z
is not bound outside the body of the test
macro due to hygiene. Use the Macro Stepper in DrRacket and note that the z
in expanded macro and the z
outside it are different colors, meanings they are different variables, which happen to have the name name. Like there are many people named “Leandro” who aren’t me, we just happen to have the same name. The quick way out is to use with-syntax
and datum->syntax
to break hygiene (see http://pasterack.org/pastes/85576). But you should really learn about hygiene and how to use it to your advantage. Maybe there’s a better way to write macros for your use case, taking advantage of hygiene, that would compose better with other macros. To that end, I recommend you start with Fear of Macros (http://www.greghendershott.com/fear-of-macros/index.html) and then follow its references (§8). That’s how I learned about this stuff, anyway :slightly_smiling_face: Good luck!

@leafac thanks very much for the response, I did think it might also be a hygiene issue, but sometimes it hard to discern what layers you are in and where the problems lie in several layers of meta. I will try the “breaking” trick to see if I can get it to work - I think i tried all this stuff already but maybe I was not applying it correctly. Hopefully there is a nicer way to do it in the future. For a bit more context this is along the lines of what I am trying to achieve:
;this denotes a racket s-exp block
;which I pick up as a whole unit
<-
(define x 42)
(define y 42)
(define (test z)
(+ y z))
->
; some custom language here that gets expanded
blah <% (test 10) %> ; this inline expression should be able to "see" the block stuff above
thanks again for the tip :slightly_smiling_face:

@samth Thanks. the previous errors were masking that from me.

@leif is there something else erroring in the travis builds? if so, we should fix it

@samth At least when I merged there was.

I don’t think that’s a good reason to merge something with failing builds, unless we really can’t fix it

@samth I agree?

But I have no idea who’s commit started the errors.

what are the errors?



the first one seems to just be a transient failure

the second is on the release branch, which sometimes has other difficulties, but several configurations passed there

have you looked at what happened?

The builds for mast have been failing off and on for the past few weeks.

I ran the tests, noticed a bunch of errors that weren’t related to log.

pushing without a clean test run is not a good idea

@samth I fixed the tests.

At least the ones related to log.

It looks like they are all passing now (at least on the machines I tested it on.)

great

@leif the travis tests don’t seem to be working with your fix. can you take a look? https://travis-ci.org/racket/racket/builds/222617417

@samth Hmm…that does not appear to be log related: --------------------
raco pkg install --copy <https://bitbucket.org/mflatt/pkg-test.git?path=pkg-test1>
FAILURE
name: check-equal?
location: /home/travis/build/racket/racket/pkgs/racket-test/tests/pkg/util.rkt:219:6
actual: 1
expected: 0
expression: (check-equal? cmd-status 0)
message: "exit code"
Check failure
--------------------

is that what happens in all of them?

Nope, in another one the error is: The job exceeded the maximum time limit for jobs, and has been terminated.

@samth 4 of them have the first error message, 3 of them have the second.

did your changes cause anything new to get installed?

Nothing that I can imagine

The docs link to the math library

But they already linked to a lot of things iirc.

right, if you didn’t add any dependencies then that wouldn’t change things

The actual code did not have any #includes (that I added anyway)

I did add one, here:


In pkgs/racket-doc/info.rkt

But that’s the only place I added a dep.

And I mean, it was already depending on drraacket
, pict
, compiler-lib
, future-visualizer
, etc.

I added math-doc
and math-lib
(so I could link to fllogb

that shouldn’t be an issue

@samth FWIW this error happened off and on before my push: https://travis-ci.org/racket/racket/jobs/220284133

As for the build time exceeded though, I don’t have much o that yet

Looking into it.

may just need to be re-run if downloading took extra long or something

That might make sense. I’ll try that.

there should be buttons for rerunning builds

Yup, they’re rerunning as we speak. :wink:

well this time some of them passed


Sigh, rats. Thanks anyway.