Here's a system [1] I've been developing to auto-quote unbound symbols and more densely overload functional position. It's a follow-up to the recent subthread on this topic at http://arclanguage.org/item?id=13804: --- 1. Numbers and strings evaluate to themselves 2. Symbols evaluate to their bound value 3. Symbols are initially bound to their own quoted symbol [2] 4. A number or quoted symbol [3] in functional position returns a list of itself consed onto the list of arguments > (1 2 3)
(1 2 3)
> (a b c)
(a b c)
5. Lists and strings are sequences6a. A sequence in functional position returns its nth element if there is only 1 argument and that argument is an integer... > (= xs (a b c))
(a b c)
> xs.0
a
> xs.1
b
> (= s "foo")
"foo"
> s.0
#\f
6b. ...otherwise it returns a list > (xs d e)
((a b c) d e)
> (s "bar")
("foo" "bar")
> (xs 0.)
((a b c) 0.0)
7. Hash tables and alists are maps8a. A map in functional position performs the lookup if there is only 1 argument and that argument is a quoted symbol [3, 4] ... > (= h (obj k1 v1))
#hash((k1 . v1))
> h.k1
v1
> (= a (x.1 y.2))
((x 1) (y 2))
> a.y
2
8b. ...otherwise it returns a list > (h foo bar)
(#hash((k1 . v1)) foo bar)
> (a z 3)
(((x 1) (y 2)) z 3)
---[1] System of rules, that is. No code yet. [2] Another way to think about this is that unbound symbols are auto-quoted. [3] This includes symbols that have no explicit bindings yet, by virtue of #3. [4] For alists, which are not a concrete type but simply lists composed of a certain structure, this in an exception to #6b. |