Arc Forumnew | comments | leaders | submitlogin
1 point by eds 5866 days ago | link | parent

> Arc does not distinguish between a key mapping to nil in a table and the same key being absent entirely.

  (def get (tab key (o default))
    ($ (hash-table-get ',tab ',key ',default)))
  
  (= tab (table))
  (= absent-entirely (uniq))
  (get tab 'key absent-entirely)
  
  (defcall table (tab key (o default))
    (get tab key default))
  
  (tab 'key absent-entirely)
;-)


1 point by rntz 5866 days ago | link

It's true, I can override this. But this would change the language for any consumer of my library, as well; and however bad it may be to have absent keys map to nil, it's even worse to face the possibility of breaking the language for someone else. Sure, it's an optional parameter here... but what happens if someone else has their own idea about adding an extra parameter and what it should do? Your idea is probably the right design (though 'len and 'keys and the setter for tables would have to be changed as well to fit it), but it's not the way arc currently works. Hopefully pg will pick it up and run with it, though.

-----