Hacker News new | past | comments | ask | show | jobs | submit login

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



Note that Scheme made this choice in order to make it simpler for compilers to produce efficient code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: