Arc Forumnew | comments | leaders | submitlogin
1 point by Adlai 5649 days ago | link | parent

It be very neat for alists to be usable like tables and strings, as "functions". That would almost be like a duck-typed "database" interface. Obviously some functionalities are specific to each (shadowing older pairs in an alist, having five bazillion keys in a hash table), but it would make sketching out an application much easier -- you could change only one or two spots in your code to switch between a table or alist, and the rest of your code would still work fine. Maybe this could be another use for 'annotate -- to differentiate between "a list" and "an alist"?

In the meantime, it should be easy to write a "polymorphic" lookup function:

  (def lookup (db key)       ; obviously just a sketchy
    (if (atom db) (db key)   ; definition -- but Arc is LFSP
        (alref db key)))     ; so there's no warranty :)