Arc Forumnew | comments | leaders | submitlogin
2 points by pg 5649 days ago | link | parent

The vague eventual plan is to replace alref with some form of function-call like lookup, as with tables. I'm still not sure how, but in the meantime I wanted a function that at least had the same argument order.


1 point by Adlai 5649 days ago | link

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 :)

-----