
@arifshaikh.astro has joined the channel

can someone give me an example use of syntax-original? I’m trying to use it within the body of a transformer, but it seems like my syntax obj (and its constituent syntax objs) have lost the property by the time it gets to me: #lang racket
(define-for-syntax (-print-original? v)
(eprintf "~a: ~a~n" v (syntax-original? v)))
(define-syntax (print-original? stx)
(-print-original? stx)
(-print-original? (car (syntax-e stx)))
(-print-original? (cadr (syntax-e stx)))
#'(void))
(print-original? 1)
;; output
#<syntax:syn-original.rkt:12:0 (print-original? 1)>: #f
#<syntax:syn-original.rkt:12:1 print-original?>: #f
#<syntax:syn-original.rkt:12:17 1>: #f

can syntax-original only be meaningfully used before the racket expander kicks in? if yes, can anyone suggest how to determine if an s-expr has been mangled/introduced by a transformer (perhaps checking if the lexical context of all identifiers are untainted?)

IIRC, syntax-original?
should be used from the perspective of the macro expander, and not from the perspective of macro transformers

So apply syntax-local-introduce
to these syntax objects, to revert back to the view of the macro expander.

For example:
(-print-original? (syntax-local-introduce stx))
prints #t

gotcha. if I can pick your brain a little more…

I’m defining a custom error form (error~
) which captures the srcloc of its use site. I want to ensure that if someone writes a transformer that introduces error~
they pass the original syntax object as an argument.


my thought was I could use syntax-original?
to differentiate between a direct use of error~
(ie. one that has the entire form present in the original source) and one introduced by macro. seemingly, not the case.

I'm defining a custom error form (error~) which captures the srcloc of its use site. I want to ensure that if someone writes a transformer that introduces error~ they pass the original syntax object as an argument.
I think all you can do, is to document how error~
finds the source location it reports.

in this case, I would be OK with that, but its representative of a problem I have with macros

in that macros can be tricky to compose correctly vs. functions, and I want to help a macro author (often myself) not shoot themselves in the foot.

being able to differentiate between the direct-use case, and the macro-mediated use-case would be nice

:shrug: I’ll poke around a bit more. in any case, I really appreciate the pointers.

So, out of curiosity, what’s your use case for using hasheq
with non-reproducible keys?

@dont.post.me has joined the channel

Hey! I was trying to follow along with Handmade Hero in Racket but my program crashes as soon as I try to open a windows window. I’m not sure how to debug this and I don’t know where to look for more logging or debug info. I think it might actually be a bug in racket. If I run it in DrRacket then DrRacket just quits without any notice or message. I expect some kind of error message. Thanks for the help! https://pastebin.com/Y25xYqmu

Sorry, I just noticed that there is a #beginners channel. Only the #general and #random displayed initially.