Arc Forumnew | comments | leaders | submitlogin
1 point by evanrmurphy 5012 days ago | link | parent

A simple front-end to this compiler I've been working on. The main (and only?) deviation from arc syntax has to do with object/list refs versus function calls. Because of the difficulty I had disambiguating the (x y) form, for the moment each case gets its own form as follows.

Function calls:

  (fncall x y) -> x(y);           ; verbose
  (x y)                           ; succinct
   x.y
  (fncall x 'y) -> x(y);          ; verbose quoted
  (x 'y)                          ; succinct quoted
   x!y
Object refs:

  (objref x y) -> x(y);             ; verbose
                                    ; no succinct form for no quotes
  (objref x 'y) -> x('y');          ; verbose quoted
  (x `y)                            ; succint quoted
   x.`y
List refs:

  (listref x y)  -> car(nthcdr(y,x));    ; verbose
  (listref x 'y) -> car(nthcdr('y',x));  ; verbose quoted
                                         ; no succinct forms for listref
Suggestions on how to improve this situation are welcome. I greatly dislike the lack of short forms for listref and non-quoted objref. The only perk is that since Javascript arrays are objects and numbers don't mind being quoted, you get array access for free:

  (objref (array 'a 'b) 0)  -> ['a','b'][0];
  ((array 'a 'b) `0)                                ; same as above

  (let a (array 'a 'b)      -> (function(a){
    a.`0)                        return a[0];
                               })['call'](this,['a','b']);

  (.`0 (array 'a 'b))       -> (function(_){        ; using get ssyntax
                                 return _[0];
                               })(['a','b']);