9 ms·
You're critique is valid. `length` `vector-length` and `string-length` are from the very monomorphic old Scheme libraries. The Racket module system does provi
by samdphillips 5y ago
You're critique is valid. `length` `vector-length` and `string-length` are from the very monomorphic old Scheme libraries.
The Racket module system does provide ways to use the names you want without having to change the core language. The `collections` package (https://pkgs.racket-lang.org/package/collections https://pkgs.racket-lang.org/package/collections) also smooths over some of these issues.
- memling 5y agoThanks for the tip! I'll look over the collections package for sure. It looks like some of the things of interest to me are there already. I knew there were historical reasons behind some of these things (just like the old complaints about car and cdr not being called first and rest). Sometimes it feels like this hewing to history comes with some baggage that makes adoption a little more challenging. I find myself writing the following in some of my projects, for example: (define-syntax (hash-ref* stx) (syntax-case stx () [(_ hsh k1) #'(hash-ref hsh k1)] [(_ hsh k1 k2 ...) #'(hash-ref (hash-ref* hsh k1) k2 ...)])) So that I can do something like: > (define hsh '#hash((a . #hash((b . c))))) > (hash-ref* hsh 'a 'b) 'c I feel a little silly each time because it seems like the sort of thing that should just "be there," in the way you can do something like hsh['a']['b'] in Python. Of course there are ways to make it a bit more like Clojure--I think Greg Hendershott created a Clojure-like layer called rackjure--so that you can access using the variable name, etc. It would be nice to have something standardized to make the ergonomics nicer.
- soegaard 5y agoNote that Scheme made this choice in order to make it simpler for compilers to produce efficient code.