Arc Forumnew | comments | leaders | submitlogin
4 points by Pauan 4500 days ago | link | parent

If adjacency means function application, how does the evaluator know that (+ 1) and (1 +) are the same? What happens if both are functions, like with (+ +) or (map car)?

An interesting idea: constants like 1 are functions that accept a function and call that function with themself, which means (1 +) is treated as similar to ((fn (x) (x 1)) +) in Arc.

That doesn't solve the (map car) case, though. I think you could solve that by saying that function application is always left-to-right, and then use the above "constants-as-functions" idea to enable infix (1 + 2) expressions.

And then symbols could be vaus that evaluate themself in their environment, so that (a +) is like (($vau (x) env ((eval x env) (eval ($quote a) env))) +) in Kernel.

Alternatively, if you make environments static like they are in Nulan... you could have (a +) evaluate to ((fn (x) (x <the value of a>)) +)

---

Originally this idea didn't seem very interesting to me, but combined with the above "everything is a vau/fn, even constants" idea... I might actually play around with this for a while.



2 points by akkartik 4500 days ago | link

Yeah, I somehow hadn't considered higher-order functions at all :/

almkglor had an interesting suggestion: view this idea in terms of pattern matching. When you see a function you see if it makes sense to apply it in the given context.

So in (map f list), the f would likely not apply to map, so it would be treated as an object.

But this is still half-baked..

-----

2 points by Pauan 4499 days ago | link

That's an interesting idea too, and it looks like you're moving into a more fuzzy analog kind of system, not entirely unlike how JavaScript takes both operands into account with `+` so that 1 + "foo" returns "1foo"

-----