Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Call For Syntax

db666 edited this page · 5 revisions

A list of proposed syntaxes, see this discussion thread for more information.

Anyone can edit this wiki page and add a new syntax proposal. A proposal can a new idea, based on another, or mix-up of two or more.

Also, every syntax proposal must include the following programs written in the proposed syntax:

  • Hello World program
  • 99 Bottles of Beer program
  • Multithread Counter (simple loop that print from 1 to 10 in each thread) program

Please do not use the Wiki for questions/comments. Use our Google Groups mailing list instead.

1. Python-like Syntax

1.1. Hello World

"Hello World":
    -> print

1.2. 99 Bottles of Beer

range(99, 0, -1):
    |  str
    -> _ + " bottle(s) of beer on the wall,"
    -> print
    -> _.split(" on")[0] + '.'
    -> print
    -> print("Take one down, pass it around,")

1.3. Multithread 1 to 10 Counter

range(1, 10):
    -> print("In Thread A"):
        -> print
    -> print("In Thread B"):
        -> print

2. C-like Syntax

2.1. Hello World

"Hello, world" -> [
    print
]

2.2. 99 Bottles of Beer

range(99, 0, -1) | [
    str -> 
    _ + " bottle(s) of beer on the wall," ->
    print ->
    _.split(" on")[0] + '.' ->
    print ->
    print("Take one down, pass it around,")
]

2.3. Multithread Counter (1 to 10)

range(1, 10) -> [
    [
        print("In Thread A") -> 
        print
    ] 
    ,
    [
        print("In Thread B") -> 
        print
    ]
]

3. Musical notation / Modern staff notation -like Syntax

3.1. Hello World

"Hello World":
[ # -> 
    print
]

3.2. 99 Bottles of Beer

range(99, 0, -1): 
    [ # ->
        str
        _ + " bottle(s) of beer on the wall,"
        print
        _.split(" on")[0] + '.'
        print
        print("Take one down, pass it around,")
    ]

3.3. Multithread Counter (1 to 10)

range(1, 10)
[ # ->
   [ # ->
      print("In Thread A")
      print
   ]
   ,
   [ # ->
      print("In Thread B")
      print
   ]
]

3.4. Extras

3.4.1 Repeat signs

3.4.1.1 Repeat const times

Repeats "print -> print" block 2 times

"Hello World" -> [: print -> print :] * 2

3.4.1.2 Repeat N times

Repeats "print -> print" block N times

"Hello World" -> [: print -> print :] * N

3.4.1.3 Repeat expression result times

Repeats "print -> print" block fcn_A() result times

"Hello World" -> [: print -> print :] * fcn_A()

3.4.2. Simile marks

3.4.2. Repeat the Previous Block

"Hello World" | print | % 

Equals to:

"Hello World" -> print -> print

3.4.3. Repeat the Two Previous Blocks

"Hello World" | print | print | %%

Equals to:

"Hello World" -> print -> print -> print -> print

3.4.4. Volta brackets

Prints "Hello World" 10 times, and, on the 2nd iteration it will also print "Second iteration"

"Hello World" -> [: print -> 2: print("2nd Iteration") :] * 10

4. F#-like Syntax

4.1. Hello World

"Hello World": -> print

4.2. 99 Bottles of Beer

range(99, 0, -1): |  str
                  -> _ + " bottle(s) of beer on the wall,"
                  -> print
                  -> _.split(" on")[0] + '.'
                  -> print
                  -> print("Take one down, pass it around,")

4.3. Multithread Counter (1 to 10)

range(1, 10): -> print("In Thread A"): -> print
              -> print("In Thread B"): -> print

5. "Thread comprehension"

5.1. Hello World

{print for ["Hello World"]}

5.2. 99 Bottles of Beer

{str
    -> _ + " bottle(s) of beer on the wall,"
    -> print
    -> _.split(" on")[0] + '.'
    -> print
    -> print("Take one down, pass it around,")
for range(99, 0, -1)}

Or, perhaps nicer:

{reduce(->, [
    str,
    _ + " bottle(s) of beer on the wall,",
    print,
    _.split(" on")[0] + '.',
    print,
    print("Take one down, pass it around,")
]) for range(99, 0, -1)}

5.3. Multithread Counter (1 to 10)

{[print("In Thread A) -> print,
  print("In Thread B") -> print] for range(1, 10)}

5.4. Notes

The general form would be {functions for values}. "functions" can be an expression which evaluates to a single function, in which case we map it over "values", or it can be a list (or, more generally, an iterable) of functions, in which case we do a parallel map. We can run f(x) asynchronously via {[f] for [x]}.

We follow Python's generator syntax "(a for b in c)" and list comprehension "[a for b in c]" (and set and dictionary comprehension in Python3). The "b in" is debatable; since we're doing a map, we're binding each value to our functions' first argument anyway, so why bother with the intermediate bind? On the other hand, maybe we want our function/function list to use the value in its evaluation. For example:

{[f] * (n+1) for n in range(4)}

This would run, in parallel, f(0), f(1), f(1), f(2), f(2), f(2), f(3), f(3), f(3), f(3). The argument over using "b in" is essentially the argument over whether this kind of evaluation is useful.

Something went wrong with that request. Please try again.