Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 6107 days ago | link | parent

Regarding 'if: We could insert a code walker which transforms 4 or more arg forms of 'if to conventional 'if:

  (if
    (hmm)
      (niaw)
    (grr)
      (woof))

  =>

  (if (hmm)
      (niaw)
      (if (grr)
          (woof)))
Also, we can use Anarki-specific 'ssexpand and 'ssyntax to transform symbol syntax, probably by inserting another step in the compile process (which is why I suggested structuring arc2c in: http://arclanguage.com/item?id=5598 ); However ssyntax which transforms to ((compose a b) ...) has to be transformed to (a (b ...)) because of macros, such as p-m:def.


1 point by sacado 6107 days ago | link

Excellent idea :)

-----

4 points by almkglor 6106 days ago | link

wrote a code walker, on the git.

Basically to use:

  (def your-function (argument-data)
    (code-walk a-variable argument-data
      (if
        (something-you-need-to-process a-variable)
          `(stuff ,(car a-variable) ,(cdr a-variable))
        ; else return the variable as-is
          a-variable)))
code-walk will automatically skip ' as well as the constant parts of `(), but will reprocess when it sees a comma or comma-at `( ,...)

See to-3-if sample

Also I removed the err in 'source - since part of codegen now emits the code in list form rather than AST, source just passes it if it's not an AST

Edit: also added ssyntax support

-----