Alex Harsanyi wrote on 2/2/19 1:28 AM:
One improvement that I can think of is to add a performance
description to each function that operates on the basic data
structures (lists, vectors, hash-tables)
Before complete coverage, perhaps two first steps:
* Try to think of the minority of procedures (and use cases?) that might
be *surprisingly* expensive (either to anyone, or to users coming from
some other languages), and focus first on the documentation for those.
`append` is likely one, for people who don't yet understand lists well,
or who aren't aware of more efficient patterns/idioms. `list?` (or
`listp` elsewhere in our Lisp family) is one that bit me and others,
somehow not realizing it's potentially O(n) [1] (though apparently
Racket now optimizes some cases of that, for immutable pairs[2]). Those
are the first two that come to mind, but I assume someone would find
others by looking methodically through the documentation.
* Exposing lists based on pairs means programmers must understand the
list model (list is not an opaque abstract data type), and it'll help
them if they know some patterns for working with the model. Teach every
Racketeer some old-school list processing.[3][4] Maybe teach this
before `for`-something (before they think "Aha! Now I know the Racket
way, which is pretty much the same as in many other languages I know!",
and then they consider the finer points of lists and recursion to be
esoteric stuff that maybe they don't learn well, soon).
[1] The current documentation even hides the recursive mathematical
definition of a list in innocent-looking text, trying to trick users
into the classic mistake! :)
[2] It looks like Racket C code now sometimes stores a bit with
immutable pairs to cache list-ness, though the documentation's exact
characterization of the performance of this isn't obvious from the C
function alone. Also, I don't see where in that function the
PAIR_IS_NON_LIST flag is checked, for optimizing those cases. (BTW,
[3] https://m.xkcd.com/297/
[4] One day, I got all excited by Roombas, and accidentally typed an
alist primer.
https://www.neilvandyke.org/racket/roomba/#%28part._.Association._.List._.Primer%29
--
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.