So I've been looking for "dot notation" in Racket for a long time and I have considered struct++ in the past. The issue is that it doesn't do what Sketching does, and as far as I can tell, Sketching is the first to what I want that I've found in the racket ecosystem.
I think to clarify, its not actually dot notation that I'm looking for in Racket per se. What I actually care about is the dynamic dispatch part (at least in a non statically typed language).
Or to be more specific, the thing that I find annoying is that while Racket is dynamically typed it doesn't have dynamic dispatch or generics, so you're constantly writing types at the call site.
So like in the examples I showed above
(struct horse (breed height color name))
(define bella (horse "Danish Warmblood" 171 "brown" "bella"))
(horse-name bella)
"bella"
the issue for me is having to write horse every time I want to access bella's name. For example I would settle for a syntax like
(.name bella)
"bella"
which I think is how clojure does hash table access?
This issue extends to Racket's other data structures as well. Only lists let you write "non-prefixed" functions. So you can call length
on a list, but you have to call vector-length
on a vector, same with vector-map
and vector-set!
, etc. What using the bracket notation in Super #lang and Sketching gives is dynamic (or generic?) access to the data structures, and Sketching also let you mutate structs without prefixing the setter as well.
This all makes a big difference for me because if you're trying to use these data structures in line with the code operating on them, you're either writing long prefixes every time you use them, or you destructure them ahead of time every time and give them a shorter name. I find both options boiler-platey, hard to read, and annoying to write. It wasn't until I tried Sketching that I realized how much I disliked this. I believe other dynamically typed languages like javascript and python all do dynamic dispatch for the dot notation and usually have special syntax for data structure access. The performance is probably worse that way, but I would at least like the option.
I welcome dot notation for objects as well, though I use them less and I don't have to keep writing the type so its not as bad. But I just really want it for structs too. We have it in Sketching and I want the rest of the Racket eco system to get it as well. If I have to write (require (only-in sketching struct #%top :=))
then fine, but I think it should be in Super. (I guess I can also fork it and add it myself but yea)
/essay rant lol
edit: Actually on further thought, the point of racket objects and classes is to do the dynamic dispatch, right? So maybe I should leave the structs alone and I should just use the objects for that sort of thing, especially with supers dot notation? Perhaps what I'm ultimately after is the syntax or I'm just used to typed languages where one can statically dispatch stuff and I miss that.