I bump into struct subtleties all the time. For example, my attempts to
#:auto always degenerate into custom constructor procedures; This usually
involves #:constructor-name and #:omit-define-syntaxes, which might not be
a big deal if I had a solid understanding of what these flags actually do.
So far, all of my struct troubles have been rooted in a lack of
understanding.

It is unfortunate that such a fundamental aspect can be so un-intuitive.
Reading the source hasn't helped much because structs are a low-level
construct used *everywhere* for *everything*. This would be a code smell if
I didn't trust that our Racket ancestors knew what they were doing, so the
notion of "fixing" structs (or even struct-copy) seems misguided.

Structs seem to occupy an awkward region of the design space between
totally opaque (e.g. objects) and totally transparent (e.g. algebraic data
types). On one hand, structs are too "open." The "good for everything"
design makes them not particularly great at anything. Prefabs are a
pathological case -- every attempt I've made at using them devolves into
lists or non-prefabs in order to re-gain control over basic things like
construction or printing. On the other hand, structs aren't "open" enough.
Racket's pattern-based binding forms allow me to de-structure, but it's not
yet clear to me how much extra plumbing would be needed for something like
a totality check, or even where that plumbing would go.

I can appreciate the architectural decision that structs represent for the
core -- flexibility often comes with a cost to conciseness and convenience.
For something like a standard library, where transparency prevents friction
between language users and implementers, I think higher-level abstractions
are more appropriate. My preference is for ADTs: they support a
pattern-based functional style, are amenable to static analysis and
automatic tooling, and I already have an intuition for how they should
behave.

/rant

Eric


On Tue, Mar 20, 2018 at 9:36 PM Kevin Forchione <lyss...@gmail.com> wrote:

>
> Just read your GitHub link and see the problem goes beyond my simple
> #:auto issue. Thanks for that link. I’m pretty green to all the thorny
> issues when it comes to dressing primitive datatypes up in fancy bindings
> and hope the magicians of indirection can somehow pull a rabbit out of the
> hat on this one someday. :)
>
> Kevin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to