teh6
2021-2-8 11:00:16

Hi, I’m a new PhD student working with Edwin. We’ve found a bit of odd behaviour in the Racket codegen for Idris2: If you use a foreign sleep function in a multithreaded program, it seems to run the threads sequentially (minimal example: https://github.com/CodingCellist/idris2-racket-sleep-debug). Does anyone have an idea as to why this might be happening? :)


soegaard2
2021-2-8 11:01:25

That first sentence confused me… :slightly_smiling_face: http://computersystemsartists.net/csc3200/scheme_pages/edwin.htm


soegaard2
2021-2-8 11:03:53

This part of the documentaion refers to the BS backend, but might be relevant: https://docs.racket-lang.org/inside/threads.html?q=racket%20thred#%28part._usefuel%29


soegaard2
2021-2-8 11:06:09

I don’t know how thread switching works with the CS backend.


ryanc
2021-2-8 11:11:29

Racket threads are green threads. Calling a foreign function blocks all Racket threads from running. If possible, you should use Racket’s sleep and synchronizable events instead of blocking FFI calls. If that’s not possible, one workaround is to use the ffi/unsafe/os-thread library (only available on Racket CS, and beware the restrictions on code running in an OS thread).


teh6
2021-2-8 11:46:28

Aah, so using any foreign function which doesn’t immediately return (like sleep ) will block all Racket threads until that function returns?


ryanc
2021-2-8 12:29:02

That’s right.


gknauth
2021-2-8 12:38:26

I’ll have to ask Jerry Sussman if he uses Edwin these days. I saw him using it a few years ago, but I know he also uses GNU Emacs.


mflatt
2021-2-8 13:09:00

A foreign function that blocks will block all Racket threads, not just the current one. That’s because all Racket threads (within a place) run on the same OS thread.

If you’re looking for OS-scheduled threads, you can use separate places, or use ffi/unsafe/os-thread, where “unsafe” is in the ltter name because you then have to avoid any Racket-thread synchronization. With either places or rawer OS threads, specify #:blocking? #t for blocking foreign calls so that they don’t disable garbage collection while blocking.


mflatt
2021-2-8 13:09:46

(I see that here were answers already that I missed by not scrolling down in Slack!)


greg
2021-2-8 17:07:25

The snapshot server seems to be giving 403 Forbidden errors. e.g. https://www.cs.utah.edu/plt/snapshots/current/installers/racket-current-x86_64-linux-precise.sh I noticed this from a setup-racket GitHub action failing, and got same result trying that URI from home just now.


greg
2021-2-8 17:08:29

The message suggests the server can’t read htaccess: Forbidden You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe Apache/2.4.29 (Ubuntu) Server at <http://www.cs.utah.edu\|www.cs.utah.edu> Port 443


greg
2021-2-8 17:10:25

~= “access denied because I can’t access htaccess” :slightly_smiling_face:


samth
2021-2-8 17:13:42

cc @mflatt


jestarray
2021-2-8 17:25:10

what is the release date for v8.0 cs ?


samth
2021-2-8 17:25:51

Real Soon Now


samth
2021-2-8 17:26:18

Basically, we’re still working on some last release-related issues but it should be done soon.


mflatt
2021-2-8 17:27:48

Looks like rsync failed uploading the snapshot. I restarted it.


mflatt
2021-2-8 17:59:29

Should work, finally.


mflatt
2021-2-8 18:00:04

The broken rsync apparently left the directory with bad permissions, and just restarting rsync didn’t fix it.


greg
2021-2-8 19:41:18

Thanks!!


joel
2021-2-8 20:21:09

Hopefully this isn’t too dumb of a question. I’m trying to make a doclang-like #lang that, instead of exporting a list, provides a function that lets you fill in that list with different values at run time (via the function arguments). See it here: https://github.com/otherjoel/beeswax/ I decided to use doclang-raw from pollen/private/external (don’t want the scribble-like decode treatment), because it seemed ready-made to let me use top-level forms like require inside my lang. Well now I have it mostly working — except I can’t use top-level forms (because the only way I could think of to get doclang-raw to give me a working procedure instead of a “doc” was to expand all the expressions inside lambda). So here’s my question: should I go down the road of trying to customize doclang-raw for my purposes, or is there a better approach?


soegaard2
2021-2-8 20:22:45

The example from the readme is: #lang beeswax &lt;html&gt; &lt;head&gt; &lt;title&gt;◊(hash-ref metas 'title)&lt;/title&gt; &lt;/head&gt;&lt;body&gt; ◊(-&gt;html doc) &lt;/body&gt;&lt;/html&gt;


soegaard2
2021-2-8 20:23:30

What would the expansion be?


joel
2021-2-8 20:27:32

So running that example in the REPL (but just use, e.g. doc and not (-&gt;html doc) for now) will as of right now get you a 2-arity procedure, render that takes two arguments, doc and metas. (https://github.com/otherjoel/beeswax/blob/d212965f3dad395d11e1185382eb8c154e8dc2e6/expander.rkt#L16-L23)


greg
2021-2-8 20:28:05

Probably too simple and specific to be a real answer, but: If the only top-level form you need is require, do you know about local-require and would that work?


joel
2021-2-8 20:31:49

It’s a little hard for me to follow it all the way through the doclang-raw expander but it ends up like (provide (all-defined-out) render) (define (render doc metas) (beeswax-concat-bytes (list . ("&lt;html&gt;\n" "&lt;head&gt;\n" "&lt;title&gt;" (hash-ref metas 'title) "&lt;/title&gt;" ...) etc.


soegaard2
2021-2-8 20:34:03

That looks okay - I think? I think, I am missing the context of “I can’t use top-level forms”.


joel
2021-2-8 20:34:31

That could be a workaround in this case. Are there any performance differences (not that performance is sacred in this case)? If I’m just not going to allow top-level forms then I probably don’t need anything doclangish


soegaard2
2021-2-8 20:35:06

Hmm. It might be simpler to make your own copy of doclang-raw.rkt and modify it into what you need.

Also, since it is buried in /private/ you can’t know whether it will change in the future.


joel
2021-2-8 20:36:37

Well within the #lang beeswax file I’d like to be able to use require. But require is being expanded inside of lambda; doclang-raw isn’t properly lifting it out first. So I think I might have to make my own modified doclang-raw, but I was wondering if there is a better approach to this sort of thing before I do that.


soegaard2
2021-2-8 20:37:53

Okay, that is a problem.


greg
2021-2-8 20:41:56

Ah, sorry, I read your question too quickly and missed the main point.


soegaard2
2021-2-8 20:42:40

Only workaround, I can think of is using local-require instead of require. But a “proper” solution is probably better.


joel
2021-2-8 20:45:47

What bad things could happen if I just defined require as (make-rename-transformer local-require) ?


greg
2021-2-8 20:46:41

Having misunderstood your question, once, I’ll risk doing that a second time. :slightly_smiling_face: Are you trying to do something like “template variables” here?


joel
2021-2-8 20:46:50

Yes exactly


greg
2021-2-8 20:47:19

Because web-server/templates has an include-template that I used in Frog.


greg
2021-2-8 20:47:36

I barely remember how this works and it looks very hacky to my eyes today. But…



soegaard2
2021-2-8 20:48:01

I looked for that! But I found x number of other libraries, also named “template” something.


joel
2021-2-8 20:48:31

Yes, Pollen has something similar as well. The larger goal of this project is to make a #lang for the templates themselves, so they can be proper racket modules in their own right rather than strings that get eval’d at run time


greg
2021-2-8 20:48:46

Maybe you’d be better just ignoring my Frog example, at least at first, and looking at web-server/templates, only. :slightly_smiling_face:


greg
2021-2-8 20:49:27

OK. Interesting.


greg
2021-2-8 20:51:19

I don’t have anything super useful to offer atm, but, if I were trying to figure this out I might look at those for ideas (good or bad).


vincent.sampieri5
2021-2-8 22:49:04

@vincent.sampieri5 has joined the channel


joel
2021-2-9 02:15:30

OK so Pollen actually does the make-rename-transformer trick for local-require in its templates too. https://github.com/mbutterick/pollen/blob/bd23f651fb4be5e308ce31422dfb2193eff5dae7/pollen/private/render-helper.rkt#L51-L52


notjack
2021-2-9 03:38:16

this has got to be a bug right (define (importance&lt;? a b) (&gt; (or (cadddr a) -inf.0) (or (cadddr b) -inf.0))) (source: https://github.com/racket/racket/blob/master/racket/collects/raco/raco.rkt#L22)


sorawee
2021-2-9 03:49:22

I don’t think it’s a bug, but probably should be named importance&gt;?. The output of raco help is correct as expected.


notjack
2021-2-9 03:55:00

bizarre


sorawee
2021-2-9 03:56:48

notjack
2021-2-9 04:13:46

nope, I was looking into how raco dispatches to subcommands


notjack
2021-2-9 04:14:19

because I want resyntax to include separate resyntax analyze and resyntax fix subcommands


sorawee
2021-2-9 04:14:58

Just add resyntax command. And have resyntax use command-line to parse analyze and fix.


notjack
2021-2-9 04:15:32

yeah that’s pretty much what I’m doing


notjack
2021-2-9 06:11:57

:grin:


notjack
2021-2-9 06:46:48