laurent.orseau
2021-2-7 08:02:38

What platform? I don’t recall such an issue myself


jestarray
2021-2-7 08:40:11

windows 10


jestarray
2021-2-7 08:40:13

lemmie do a screen cap


jestarray
2021-2-7 09:45:51

jestarray
2021-2-7 09:47:47

right around 28 seconds you can hear my mouseclicks trying to click step again but it just wont do anything until i unhover then rehover. This is windows 10 on cs version 8.0.0.1—2021–01–19(08fa243/a)


soegaard2
2021-2-7 09:48:28

I almost never use the debugger. Is there something you need to click first, to leave the breakpoint?


jestarray
2021-2-7 09:48:29

i use dual monitors , 4k and a 1080p one so im unsure if that plays a role..


jestarray
2021-2-7 09:49:12

i dont want to leave the breakpoint, i want to keep stepping through the program line by line


jestarray
2021-2-7 09:52:36

i really gotta look into upping the racket-langserver… if we get autocompletion, parameter name inferencing(like rust analyzer) so we dont have to make a round trip to the docs, and a faster debugger, it would be a huge productivity game. Things like structs with a lot of members would no longer be a guessing game completely without needing keyword arguments or macros


soegaard2
2021-2-7 09:57:40

I missed “i have to unmouse, re-hover and then click…”. If that works, then it must be something to do with the gui library.


philip.mcgrath
2021-2-7 12:22:54

I think @lexi.lambda might know, if there is any.


mflatt
2021-2-7 13:28:05

@robby has been adjusting the way those buttons work (aimed at fixing the way highlights have been too sticky on some platforms). I think he’s aware of this problem and gradually improving the buttons, still.


kellysmith12.21
2021-2-7 14:22:26

Thought for the docs: some of the papers on Racket’s system of continuations include pictures that show examples of continuations, frames, and marks. I found those diagrams to be very helpful. Perhaps it would be worthwhile to include similar pictorial examples in the docs on continuations and on the evaluation model?


laurent.orseau
2021-2-7 14:24:31

Could you share one the examples you found the most helpful?


kellysmith12.21
2021-2-7 14:30:44

In <https://www.cs.utah.edu/plt/publications/pldi20-fd.pdf|Compiler and Runtime Support for Continuation Marks>, the examples of continuation frames and marks (seen starting in section 3) are, I think, a great tool for learning about and reasoning about continuations.


laurent.orseau
2021-2-7 14:33:12

thanks!


robby
2021-2-7 15:33:33

Thanks @jestarray, I’ve pushed a fix. (I actually didn’t know about this problem; it seems to have been a different one than I’ve been fighting with :slightly_smiling_face:)


greg
2021-2-7 16:37:03

I stumbled across that paper a month ago and was surprised to see it was only about 6 months old. I agree it’s super helpful.


badkins
2021-2-7 17:09:05

I don’t suppose anyone has developed a “fixnum struct” library? I just realized that my move struct for my chess engine could be represented in 43 bits currently, so there’s no need for me to allocate a struct for it (a chess engine generates & makes a lot of moves :) ). Before I make an abstraction, I thought I’d check, on the off chance that something exists.


soegaard2
2021-2-7 17:11:23

Do you mean like fxvector?


badkins
2021-2-7 17:12:08

No, I mean, I can represent my entire move struct in a single fixnum. I would just have to bit shift fields into place.


badkins
2021-2-7 17:12:33

I’d like to avoid the allocation of the move struct entirely.


badkins
2021-2-7 17:14:06

IIRC structs are implemented with vectors, so creating a struct is allocating a vector.


badkins
2021-2-7 17:18:37

It’s possible I’m falling into the “premature optimization” trap. Somewhow, gc time is pretty darn small! cpu time: 30118 real time: 30672 gc time: 28


badkins
2021-2-7 17:19:32

That was for 21,500,000 nodes searched. Maybe there is some magic optimizations going on I’m not aware of :)


soegaard2
2021-2-7 17:20:50

So, you just need a convenient way to define functions that pick out bits of a fxnum?


badkins
2021-2-7 17:22:02

Well, I’m fine coding up the setters & getters, but if there was a general abstraction to use a fixnum for structs when you know that the fields are all fixed bit sizes, and the total fits in 60 bits, it would be nice.


soegaard2
2021-2-7 17:24:10

Tony’s bitsyntax is close, but it use a bytes to store the bits. I can’t think of a library for your use case.


badkins
2021-2-7 17:24:16

So instead of: (struct move (src src-idx dst-idx captured-piece promoted-piece is-castle-queenside? is-castle-kingside? is-ep-capture?) #:transparent #:mutable) you might have: (fixnum-struct move (src 8 src-idx 7 dst-idx 7 captured-piece 8 promoted-piece 8 is-castle-queenside? 1 is-castle-kingside? 1 is-ep-capture? 1) #:transparent #:mutable)


soegaard2
2021-2-7 17:32:25

This would a great example for the macro tutorial. I’ll give it a go.


badkins
2021-2-7 17:36:32

I wonder if it might be nice to handle boolean fields differently. For example, for is-castle-queenside? you could specify it was a boolean type, then the setter/getter would deal with booleans, e.g. (move-is-castle-queenside? m) -> boolean?


badkins
2021-2-7 17:38:19

(fixnum-struct move (src 8 src-idx 7 dst-idx 7 captured-piece 8 promoted-piece 8 is-castle-queenside? 1 #:boolean #t is-castle-kingside? 1 #:boolean #t is-ep-capture? 1 #:boolean #t) #:transparent #:mutable)


soegaard2
2021-2-7 17:38:20

Note: The racket-mode indenter indents standard clauses like [src 8] [src-idx 7] etc better than clauses with no brackets.


badkins
2021-2-7 17:38:43

I’ll leave the syntax up to you :)


massung
2021-2-7 17:45:00

@badkins it’s been a while since i coded up a chess engine, but it looks like your struct - aside from “everything” is already pretty close to a FEN. Just tossing it out there that you may be able to get considerably more compact if moves are deltas from a packed-FEN “keyframe”.

Regardless, I hope you share your code at some point. Chess code is something that’s truly awesome to learn how each person solves it. :slightly_smiling_face:


badkins
2021-2-7 17:47:30

Code is here: https://github.com/lojic/RacketChess\|RacketChess - once I have a reasonably complete set of features, I’m going to re-build it with a series of blog posts taking a beginner from nothing to a decent engine. I have plenty of space, but not enough time, so I’m pretty sure a packed-FEN would slow it down.


badkins
2021-2-7 17:48:38

It should make for a nice Racket tutorial, and I hope to introduce some syntactical abstractions later.


soegaard2
2021-2-7 17:49:15

Do you prefer macros or functions as the getters?


badkins
2021-2-7 17:50:08

Whatever is fastest. I suppose define-inline would be about the same speed as a macro, but I don’t know. I don’t think I’ll need any higher order functionality, so macros would be fine, I think.


badkins
2021-2-7 17:51:25

I could use this in https://github.com/lojic/RacketChess/blob/master/src/piece.rkt\|piece.rkt also - for now, I just have a very hacky way of doing it.


soegaard2
2021-2-7 18:56:27

Here is the first version:


soegaard2
2021-2-7 18:57:11

soegaard2
2021-2-7 18:58:52

Oh - I forgot to use define-inline . I’ll fix that. Also, one can switch to the unsafe versions of the fx-operations with: (require (filtered-in (λ (name) (and (regexp-match #rx"^unsafe-fx" name) (regexp-replace #rx"unsafe-" name ""))) racket/unsafe/ops))


soegaard2
2021-2-7 19:05:16

With inlining:


soegaard2
2021-2-7 19:26:50

And now with update functions:


soegaard2
2021-2-7 19:27:10

philip.mcgrath
2021-2-7 19:37:49

I’m implementing an algorithm that computes with a lot of Byte -sized values. Out of curiosity, I’ve been exploring how much I can prove to Typed Racket that it’s safe to use fixnum arithmetic specialization. The Optimization Coach has a useful hint that adding Byte and Index annotations can help prove that functions will produce Fixnum-sized results. But it seems that there aren’t types like Negative-Byte or Negative-Index (e.g. Byte is (U Zero Positive-Byte)), which limits how often I can use that strategy. Would those types be useful additions to Typed Racket? Are there other techniques that I should try?


philip.mcgrath
2021-2-7 19:38:35

Here’s some code: #lang typed/racket (require syntax/parse/define) (define (year-&gt;easter/values [x : Positive-Integer]) ;; Algorithm: ;; - Jean Meeus, "Astronomical Algorithms," 2nd ed., ;; (Richmond: Willmann-Bell, 1998), ;; chapter 8, "Date of Easter," pp. 67--68 ;; - Reinhold Bien, "Gauß and Beyond: The Making of Easter Algorithms," ;; Arch. Hist. Exact Sci. 58, 439–452 (2004), ;; table 9, "Algorithm of an anonymous correspondent," p. 451, ;; &lt;<https://doi.org/10.1007/s00407-004-0078-5>&gt; ;; ;; The macro lets the implementation obviously match ;; the presentation by Meeus and Bien. (divide/by/quotient/remainder [ x #:/ 19 #:-&gt; _ a] [ x #:/ 100 #:-&gt; b c] [ b #:/ 4 #:-&gt; d #{e : Byte}] [ (+ 8 b) #:/ 25 #:-&gt; f _] [ (+ b (- f) 1) #:/ 3 #:-&gt; g _] [ (+ (* 19 a) b (- d) (- g) 15) #:/ 30 #:-&gt; _ h] [ c #:/ 4 #:-&gt; i k] ;; yes, we skip j [(+ 32 (* 2 e) (* 2 i) (- h) (- k)) #:/ 7 #:-&gt; _ l] [ (+ a (* 11 h) (* 22 l)) #:/ 451 #:-&gt; m _] [ (+ h l (* -7 m) 114) #:/ 31 #:-&gt; n p] #:then (values n (add1 p)))) (define-simple-macro (divide/by/quotient/remainder [dividend:expr #:/ divisor:expr #:-&gt; q:id r:id] ... #:then body:expr ...+) (match-let*-values ([{q r} (quotient/remainder dividend divisor)] ...) body ...))



soegaard2
2021-2-7 19:49:46

The user can’t register at http://racket-lang.org\|racket-lang.org. The error is very odd. Maybe the “Servlet Error” page has an error?


spdegabrielle
2021-2-7 19:52:48

I can’t either


soegaard2
2021-2-7 19:53:09

@jeapostrophe ^


badkins
2021-2-7 20:02:30

Awesome - I’ll try it out.


badkins
2021-2-7 20:20:47

First test passed :) (module+ test (require rackunit) (fixnum-fields move ([src 8] [src-idx 7] [dst-idx 7] [captured-piece 8] [promoted-piece 8] [is-castle-queenside 1 #:flag] [is-castle-kingside 1 #:flag] [is-ep-capture 1 #:flag])) (let* ([ m (make-move #b101 27 35 #b110 #b011 1 0 0) ] [ src (move-src m) ] [ src-idx (move-src-idx m) ] [ dst-idx (move-dst-idx m) ] [ captured-piece (move-captured-piece m) ] [ promoted-piece (move-promoted-piece m) ] [ is-castle-queenside? (move-is-castle-queenside? m) ] [ is-castle-kingside? (move-is-castle-kingside? m) ] [ is-ep-capture? (move-is-ep-capture? m) ]) (check-not-false (fixnum? m)) (check-not-false (fixnum? src)) (check-not-false (fixnum? src-idx)) (check-not-false (fixnum? dst-idx)) (check-not-false (fixnum? captured-piece)) (check-not-false (fixnum? promoted-piece)) (check-not-false (boolean? is-castle-queenside?)) (check-not-false (boolean? is-castle-kingside?)) (check-not-false (boolean? is-ep-capture?)) (check-equal? (move-src m) #b101) (check-equal? (move-src-idx m) 27) (check-equal? (move-dst-idx m) 35) (check-equal? (move-captured-piece m) #b110) (check-equal? (move-promoted-piece m) #b011) (check-not-false (move-is-castle-queenside? m)) (check-false (move-is-castle-kingside? m)) (check-false (move-is-ep-capture? m))) )


badkins
2021-2-7 20:22:14

Double thanks – 1) for being able to simplify my chess engine, and 2) for the macro tutorial which I’m still very weak with :)


badkins
2021-2-7 20:22:51

I think it’s worth making it a package.


badkins
2021-2-7 20:23:42

I’ll wait a bit before using it extensively in case you do want to make a package and make any syntax changes.


soegaard2
2021-2-7 20:28:07

Great you can use it. I haven’t got time for making it into a package.

Consider just keeping it as a file in your engine. That way you can change things (like using unsafe operations), if you want extra speed.


spdegabrielle
2021-2-7 20:28:17

I’ve responded on Reddit.


badkins
2021-2-7 20:30:58

Sounds good. I’ll add an attribution.


soegaard2
2021-2-7 20:31:39

Apropos macro-tutorial, is the code readable?


badkins
2021-2-7 20:35:12

Yes, I think so. I’ll need to spend some time with it to understand it fully, but that’s more due to my level of macro knowledge than the clarity of the code I think.


samdphillips
2021-2-7 21:01:26

Has anyone used plot to write SVG and gotten mouse overs to work with the plot?


samdphillips
2021-2-7 21:02:46

I mean mouse overs if I was to use some sort of Javascript glue in the browser.


badkins
2021-2-7 21:23:54

@soegaard2 as a testimony to the suitability as a tutorial, I was able to make some changes, so it must be clear enough :) I added the ability to use set and unset for the flag fields: (set-move-is-castle-queenside? m) & (unset-move-is-castle-queenside? m). https://github.com/lojic/RacketChess/blob/development/src/fixnum-fields.rkt


badkins
2021-2-7 21:25:15

At first I didn’t like the fact that there seemed to be some redundancy by having both 1 and #:flag, but it’s probably cleaner to have it that way vs. ... [ is-ep-capture #:flag ] ...


badkins
2021-2-7 21:25:43

Since you may want a 1-bit value that’s not a flag, I suppose it makes sense to specify both.


soegaard2
2021-2-7 21:26:06

An alternative is to just have 1, and then automatically make flag functions for all fields with width 1.


badkins
2021-2-7 21:26:55

Hmm… that may be the way to go.


soegaard2
2021-2-7 21:28:08

Btw, in (fxand 1 flag-input-mask) I think you can just use 1. In update-prefix-name I used (fxand val flag-input-mask) but here val is supplied by the user (so it can be too wide).


badkins
2021-2-7 21:28:48

I normally prefer explicit over implicit, so maybe I’ll leave 1 and #:flag for now. `I dunno, I do normally like explicit over implicit, so maybe I’ll leave


soegaard2
2021-2-7 21:29:14

Right now a fields of width larger than 1 can also be used as flags. Zero is false, and non-zero is true.


badkins
2021-2-7 21:29:32

If you’re going to use the code for a tutorial, there were a couple bindings that weren’t used that you can delete. I forget which ones at the moment.


soegaard2
2021-2-7 21:29:55

Thanks for the tip. I’ll check.


soegaard2
2021-2-7 21:32:55

Btw - a check that the total width is smaller than the number of bits in a fixnum, would be a good idea.

I couldn’t remember what to call to the length on the running system.


badkins
2021-2-7 21:33:19

No need for me to shift 0 either :)


badkins
2021-2-7 21:35:38

I think I’d be fine with just limiting to 60 bits regardless of system.


badkins
2021-2-7 21:36:05

worst case, iterate until (fixnum? v) returns false :)


soegaard2
2021-2-7 21:36:23

Oh yeah :slightly_smiling_face:


samth
2021-2-7 21:56:15

There’s some code for this in the Typed Racket implementation


badkins
2021-2-7 22:00:29

I wondered about that @samth - makes sense it would have it.


tov
2021-2-8 01:22:41

Is there a form that hoists definitions up to module binding level? I seem to recall its existence but can’t remember its name.


sorawee
2021-2-8 01:27:22

I think you are looking for syntax-local-lift-* family


sorawee
2021-2-8 01:28:05

I’ve never used them myself, so I don’t know what they actually do, but it sounds like what you want lol


tov
2021-2-8 01:28:30

Thanks!


samth
2021-2-8 01:32:46

Probably you want syntax-local-lift-module-end-declaration


tov
2021-2-8 03:49:35

Thanks, Sam. I think I have syntax-local-lift-expression working now. (This is for an inline method cache.)