arifshaikh.astro
2021-10-19 12:04:52

@arifshaikh.astro has joined the channel


dan.hillier.anderson
2021-10-19 12:29:13

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


dan.hillier.anderson
2021-10-19 12:32:29

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?)


sorawee
2021-10-19 12:33:59

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


sorawee
2021-10-19 12:34:15

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


sorawee
2021-10-19 12:36:13

For example:

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


dan.hillier.anderson
2021-10-19 12:39:12

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


dan.hillier.anderson
2021-10-19 12:41:44

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.



dan.hillier.anderson
2021-10-19 12:44:50

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.


soegaard2
2021-10-19 13:22:08

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.


dan.hillier.anderson
2021-10-19 13:27:11

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


dan.hillier.anderson
2021-10-19 13:29:45

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.


dan.hillier.anderson
2021-10-19 13:30:21

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


dan.hillier.anderson
2021-10-19 13:31:14

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


badkins
2021-10-19 14:49:24

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


dont.post.me
2021-10-19 23:50:43

@dont.post.me has joined the channel


dont.post.me
2021-10-20 00:15:40

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


dont.post.me
2021-10-20 00:21:20

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