laurent.orseau
2021-1-12 08:34:59

Is (begin ...) an expr w.r.t. syntax-class? (I’m afk)


sorawee
2021-1-12 08:35:36

I see no reason why it wouldn’t be an expression


sorawee
2021-1-12 08:35:50

Syntactically, an expression is pretty much everything except keyword


sorawee
2021-1-12 08:36:03

according to syntax-parse, that is


sorawee
2021-1-12 08:36:28

If you mean expression as in “expression context”, then that needs more cooperation from macro expander


sorawee
2021-1-12 08:36:38

Not sure if @notjack’s tool can handle that (yet)


notjack
2021-1-12 08:42:09

It definitely can’t right now. Unsure if it’s possible.


laurent.orseau
2021-1-12 08:59:56

Ah too bad. Yes I was thinking of expression context.


ryanc
2021-1-12 12:14:33

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
2021-1-12 16:10:35

@alec.mills has joined the channel


simon_paul58
2021-1-12 16:14:30

@simon_paul58 has joined the channel


jesse697
2021-1-12 18:28:38

@notjack are you also looking for Typed Racket refactoring rules?


jesse697
2021-1-12 18:38:49

there are some legacy forms in TR that can be obviously rewritten to the current forms (for example)


jesse697
2021-1-12 18:46:38

and other things, like (U t) can be rewritten to just t


notjack
2021-1-12 18:49:47

@jesse697 Yes, provided the refactoring doesn’t need to know the types of anything it refactors


jesse697
2021-1-12 18:51:07

let me know how I can help! awesome project


jesse697
2021-1-12 18:51:19

I’d be happy to make an issue where I can list some initial ideas


notjack
2021-1-12 18:52:30

That would be very helpful :)


jesse697
2021-1-12 19:13:04

done, and I submitted another suggestion (more like a wild idea), too


jesse697
2021-1-12 19:19:38

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!”


greg
2021-1-12 19:27:40

wants an animated zipy to pop up and say “Hi! It looks like you’re trying to write a multi-branch conditional…”


greg
2021-1-12 19:31:36

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


notjack
2021-1-12 19:32:15

damn that’s good


jesse697
2021-1-12 19:37:46

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.


samth
2021-1-12 19:38:21

you can require it


jesse697
2021-1-12 19:38:51

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.


sorawee
2021-1-12 19:40:08

Can’t you raco make to detect syntax error?


jesse697
2021-1-12 19:40:50

looks like I could do racket -t foo.rkt


jesse697
2021-1-12 19:42:40

@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


jesse697
2021-1-12 19:43:29

I’ll check it out — thanks


greg
2021-1-12 20:04:10

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?


greg
2021-1-12 20:06:13

(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.)


ben.knoble
2021-1-12 20:13:08

#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


ben.knoble
2021-1-12 20:24:49

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?


ben.knoble
2021-1-12 20:27:45

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.


sorawee
2021-1-12 20:38:44

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


samth
2021-1-12 20:39:03

sorawee
2021-1-12 20:39:44

But I agree that this is confusing, and could potentially be a bug.


ben.knoble
2021-1-12 20:40:10

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.


sorawee
2021-1-12 20:40:45

syntax-parse’s #:with is similar to with-syntax


sorawee
2021-1-12 20:40:50

So yes


sorawee
2021-1-12 20:41:16

But note that you gotta use (datum->syntax stx 'run), not #'run


ben.knoble
2021-1-12 20:41:55

grrrr… ok, let’s try that


ben.knoble
2021-1-12 20:44:00

thank you @sorawee that made a big difference, at least for ,enter!


me1890
2021-1-12 20:53:36

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


sorawee
2021-1-12 20:55:41

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


sorawee
2021-1-12 20:55:59

E.g.,

(define-simple-macro (@#%module-begin . prog) #:with X (datum->syntax this-syntax 'x) (#%module-begin (λ (X) . prog)))


sorawee
2021-1-12 20:56:13

With this, you don’t need to provide λ


ben.knoble
2021-1-12 20:57:48

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)


sorawee
2021-1-12 21:00:58

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.


ben.knoble
2021-1-12 21:01:47

Hm. I’ll have to try it, as you said, though this is an instance where I really can’t visualize the various interactions


ben.knoble
2021-1-12 21:19:18

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.


alexharsanyi
2021-1-12 22:53:36

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-&gt;string (get-pure-port (string-&gt;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


alexharsanyi
2021-1-12 22:54:45

this is on Windows with:

$ racket --version Welcome to Racket v7.9.0.22 [cs].


samth
2021-1-12 23:02:54

Do you have Racket BC installed? Or an earlier version?


alexharsanyi
2021-1-12 23:11:47

Unfortunately not


samth
2021-1-12 23:15:23

Ok


samth
2021-1-12 23:15:35

Cc @mflatt


mflatt
2021-1-12 23:44:51

It could be that the openssl libraries don’t work with “MemoryModule.c”.


samth
2021-1-12 23:45:37

Ah, C