I'm just fooling around as you can probably see. I don't fully understand how macros really work and I'm pretty sure I am doing it wrong since I needed to use 'eval' inside a macro. Redefined the 'alref' function as such: (mac aget (al (o key nil))
`(if ,key
(cadr (assoc ,key ,al))
(withs (xpn (ssexpand ',al)
al (eval (car xpn))
key (eval (cadr xpn)))
(cadr (assoc key al)))))
Usage: arc> (= x '((first "First Name")(last "Last Name")))
((first "First Name") (last "Last Name"))
arc> (aget x 'first)
"First Name"
arc> (aget x!first)
"First Name"
And I really shouldn't be doing the following since I really don't know the consequences, but oh well..... it's only for fun.Hacked more of ac.scm: http://www.blackstag.com/docs/hacked.ac.scm.arc So now I can: arc> ^x!first
"First Name"
(and I've run out of special characters lol, but I figure '^' looks like a mini 'A' for association list anyway)note: I haven't figured this one out yet... arc> (= ^x!first "New Name")
Error: "reference to undefined identifier: _if"
but I'm tapped out for the night....T :) |