

A Lisp syntax with less parentheses - jiyinyiyong
https://medium.com/@jiyinyiyong/a-lisp-syntax-with-less-parentheses-915384011008

======
jiyinyiyong
Author here. I created this little syntax for writing with less brackets one
day. Less braces, less parentheses, and maybe less commas, less double quotes
too. And Cirru is really interesting to myself.

And the idea behind CirruSepal is to write ASTs in Cirru Synax, such as ES6
AST(CirruScript), Racket AST, Julia AST. Actually I failed in generating LLVM
IR from Cirru, so I tried Julia AST instead. It could be more fun if I had
those skills.

Cirru Syntax is nice for exploring.

~~~
MarkSmith123
Very Good :P

------
zck
Perhaps it's me, but I think parentheses are one of the strongest selling
points of Lisps. The less I have to worry about special characters, special
evaluation, and indentation rules the better.

Also, I'm not even sure what some of the code in the demos even do:

    
    
        set a
          + 1 2
          , 3
    

supposedly translates into the Racket code:

    
    
        (set a (+ 1 2) (, 3))
        ;; which is also
        (set a (+ 1 2) 3)
    

I think you don't want set here ("set" is many things, but not setting
variables: [http://docs.racket-
lang.org/search/index.html?q=set);](http://docs.racket-
lang.org/search/index.html?q=set\);) I think you want "define"
([http://docs.racket-
lang.org/reference/define.html?q=set#%28f...](http://docs.racket-
lang.org/reference/define.html?q=set#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29)),
which only takes two arguments.

~~~
jiyinyiyong
Indentation-based syntax is always an alternative. Not everyone hates
parentheses.

Comma syntax is not always preferred in a program, but it's quite useful in
some cases. Suppose `(+ 1 2)` here is something deeply nested, then you can
see its power:

    
    
        set a
          + 
            + 1
              + 2
                + 3
                  + 4 5
            , 3
    

Yes, `define` is better. It's because ES5 doesn't use `Set` and I was using it
as an alias of `set!`.

~~~
zck
But set! doesn't take three arguments either. I mean, it's fine if you're just
trying to show syntax, but if you say some code is Racket code, it should be
able to be pasted into a Racket repl. If you're using real code, you should
leverage our current understanding: "oh, we're setting a variable here, so I
expect it to work this way", and not confuse us: "why are we dividing
strings?" Otherwise, you should just use the function `foo`, and call it with
arguments `bar`, `(baz bif)`, and `, 3`.

I think the comma operator is horribly explained, and I don't currently
understand it. It "turns the expression it belongs into several words(or
expressions)." Apparently (, 3) is the same as 3. Is it the same as identity,
because each new line is a function call? But the identity function doesn't
return several values (what are "words" in this context?), but only one.

Also also, the section beginning "However, Cirru does contain tricky parts in
representing strings in Cirru", beyond being awkwardly worded, is confusing
too. The only explanation is it "behaves like a Bash", and says two
expressions "are totally different". What behaving like Bash does is never
explained, and because you show inputs but no outputs, I can't tell how it
differs.

Your example of, I think, escaping double quotes in a string is compared to a
print of these five variables. When you say the two prints are "totally
different", is it because one print expression is called with three strings,
and the other with five variables? Do you expect that to be a point of
confusion for the reader? It seems as though the two print statements are
totally unrelated, but by joining them with "these are totally different", it
makes the reader try to see where the confusion would be. And I'm confused why
anyone who's familiar with programming enough to read this introduction would
think they're the same.

You say that "Quotes are required when a token contains whitespace", but what
token contains whitespace? You seem to rely on unset variables (the second
`print` has variables `data`, `a`, `b`, `c`, and `d`, which are defined
nowhere).

~~~
jiyinyiyong
You are right. I should give better examples. For comma syntax I updated to
this:

    
    
        + a
          + 1 2
          , 3 4 5
        ;; which is also
        (+ a (+ 1 2) (, 3 4 5))
        ;; and
        (+ a (+ 1 2) 3 4 5)

------
teapot7
_Fewer_ brackets, not less brackets.

~~~
jiyinyiyong
Thx, just updated.

