Arc Forumnew | comments | leaders | submitlogin
1 point by eds 6070 days ago | link | parent

This is fine if the compiler is static like Stalin, but if you omit parts of arc.arc that aren't used, you run the risk of not being able to deal with code known only at run time (e.g. (loop:print:eval:read)).


2 points by almkglor 6070 days ago | link

And if 'eval is an interpreter?

Come now, if you want real support for eval, you'll also need to include the compiler:

  (eval `(fn (x) ,@my-variable)) ;how will it build the function?
The alternative is to punt: if there's ever an 'eval, then add arc.arc completely, make 'eval an interpreter which somehow uses 'symeval to lookup globals (and execute global functions as compiled functions), and when it encounters a function, will build the function as an interpreted function (and obviously allow interpreted code to call compiled functions and vice versa).

Basically you create a virtual function:

  (def eval (e (o env))
    (if
      (caris e 'fn)
        (add-attachment
          'environment env
          (annotate 'virtual-function
            (cdr e)))
      ...))
  (defcall virtual-function (f . args)
    (with (env (get-attachment 'environment)
           (arglist . body) args)
      ; has to be nondestructive
      (zap add-args-to-environment env arglist args)
      (each e body
        (eval e env))))

-----