Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4464 days ago | link | parent

In fact, following that line of thought, here's an implementation of apply:

  (def apply (f args env)
    (eval (cons f (map quote args)) env))
You can make the env argument optional if you like, with whatever semantics you want (the current environment, a new environment, etc.)

---

Side note: why doesn't Arc 3.1 use this definition? Because eval is incredibly slow in Racket, but applying a function is fast. But I'm assuming in a language that emphasizes fexprs (like Kernel, or wart) that eval should be plenty fast.



2 points by rocketnia 4464 days ago | link

  >
  > (map quote args)
  >
I don't think that does what you think it does. Suppose 'map is implemented independently of 'apply, and that it takes this form:

  (def map (f seq)
    ...
    ... (f elem) ...
    ...)
Then (map quote '(1 2 3)) should result in the list (elem elem elem). That's what my intuition says anyway, not that it's really useful behavior. :-p

Mapping [list quote _], as I was talking about when I called it ($lambda (x) (list $quote x)), will hopefully work regardless of what mapping quote does.

-----

1 point by Pauan 4464 days ago | link

Right, I was assuming quote automagically read my mind and did what you're talking about. :P

-----