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? :)
That first sentence confused me… :slightly_smiling_face: http://computersystemsartists.net/csc3200/scheme_pages/edwin.htm
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
I don’t know how thread switching works with the CS backend.
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).
Aah, so using any foreign function which doesn’t immediately return (like sleep
) will block all Racket threads until that function returns?
That’s right.
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.
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.
(I see that here were answers already that I missed by not scrolling down in Slack!)
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.
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
~= “access denied because I can’t access htaccess” :slightly_smiling_face:
cc @mflatt
what is the release date for v8.0 cs ?
Real Soon Now
Basically, we’re still working on some last release-related issues but it should be done soon.
Looks like rsync
failed uploading the snapshot. I restarted it.
Should work, finally.
The broken rsync apparently left the directory with bad permissions, and just restarting rsync didn’t fix it.
Thanks!!
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?
The example from the readme is: #lang beeswax
<html>
<head>
<title>◊(hash-ref metas 'title)</title>
</head><body>
◊(->html doc) </body></html>
What would the expansion be?
So running that example in the REPL (but just use, e.g. doc
and not (->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)
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?
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 . ("<html>\n" "<head>\n" "<title>" (hash-ref metas 'title) "</title>" ...)
etc.
That looks okay - I think? I think, I am missing the context of “I can’t use top-level forms”.
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
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.
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.
Okay, that is a problem.
Ah, sorry, I read your question too quickly and missed the main point.
Only workaround, I can think of is using local-require
instead of require
. But a “proper” solution is probably better.
What bad things could happen if I just defined require
as (make-rename-transformer local-require)
?
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?
Yes exactly
Because web-server/templates
has an include-template
that I used in Frog.
I barely remember how this works and it looks very hacky to my eyes today. But…
I looked for that! But I found x number of other libraries, also named “template” something.
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
Maybe you’d be better just ignoring my Frog example, at least at first, and looking at web-server/templates
, only. :slightly_smiling_face:
OK. Interesting.
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 has joined the channel
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
this has got to be a bug right (define (importance<? a b)
(> (or (cadddr a) -inf.0)
(or (cadddr b) -inf.0)))
(source: https://github.com/racket/racket/blob/master/racket/collects/raco/raco.rkt#L22)
I don’t think it’s a bug, but probably should be named importance>?
. The output of raco help
is correct as expected.
bizarre
nope, I was looking into how raco
dispatches to subcommands
because I want resyntax
to include separate resyntax analyze
and resyntax fix
subcommands
Just add resyntax
command. And have resyntax
use command-line
to parse analyze
and fix
.
yeah that’s pretty much what I’m doing
:grin: