Arc Forumnew | comments | leaders | submitlogin
1 point by almkglor 5876 days ago | link | parent

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 5875 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 5874 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)

-----