
The great thing about JSON standards is there are so many to choose from :slightly_smiling_face: If you like the IETF version, <https://datatracker.ietf.org/doc/html/rfc8259#section–4|RFC 8259 §4> says: > An object whose names are all unique is interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates. IIRC, the ECMA and http://json.org\|json.org standards are completely silent on this issue.

What’s the right way to wait until the window really has the focus after a call to (send wnd focus)
? A (sleep/yield 0.05)
does the trick, but that doesn’t seem right. I tried various combinations of (yield 'wait)
and (queue-callback ...)
but without success. Any clue?

The problem may be exacerbated by the fact that it’s a quickscript, and I don’t have a great grasp of how many event spaces there are, or even where each event goes

Ideally I’d like to obtain an event on which I could sync. I could also do a busy wait, but that seems worse than sleep/yield

Current solution is a busy loop capped at 0.5s to avoid deadlocking: (when wnd (send wnd focus)
; Busy loop to make sure the window has the focus. Not
; ideal but works.
; Don't wait more than 0.5s to avoid deadlocking in case of problem.
(let ([wait-seconds 0.02] [wait-max 0.5])
(let loop ([waited 0])
(unless (or (send wnd has-focus?) (> waited wait-max))
(sleep/yield wait-seconds)
(loop (+ waited wait-seconds))))))

Rando lib question:
Can Sketching (https://docs.racket-lang.org/manual-sketching/index.html) output a canvas
usable by GUI Easy? (https://docs.racket-lang.org/gui-easy/index.html)

@d_run I think so. Here are the steps: 1. Setup a canvas with gui-easy 2. Get the drawing context dc from the canvas 3. Call current-dc
from sketching/parameters
to set the drawing context used by Sketching. 4. Make a drawing using the commands (require sketching/exports-all
). 5. Profit.

Actually, you could probably also do: #lang sketching
(require gui-easy)
(no-loop)
(no-gui)
<setup canvas with gui-easy>
(current-dc <the dc from the canvas>)
<draw here>


I don’t think there’s a better way right now, unless @robby remembers something I have forgotten.

I don’t know a better way.

ok, thank you both

Another thought: it may make sense to put whatever the work you’re doing after the sleep into a queued callback (in the general case you have to cps). The reason being that some drastic change may have happened during that yield and I just find it easier to think about my code when I avoid the yields.

I’m happy to do that, but I’m a little fuzzy on the logic. Do you mean that if I don’t put the subsequent gui calls into a queue callback, someone else may need to do a yield to wait for my forced events to finish, but if instead I push them into the queue, that won’t be necessary? If so, should I put the gui calls before the busy loop in a queue-callback too to respect the order?

This just links me to functional geekery, which seems to have ceased? Was there a specific episode?
https://www.functionalgeekery.com\|https://www.functionalgeekery.com

Ep 133

Potentially worth checking DrRacket/Racket/expeditor/etc for this vulnerability: https://www.lightbluetouchpaper.org/2021/11/01/trojan-source-invisible-vulnerabilities/\|https://www.lightbluetouchpaper.org/2021/11/01/trojan-source-invisible-vulnerabilities/

Woah, I honestly didn’t expect such things to be possible with unicode. I suppose the fix for unterminated unicode control sequences should be at the reader level? For homoglyphs, I’m not sure, since symbols can be constructed, so checking for similar symbols could be costly. Disallowing some glyphs may not be nice to some languages

@samth you suggest to check at the editor level, but wouldn’t it be better at the reader level?