Is (begin ...) an expr w.r.t. syntax-class? (I’m afk)
I see no reason why it wouldn’t be an expression
Syntactically, an expression is pretty much everything except keyword
according to syntax-parse, that is
If you mean expression as in “expression context”, then that needs more cooperation from macro expander
Not sure if @notjack’s tool can handle that (yet)
It definitely can’t right now. Unsure if it’s possible.
Ah too bad. Yes I was thinking of expression context.
Yes, it’s the communication channel between the expander and the macro stepper. Part of the reason that it isn’t documented is that the protocol isn’t stable; it changes when the expander changes.
@alec.mills has joined the channel
@simon_paul58 has joined the channel
@notjack are you also looking for Typed Racket refactoring rules?
there are some legacy forms in TR that can be obviously rewritten to the current forms (for example)
and other things, like (U t) can be rewritten to just t
@jesse697 Yes, provided the refactoring doesn’t need to know the types of anything it refactors
let me know how I can help! awesome project
I’d be happy to make an issue where I can list some initial ideas
That would be very helpful :)
done, and I submitted another suggestion (more like a wild idea), too
there are some interesting puzzles with resyntax: for example, if the module requires racket/match, should we rewrite (some) conds into matches? If racket/match isn’t available, should we import it, and then do the rewriting? It would be a kind of pro tip: “hey, use match!”
wants an animated zipy to pop up and say “Hi! It looks like you’re trying to write a multi-branch conditional…”
This one is actually pretty good, if you’ve ever done MS SQL :slightly_smiling_face: https://danieljanikcom.files.wordpress.com/2017/06/cte_thumb.png?w=952&h=772
damn that’s good
if a module has a main submodule, and I run that (I’m thinking racket foo.rkt on the command line), the main submodule gets executed. Is there a way I can instantiate the module without running it? That is, do everything except actually execute what’s in main.
you can require it
context: in my CI pipeline I have a check: do I have any unbound identifiers, syntax errors, etc. I do this by doing racket foo.rkt for every file in a directory. Some of those foo.rkt files, though, have main submodules; I don’t want to actually run them in that context.
Can’t you raco make to detect syntax error?
looks like I could do racket -t foo.rkt
@sorawee interesting — it feels a bit hack-y, though, since I’m not really making anything, though admittedly that might just be what I nned
I’ll check it out — thanks
If you don’t like the idea of raco make creating compiled files — although for CI you might not care — then maybe raco expand >/dev/null would work?
(If it errors that will go to stderr so you can see the error in the CI output, and, then it does return non-zero exit code.)
#lang question. Let’s say my #%module-begin macro expands to something like (with the used #%module-begin basically, say, racket’s) #'(#%module-begin
(provide run)
(define (run) prog)
(module+ main (run))) Where prog is (in this case) a single expression, the result of the read-syntax. The following work fine: • (require "my-module.rkt") (run) • $ racket my-module.rkt However, when I ,enter "my-module.rkt" , which is what I normally do at the REPL, I can’t execute (run) ! ; run: undefined;
; cannot reference an identifier before its definition What voodoo am I missing, here? I thought I had finally wrapped my head around the reader/expander and provide definitions for runtime thing; in the ,enter version I can access “runtime functions” provided by my lang
Only slightly related note: let’s say read-syntax expands to roughly `(module m "lang.rkt" (lambda (x) ,expr)) where expr contains a quoted x somewhere (very much side-stepping hygiene, but this is sort of what beautiful racket does in stacker, with some hacks).
Now, I’d like to make this work without re-providing lambda in lang.rkt—any thoughts?
I know I can’t move the lambda to %#module-begin at present because of hygiene; the quoted x is nested deeply in expr and is not a syntax-object. Moving it to the expander means the lambda formal x and the expr x aren’t the same.
One voodoo that I think will help, is to change:
(define-simple-macro (@#%module-begin . prog)
(#%module-begin
(provide run)
(define (run) . prog)
(module+ main (run)))) to
(define-simple-macro (@#%module-begin . prog)
#:with RUN (datum->syntax this-syntax 'run)
(#%module-begin
(provide RUN)
(define (RUN) . prog)
(module+ main (RUN))))
Has anyone seen an SSL-related embedding error like this? https://www.reddit.com/r/Racket/comments/kvpcbj/building_standalone_executable_sslconnect_error/
But I agree that this is confusing, and could potentially be a bug.
In syntax-parse, is that similar to (with-syntax ([run #'run]) (#% …))? I wrote that at one point, and don’t remember if I tried it.
syntax-parse’s #:with is similar to with-syntax
So yes
But note that you gotta use (datum->syntax stx 'run), not #'run
grrrr… ok, let’s try that
thank you @sorawee that made a big difference, at least for ,enter!
The vulkan api looks complete, but i don’t want to use vulkan if i don’t have to. It’s quite a bit harder to use than opengl
You can move lambda to #%module-begin. You just need to use the same trick I used in the previous thread on the identifier x
E.g.,
(define-simple-macro (@#%module-begin . prog)
#:with X (datum->syntax this-syntax 'x)
(#%module-begin (λ (X) . prog)))
With this, you don’t need to provide λ
But won’t X be different than whatever is in prog (let’s say prog is formed by '(list x) by the reader, to be concrete)
Well, try it first, and see if it works.
When you use (lambda (x) ...) directly, x is given a macro scope, which makes it hygienic because it won’t interfere with x in other scopes.
But when I (datum->syntax stx 'x), x is given the scope from stx. That is, it doesn’t have macro scope. So x in prog can see x in lambda.
Hm. I’ll have to try it, as you said, though this is an instance where I really can’t visualize the various interactions
Well, it worked :slightly_smiling_face: so that’s nice, at least. One thing I keep forgetting about the ,enter stuff is that I’m in the context of the other lang’s expander, so I can’t do '(1 2 3); I’ve got to ,top , (require) , and re-type. Sigh. Oh well.
I can reproduce this issue with this simple program:
#lang racket
(require net/url net/url-connect)
(define url "<https://www.reddit.com>")
(parameterize ((current-https-protocol 'secure))
(let* ((data (port->string (get-pure-port (string->url url)))))
(printf "data: ~a~%" data))) an executable produced with “raco exe” works, but one produced with “raco exe —embed-dlls” gives this error:
ssl-make-client-context: context creation failed (error:00000000:lib(0):func(0):reason(0))
context...:
.../openssl/mzssl.rkt:586:18
.../openssl/mzssl.rkt:717:0: make-raw-context
.../openssl/mzssl.rkt:706:0: make-context
.../openssl/mzssl.rkt:734:0: ssl-make-client-context
.../openssl/mzssl.rkt:1031:0: ssl-secure-client-context
.../openssl/mzssl.rkt:749:0: get-context
.../openssl/mzssl.rkt:586:18
.../private/more-scheme.rkt:266:2: call-with-exception-handler
.../openssl/mzssl.rkt:1520:0: wrap-ports
.../private/arrow-val-first.rkt:489:18
.../net/http-client.rkt:67:0: http-conn-open!
.../net/http-client.rkt:274:0: http-conn-open
.../private/arrow-val-first.rkt:555:3
.../net/url.rkt:201:0: <http://getpost-impure-port>
.../net/url.rkt:271:0: getpost-pure-port
.../private/arrow-val-first.rkt:555:3
this is on Windows with:
$ racket --version
Welcome to Racket v7.9.0.22 [cs].
Do you have Racket BC installed? Or an earlier version?
Unfortunately not
Ok
Cc @mflatt
It could be that the openssl libraries don’t work with “MemoryModule.c”.
Ah, C