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

windows 10

lemmie do a screen cap


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)

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

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

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

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

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.

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

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

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?

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

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.

thanks!

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:)

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.

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.

Do you mean like fxvector?

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

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

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

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

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

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

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.

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.

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)

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

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?

(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)

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

I’ll leave the syntax up to you :)

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

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.

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

Do you prefer macros or functions as the getters?

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.

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.

Here is the first version:


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))

With inlining:

And now with update functions:


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?

Here’s some code: #lang typed/racket
(require syntax/parse/define)
(define (year->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,
;; <<https://doi.org/10.1007/s00407-004-0078-5>>
;;
;; The macro lets the implementation obviously match
;; the presentation by Meeus and Bien.
(divide/by/quotient/remainder
[ x #:/ 19 #:-> _ a]
[ x #:/ 100 #:-> b c]
[ b #:/ 4 #:-> d #{e : Byte}]
[ (+ 8 b) #:/ 25 #:-> f _]
[ (+ b (- f) 1) #:/ 3 #:-> g _]
[ (+ (* 19 a) b (- d) (- g) 15) #:/ 30 #:-> _ h]
[ c #:/ 4 #:-> i k] ;; yes, we skip j
[(+ 32 (* 2 e) (* 2 i) (- h) (- k)) #:/ 7 #:-> _ l]
[ (+ a (* 11 h) (* 22 l)) #:/ 451 #:-> m _]
[ (+ h l (* -7 m) 114) #:/ 31 #:-> n p]
#:then
(values n
(add1 p))))
(define-simple-macro (divide/by/quotient/remainder
[dividend:expr #:/ divisor:expr #:-> q:id r:id]
...
#:then
body:expr ...+)
(match-let*-values ([{q r}
(quotient/remainder dividend divisor)]
...)
body ...))


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?

I can’t either

@jeapostrophe ^

Awesome - I’ll try it out.

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)))
)

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

I think it’s worth making it a package.

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

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.

I’ve responded on Reddit.

Sounds good. I’ll add an attribution.

Apropos macro-tutorial, is the code readable?

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.

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

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

@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

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

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

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

Hmm… that may be the way to go.

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

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

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

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.

Thanks for the tip. I’ll check.

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.

No need for me to shift 0 either :)

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

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

Oh yeah :slightly_smiling_face:

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

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

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

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

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

Thanks!

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

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