Arc Forumnew | comments | leaders | submitlogin
2 points by eds 6083 days ago | link | parent

Maybe you could set a hook on 'safeset that would trigger Arco whenever you changed a variable holding a function definition? Then you could reanalyze the function and produce a new optimized definition. In between you would be able to assume that the function hadn't changed à la Stalin. Or am I missing something that would prevent this from working properly?

If that isn't possible, I guess CL style is the next best. But I don't like how verbose CL type declarations are. I don't really want to code C in Arc.

Of course, a native code compiler in Arc would provide a huge boost in speed, but I think that is a long term goal.

Another random idea: if you wrote a version of Arco for CL-Arc you could take advantage of CL's type declarations. This could result in even greater boosts in speed. Just a thought.



1 point by almkglor 6083 days ago | link

When someone evil doesn't use safeset:

  (= +
    (fn args
      "I am EVIL!!"))
Hmm. Maybe put the hook in 'set instead?

Also, not sure, but how about when it's given an already-compiled-but-not-optimized function?

  (= foo (fn args "I am EVIL!!"))
  (= + foo)
Not sure about how arco is structured anyway ^^;

-----

1 point by eds 6083 days ago | link

I chose 'safeset only because that is what is used internally in 'def. But I see that you would need to watch 'set to be completely sure no redefinitions had occurred.

So if you put a hook in 'set, and watched for local variables (really function parameters, because 'let is implemented in terms of 'fn) overriding function names, that would probably be enough to know a function hadn't changed. And that would hopefully remove the need for CL style type declarations.

Maybe this should be added as an option to the poll?

-----

1 point by almkglor 6083 days ago | link

In fact, yes you really have to watch for locals either way - it's entirely possible to do this (I have, since I wanted to package Arki in a module-like object):

  (let (localfn localfn2
        help* sig source-file*) nil
    ; protect 'def from bashing Anarki help docstrings
    (= help* (table) sig (table) source-file* (table))
    (def localfn ()
      (prn "localfn!"))
    (def localfn2 ()
      (prn "!2nflacol"))
    (def globalfn ()
      (localfn) (localfn2)
      (prn "haha only global!")))

-----

1 point by eds 6083 days ago | link

Is that multi-variable form of 'let an Anarki thing? I don't remember seeing it before. It does look really cool though.

-----

1 point by almkglor 6082 days ago | link

It's part of the Arc core destructuring thing. For example:

  (let (x y z) (list 1)
    (prn x)
    (prn y)
    (prn z))
...will assign 1 to x, and nils to y and z. Basically it seems that destructuring is done in the following manner:

  (let gs4932 (list 1)
    (let x (car gs4932)
      (let y (car:cdr gs4932)
        (let z (car:cdr:cdr gs4932)
          (body ...)))))
(NOTE: not exact code, but basically this is how ac.scm handles destructuring)

-----