
Isn’t it odd, that if I write a small macro using syntax-parse but forget to require syntax/parse
, I don’t get an undefined identifier for syntax-parse
? Instead I get an error about _
?

Try this

#lang racket
(define-syntax (make-banana stx)
(syntax-parse stx
[(_ name:id)
#:with out
(format-id #'name "banana-~a" #'name)
#'(define (a-banana) name)]))

That’s an unfortunate consequence of expansion order

if you didn’t have an _
, you’d get an error about syntax-parse

ah… :slightly_smiling_face: ok…

well fair enough. at least it’s a known issue.

Using #lang racket/base
instead, you do get “syntax-parse: unbound identifier in the transformer environment” Of course what I used to do next was: 1. (require syntax-parse)
2. (require syntax/parse)
3. (require (for-syntax syntax/parse))
4. syntax
is undefined….??? 5. Eventually: (require (for-syntax racket/base syntax/parse))
This was probably when I started slapping together Fear of Macros ¯_(ツ)_/¯

@greg treading the same path.

lol I made the same syntax-parse
typo in 5 above; just fixed it

Oh and 3. Fixed also.

Really, I know how to racket.

drinks more coffee

So, the latest one driving me crazy is this error that marks no line for problems. I managed to reduce it to a simple example (longer example is in the mailing list): #lang racket
(require racket/generic
(for-syntax syntax/parse
racket/syntax))
(define-generics fruit
(fruit-name-len fruit))
(define-syntax (make-fruit stx)
(syntax-parse stx
[(_ name:id)
#:with name-len
(string-length (format "fruit-~a" #'name))
#'(struct name
(type)
#:methods gen:fruit
((define (fruit-name-len f) name-len)))]))
(make-fruit banana)
Used banana
and fruit
to avoid the usual foo
and bar
but don’t expect the example to make sense.

Error is this beautiful:

?: literal data is not allowed;
no #%datum syntax transformer is bound in: 28

Expansion looks ok.

If I copy paste expansion to repl is also fine but just running the whole thing returns this interesting ?
.

At this point, I wish I could reply back to the repl with ?
to force him to give me more information. :slightly_smiling_face:

@pocmatos The ?
means there is no source location information on the 28
, which makes sense, since you’re implicitly converting it to syntax using #:with
. I’ll give a longer explanation on the mailing list (and how to fix it).

Speaking of FoM, I will update the sloppy format-id
examples: https://stackoverflow.com/a/50559918/343414 But also, now I’m wondering why format-id
’s lctx
arg is (or/c syntax? #f)
. Instead would it be more helpful if it took (or/c identifier? #f)
or even just identifier?
(Not necessarily proposing changing format-id
. Maybe just defining a “safer” alternative wrapper.)

@lexi.lambda ok, thanks. will eagerly await the explanation.

@greg I think sometimes it’s the right thing to do to take lexical context from something that isn’t an identifier

When making another identifier? OK. I still might define a little wrapper that helps remind me “don’t just pass stx
”.

I usually pass stx
so I’m curious: what’s the matter?

@jerome.martin.dev See that SO link for example.

@lexi.lambda thanks for your reply. Will reply to the mailing list for the benefit of all.

@greg Oh… I see.. Time to fix my code then! :stuck_out_tongue:

Sooo, I started DrRacket this morning and the splash screen was something new….as far as I can tell, an animated sea-turtle on a plaid background. Nothing wrong with that, although it was a bit startling. However, DrRacket is also exhibiting some issues like blank space where menu entries should be. I’ve used package manager to remove all packages except those installed automatically and deleted/reinstalled Racket. The problem persists. Running Racket 6.12 on MacOS 10.13.5. Anyone else having similar issues? Can anyone suggest a solution (to the missing menu items—the sea-turtle is kinda cute and is welcome to stay). Thank you very much.

Something like that happened to me a while back (today I also had the sea turtle btw). Had a black star as a splash. Thought it was caused by a package I had recently installed, and was unnerved by it. Removed it, reinstalled Racket, still had the weird splash. Set it aside, thinking there was some kind of profile or temp file problem I would just deal with the next day. Next day, splash back to normal. I think on some dates drracket has different splash screens (just for fun?). Though I have not seen any documentation to support that.

@ghoetker The turtle is intentional for King Kamehameha Day. The missing menu entries are not! Maybe the missing menu entries depend on the Mac OS version, since I don’t that yet, but can you tell me more specifically where to look?

pushed some long-overdue commits for Fear of Macros https://github.com/greghendershott/fear-of-macros/commits/master

@mflatt The turtle is awesome! The missing menu items are all in the View menu. The first two items are missing, as is the item below “Hide Line Numbers”.

@nocheroot Thanks for sharing your experience. Per @mflatt, it is deliberate (and quite cool!).

@ghoetker Thanks - I do see the missing menu items on Mac OS 10.13. It doesn’t seem to be related to the turtle, though, since I get the same result when running with PLTDREASTERSECONDS
set to claim a different day for startup-window purposes. I’ll investigate more.

The missing menu items all have a number in the intended content, so that’s probably relevant

@ghoetker It is cool. Too bad I’m paranoid (professionally) and was incapable of enjoying the surprise the first time around. I think it was a five pointed black star with a lambda. Luckily I was on a vm. I might have had a stroke if it happened on a production workstation.

@nocheroot that’s for Texas independence day

Incidentally, we do test all those start-up variants in CI (thanks to a bad incident in the past)

@uldis.megnis has joined the channel