soegaard2
2020-3-6 11:04:33

@sorawee Do you happen to use dynamic-require ?


krismicinski
2020-3-6 15:58:05

Hi all, sorry of this has been asked recently, but I have a student working on a small webapp in Racket that will exchange JSON back and forth with a client-side JS app. Does anyone have a favorite web framework in Racket for this kind of work?


deactivateduser60718
2020-3-6 16:27:06

@krismicinski Have you looked at koyo? https://docs.racket-lang.org/koyo/json.html?q=koyo



leif
2020-3-6 21:14:53

Hey @mflatt and @robby the arrows in DrRacket are a bit..err…broken.


leif
2020-3-6 21:15:01

As in, they fade out after a short while.


leif
2020-3-6 21:15:20

Here is an example:


leif
2020-3-6 21:15:49

They reappear at the other end, but there’s a large chunk in the middle where they are invisible.


leif
2020-3-6 21:16:06

Oh, this is also on Ubuntu. I tried it also on @ben’s laptop and the arrows worked fine there.


leif
2020-3-6 21:17:18

Which makes me think this is a mred or racket/gui problem, rather than a DrRacket problem. But I’m not 100% sure of that.


leif
2020-3-6 21:17:40

Also, short arrows show up fine. Its only longer ones that have this issue.


robby
2020-3-6 21:22:04

Or maybe an ubuntu problem?


robby
2020-3-6 21:22:14

Hard to say without some work on it, for sure


leif
2020-3-6 21:29:42

I mean, ya, it could be an ubuntu problem.


leif
2020-3-6 21:30:15

I guess the best way to test that is to use another OS that racket still uses gtk for.


deactivateduser60718
2020-3-6 21:53:28

I’m prototyping a #lang that allows embedded #langs in a Scribble reader. Implementation here: https://github.com/zyrolasting/polyglot/blob/inline-modules/polyglot-lib/polyglot/main.rkt#L19

Here’s an example snippet.

#lang polyglot @mod['what]{ #lang racket/base (provide out) (define out 1) } @require['what] @out It works in DrRacket, but not using the racket CLI launcher. In the latter case, I see the reader invoked 6 times, with an error complaining that 'what was not found in the interim. Why does the behavior differ this much between the two environments?


samth
2020-3-6 21:54:53

Possibly it’s because of errortrace being on in DrRacket


deactivateduser60718
2020-3-6 21:57:36

I understand errortrace adding behavior, but changing it? What can I do to make the #lang behave consistently if instrumentation is disabled?


samth
2020-3-6 22:05:16

Well first figure out if that’s it. Probably by turning the debugging settings off in DrRacket


deactivateduser60718
2020-3-6 22:14:14

Applied these settings. The behavior is consistent, in that it still works only in DrRacket.


deactivateduser60718
2020-3-6 22:16:36

This is 7.6 CS, btw


shu--hung
2020-3-6 22:22:30

I see a scary (eval(require …) ns)` expression


deactivateduser60718
2020-3-6 22:23:18

Would that cause the error?


shu--hung
2020-3-6 22:25:05

I am really unsure But eval require like that depends on certain (runtime) parameters like <https://docs.racket-lang.org/reference/eval.html?q=current-load-rel#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29\|current-load-relative-directory, which are fragile>


shu--hung
2020-3-6 22:25:30

DrR and Racket CLI are two pretty different implementation of REPL


shu--hung
2020-3-6 22:25:49

as far as I understand, DrR does something like evaluating the expression inside a module’s namespace, using module-&gt;namespace



shu--hung
2020-3-6 22:26:03

while Racket CLI runs things at the hopeless top-level


shu--hung
2020-3-6 22:26:25

If you can obtain the absolute path, there are options like (require (file "absolute path"))


deactivateduser60718
2020-3-6 22:27:04

I already use an absolute path in the case of an rcfile.


shu--hung
2020-3-6 22:27:06

If you are sure that module is going to be in some fixed relative position w.r.t. to the main module, there is define-runtime-module-path


deactivateduser60718
2020-3-6 22:27:23

The one that’s reporting an error is a module declared by expanding a module form from a user string.


shu--hung
2020-3-6 22:27:27

Hmm, then current-load-relative-directory should not affect things


shu--hung
2020-3-6 22:27:41

ah.. That’s definitely going to be interpreted differently


deactivateduser60718
2020-3-6 22:27:45

That example snippet above… The 'what module is what fails to load.


shu--hung
2020-3-6 22:28:05

oh I see where is what


deactivateduser60718
2020-3-6 22:28:05

But again, only in the CLI launcher. What else differs?


deactivateduser60718
2020-3-6 22:28:42

what is declared immediately above the require in the snippet.


shu--hung
2020-3-6 22:32:16

sorry, let me read it more carefully


deactivateduser60718
2020-3-6 22:35:23

I’ll simplify it. The error reproduces in this case too.

#lang polyglot @(module what racket/base (provide out) (define out 1)) @(require 'what) @out


deactivateduser60718
2020-3-6 22:35:40

That is, works in DrRacket but not elsewhere.


shu--hung
2020-3-6 22:58:38

What do I need to install? I got standard-module-name-resolver: collection not found for module path: polyglot/lang/reader collection: "polyglot/lang"


shu--hung
2020-3-6 22:59:06

Another piece of code I tried work: ;; ilm.rkt #lang racket/base (provide (all-defined-out)) (define ns (make-base-namespace)) (define (eval-for-each stx) (define enriched-stx (namespace-syntax-introduce stx ns)) (for ([each-stx (in-list (syntax-&gt;list enriched-stx))]) (eval-syntax each-stx ns))) #lang racket/base (require "ilm.rkt") (eval-for-each (datum-&gt;syntax #f '( (module what racket/base (provide out) (define out 1)) (require 'what) (displayln out) )) )


greg
2020-3-6 22:59:38

What if you use command-line racket, but then use the xrepl command ,enter main.rkt to run. IIRC that does a module-&gt;namespace. Maybe interesting if you want to confirm that is the element that DrRacket is contributing.


shu--hung
2020-3-6 23:00:25

OTOH I remember seeing where that (eval E ns) and (parameterize ([current-namespace ns]) (eval E)) are different..some module registry thingy


greg
2020-3-6 23:01:32

(It’s late and my brain is tired, but quick glance at that code, it feels like you’re re-inventing various things that the Racket module system does, which isn’t necessarily bad, but gets you into unusual territory. Like, quick/shallow glance, I’m not sure why you couldn’t rely more on plain old dynamic-require? But idk, really.)


greg
2020-3-6 23:02:30

“unusual territory” meaning there are probably dozens of details like what @shu—hung mentioned about setting the current-namespace, etc.


greg
2020-3-6 23:02:56

Which could be fun to learn about! But could be a detour from what you’re trying to do.


greg
2020-3-6 23:03:10

Anyway sorry for the tired free advice. It does look cool!


greg
2020-3-6 23:05:08

If it turns out it work in DrRacket because of module-&gt;namespace, you might be able to make it work more generally by using define-namespace-anchor to get the namespace “in” your main.rkt module. Instead of using make-base-namespace.


greg
2020-3-6 23:05:20

Just a rough guess.


deactivateduser60718
2020-3-6 23:36:22

@greg Is there already a way to embed a #lang in a textual language that doesn’t involve a third party package?


deactivateduser60718
2020-3-6 23:36:49

@shu—hung You can install the package locally using raco pkg install --link after cloning the repository.


deactivateduser60718
2020-3-6 23:39:21

,enter on the #lang polyglot module reproduces the error, so I guess that means missing module-&gt;namespace wasn’t an issue.


deactivateduser60718
2020-3-6 23:45:18

Oh, and @greg, using racket-run in racket-mode is the only case in which I see several applications of the reader. In both DrRacket and racket, the reader is called once. But when using racket-run, it is called 4 times!

mkup.rkt&gt; Entering run-markup Entering run-markup ; require: unknown module ; module name: #&lt;resolved-module-path:'what&gt; ; Context: ; /home/sage/Code/polyglot/polyglot-lib/polyglot/main.rkt:76:7 for-loop ; /home/sage/Code/polyglot/polyglot-lib/polyglot/main.rkt:42:2 run-markup ; /home/sage/Code/polyglot/polyglot-lib/polyglot/main.rkt:33:2 markup-read-syntax Entering run-markup ; [Due to errors, REPL is just racket/base] Entering run-markup mkup.rkt&gt; Maybe there’s a clue there?


deactivateduser60718
2020-3-6 23:46:26

In any case, clearly something about how I wrote this code makes it so that it behaves differently depending on what starts it.


deactivateduser60718
2020-3-6 23:47:01

Not sure what, but I’ll reread the docs and see what I can figure out.


deactivateduser60718
2020-3-6 23:48:44

My suspicion is that the module registry for the wrong namespace was updated, even though that module was eval’d on the custom namespace.


greg
2020-3-7 00:03:21

Racket Mode has a “retry as skeleton” feature that, when evaluating the module results in an error, retries it just for bindings (just requires and defines) so that completions are available while you edit to fix the error. This is N/A on the upcoming check-syntax branch, since it is able to get completion candidates by fully expanding (not evaluating). I’m not immediately sure why you’re seeing 4X instead of 2X, I’d need to fully understand your program and do some research.