Arc Forumnew | comments | leaders | submitlogin
Tables with lists as keys behave inconsistent
7 points by rincewind 5845 days ago | 2 comments
This one works for me

  ((obj (1 2 3) 4) '(1 2 3))
These are evaluated to nil

  ((obj (1 2 3) 4) (list 1 2 3))
  ((obj (1 2 3) 4) `(1 2 3))
  ((obj (1 2 3) 4) `(,1 ,2 ,3))
Why? Are lists even allowed as hash table keys? In my opinion they should be.


1 point by sacado 5845 days ago | link

  (= h (table))
  (= (h '(1 2 3)) 0)
  (= (h (list 1 2 3)) 1)
  h
  ==> #hash(((1 2 3) . 1) ((1 2 3 . nil) . 0))
These are 2 different keys. (h '(1 2 3)) returns 0 and (h (list 1 2 3)) returns 1. To me, it looks like a bug...

-----

4 points by stefano 5845 days ago | link

Const lists (created with quote) are improper scheme list, i.e. they end with nil instead of the emtpy list (in scheme nil != '()), whereas lists created with (list ...) are proper lists (ending with '()). This is certainly a bug.

-----