| Hi- I was just playing around inside the compiler again to scratch a syntax itch. What should an intrasymbol dot do if it's the last character of a function? Currently, it throws an ugly error. I would argue it should just call the function without parameters: BEFORE arc> (date)
"2008-07-18"
AFTER arc> date.
"2008-07-18"
It's a very simple change that doesn't interfere with anything else. From a cognitive standpoint, it makes sense that a function ending in a period is being funcalled, since periods at the end of a single word usually denote a verbal command in human language. Since functions without parameters are very common, this syntax is also widely useful.To add this feature, make the following change to "build-sexpr" in ac.scm (tested in the pg version of arc only) (define (build-sexpr toks)
(cond ((null? toks)
'())
((eqv? (car toks) #\.)
(if (null? (cadr toks))
'()
(cons (chars->value (cadr toks))
(build-sexpr (cddr toks)))))
((eqv? (car toks) #\!)
(cons (list 'quote (chars->value (cadr toks)))
(build-sexpr (cddr toks))))
(#t
(cons (chars->value (car toks))
(build-sexpr (cdr toks))))))
|