philip.mcgrath
2021-10-31 18:01:03

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.


laurent.orseau
2021-10-31 18:01:19

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?


laurent.orseau
2021-10-31 18:02:11

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


laurent.orseau
2021-10-31 18:03:11

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


laurent.orseau
2021-10-31 18:16:36

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?) (&gt; waited wait-max)) (sleep/yield wait-seconds) (loop (+ waited wait-seconds))))))


d_run
2021-10-31 18:47:42

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)


soegaard2
2021-10-31 18:52:40

@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.


soegaard2
2021-10-31 18:56:14

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



mflatt
2021-10-31 19:22:57

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


robby
2021-10-31 19:35:28

I don’t know a better way.


laurent.orseau
2021-10-31 19:35:56

ok, thank you both


robby
2021-10-31 19:37:09

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.


laurent.orseau
2021-10-31 19:41:59

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?



soegaard2
2021-10-31 19:50:12

Ep 133



laurent.orseau
2021-11-1 05:26:20

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


laurent.orseau
2021-11-1 05:52:54

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