
@greg I regularly have this problem when working with racket/base
lang. I am writing using racket-mode
and do for example (define tmp (make-temporary-file))
. Then I run and baamm, racket complains that make-temporary-file
is an unbound identifier. Is there a way in racket-mode, with a keypress to adjust my requires so that I have no extra requires or missing requires? There are a few require utilities in racket-mode
but none that does this. Am I wrong?

ok. I understand that it’s not easy to achieve this because many libraries can export the same identifier, but maybe this would be easy to do if the identifier is provided by a racket sublibrary?

In my implementation of loci
, I need to mimic the fact that a place is ready for synchronization when a message is available on the channel. However, the interesting thing here is that the result of synchronization is not the channel, but instead is the message. How is this implemented? Native places seem to be implemented in C so no help there and the version based on threads doesn’t seem to be doing the right thing - but most likely the problem is mine in not understanding #:property prop:evt
when a lambda is given. The documentation refers to guard-evt
whose documentation I can’t understand. Can someone explain how this works to me? I promise to create a PR to improve the docs once I understand it.

you might take a look at the Chez implementation of places

You mean the racket-on-chez implementation of places? is that in racket?



thanks for the references

a guard-evt
is basically a function that produces an event, and it’s ready when the event produced is ready

@pocmatos you may find the following paper useful for discussing similar issues and how to handle them robustly: https://www.cs.utah.edu/plt/publications/pldi04-ff.pdf

@pocmatos I empathize. Don’t have much bandwidth right now to think/implement, but, two quick thoughts: 1. You could start a new file with #lang racket
, and switch to #lang racket/base
using M-x racket-base-requires
only after the “edit/churn velocity” of the file settles down. But, not ideal. e.g. Easy to forget to switch it, and, “heavy” during dev when you least want it. 2. I can imagine something that prompts the user to pick the module to require
, when ambig, or just adds it when clear. Much like how help search works on http://docs.r-l.org\|docs.r-l.org. But again, don’t have time this week to work on that. (Would welcome a PR, though also not so much time to review a PR right now.)

TL;DR Understand the need, good feature idea.

@samth ok, maybe I am missing something then. Need to study the code better. From looking at the code in thread/place.rkt
it seems the trick lives in place-channel
, prop:evt
property.

#:property prop:evt (poller (lambda (self poll-ctx)
(define in-mq (ephemeron-value (pchannel-in-mq-e self)))
(if in-mq
(dequeue! in-mq
(lambda (v)
(values #f
(wrap-evt
always-evt
(lambda (a)
;; Convert when out of atomic region
(un-message-ize v)))))
(lambda (sema)
(values #f (replace-evt sema (lambda (s) self)))))
(values #f never-evt))))

what’s that poller
? it’s not documented.

@ryanc thanks, will read.

@greg thanks, lets see if I can get a PR out.

that code is written against lower layers which aren’t exposed, so not everything is documented

I can’t remember if poller
is written in that layer or in the cs
code

looks like the same as unsafe-poller

ah, that one I can find… quite low level stuff already.

maybe what I need is related to that replace-evt
…

hummm… wrap-evt
is also a good candidate! :slightly_smiling_face:

@mflatt in the code above, it seems like messages would get lost when synchronizing on two place channels, since the success case of dequeue!
pops a message and puts it in an evt without forcing the scheduler to commit to that evt. (The docs for sync
say that if multiple evts are ready (like wrapped always-evt
s), one is chosen pseudo-randomly.)

@ryanc The poller
context is unusual in that returning always-evt
means that the event will be selected.

See the poller
declaration in “evt.rkt”

ah, thanks

So the first result value is a fast path rather than being the only way of forcing the scheduler to select the current event.

@pocmatos I’m not certain in this case, but I would expect you to be able to do what you want without dropping down to the level of unsafe-poller
. Often it’s a matter of using the existing event constructs in the right (but not obvious way). The primitive implementation of place messages has to be that primitive because it’s essentially the primitive implementation of an OS-thread–Racket-thread bridge.

@ryanc Yes. And that fast path doesn’t support running in non-atomic mode.

Yes, after reading the docs… very slowly… I think I got it! :slightly_smiling_face: Running some tests… thanks.

net2
is meant to provide a wrapper to let you send HTTP requests over Unix sockets, tcp sockets, and in-process pipes to other places / threads with the same interface - started work on it and got somewhat far but stalled on it for various non-technical reasons. I hope to get back to it eventually.

It’s definitely not in a usable state yet, at least for your purposes