Arc Forumnew | comments | leaders | submitlogin
2 points by evanrmurphy 5050 days ago | link | parent

> Another advantage of buckets is that they require no dots to write, as you've shown.

Exactly, I like this one a lot. Fewer conses / greater efficiency whilst being more palatable to read and write.



1 point by rocketnia 5050 days ago | link

Well, there are definitely fewer conses in ((a b) 1 2) than in ((a 1) (b 2)), but ((a . 1) (b . 2)) has them both beat. (Maybe I'm missing something.)

As for being palatable to read and write, I actually disagree, even with the decrease in punctuation.

When writing a literal bucket, to add or remove a key-value pair, I'd have to edit in two places. Besides that, I'd encounter horizontal layout annoyances: I'd have to word-wrap the keys and the values in the same way in order to see the bindings clearly. And every time I added or removed a binding, I'd have to rewrap.

Reading is a bit more of a wash. When reading a bucket in debug output, it's harder to look up specific bindings but a lot easier to see what keys exist. I think I do those two things in about equal proportions (when I'm working on Penknife, at least).

-----

1 point by evanrmurphy 5050 days ago | link

> Well, there are definitely fewer conses in ((a b) 1 2) than in ((a 1) (b 2)), but ((a . 1) (b . 2)) has them both beat. (Maybe I'm missing something.)

I resorted to cons counting to confirm it for my own simple mind and... you're correct! ^_^

  ; bucket (5 conses)
  ((a . (b . nil))  . (1 . (2 . nil)) )

  ; "frugal" alist (4 conses)
  ((a . b) . ((b . 2) . nil))
Note, however, that it's a constant difference of 1 cons. The difference doesn't grow with the size of the data, so it's rather insignificant.

Sorry I don't have time to respond to the rest of your comment right now.

-----