Arc Forumnew | comments | leaders | submitlogin
4 points by sacado 6106 days ago | link | parent

I use them to build trees, two-sided lists, when I need to encapsulate a value (e.g. to dinsinguish between nil-the-boolean and nil-the-empty-list). For all those things, opaque lists or hashes could be used, too.

But the main use of dotted lists is for recursively-built and recursively-explored lists :

  (def foo (a b)
    (if a 
      (cons (car b) (foo (cdr b))
      nil)
and relatives appear in so much of my code... I don't think I would like to see dotted pairs go away. And if you don't like them, you can always use (list ...), (l 0), (l 1), (last l), rev, ... and not care about actual implementation.


3 points by nzc 6106 days ago | link

I know, I know, I just asked this question b/c I saw someone else's post about dotted pair containing lists (old timers would say "s-expressions") not working properly in some cases in arc, and I having noodled around implementing lisp in ruby recently, and having stubbed my toe on implementing cons after having chosen arrays as the underlying implementation of lists, I thought I'd throw this out there and see what people had to say.

-----