Hoping I can I get a little help in defining a new intra symbol for arc. I would like to use the '$' to expand a symbol-statement? that will coerce a string into a symbol. I generally like to store table keys as symbols and often find I am not able to use intrasymbol expansion on a 'defop' where the arg requests are always strings. I find I do this often enough it makes sense to try changing the syntax. for example: before: (defop myapp req ()
(let user (get user)
(if (admin user)
(pr (usertable (sym user)))
)))
hopeful after: (defop myapp req ()
(let user (get user)
(if (admin user)
(pr usertable$user))
))
Notice I don't just to a 'let user (sym (get user))' since it the same arg often also needs to be used as a string, such as in (admin user). As you can imagine if you had many args to coerce the code would be much cleaner using the after scenario. Even more so when using nested tables where the arg in question is higher up. i.e. 'usertable$user.record!time'From what I can see, having no understanding of scheme syntax, I need to add: (insym? #\$ sym) to the second 'or' statement of: (define (expand-ssyntax sym)
((cond ((or (insym? #\: sym) (insym? #\~ sym)) expand-compose)
((or (insym? #\. sym) (insym? #\! sym)) expand-sexpr)
((insym? #\& sym) expand-and)
; ((insym? #\_ sym) expand-curry)
(#t (error "Unknown ssyntax" sym)))
sym))
Then I need to modify 'expand-sexpr' to somehow checkfor the '$' and convert from string to symbol - this is where I am lost, and hoping someone can help...this is a little scary modifying this lower level stuff in a syntax I don't understand. (define (expand-sexpr sym)
(build-sexpr (reverse (tokens (lambda (c) (or (eqv? c #\.) (eqv? c #\!)))
(symbol->chars sym)
'()
'()
#t))
sym))
Thanks if anyone can help.
T. |