PythonJS is being extended with optional static typing and new syntax. The translator pre-processes input source code and transforms it into an intermediate form that can be parsed by Python's ast module. This simplifies adding new syntax to PythonJS, see this commit that implements Exception Expressions.
a = d[ 'somekey' ] except KeyError: 'mydefault'
inline anonymous functions
I am now researching new syntax that can be added to PythonJS. After looking at RapydScript, I see that inline anonymous functions are a must have, and recently implemented them in PythonJS. Inline functions can be used in function calls as a named keyword argument, or in a dict literal. This solves the problem that Lambda functions can only be a single statement, which is often not that useful.
a.func( callback1=def (x,y,z): x += y return x - z, callback2= def (x, y): return x * y ) b = { 'cb1' : def (x): return x, 'cb2' : def (y): return y }
switch
switch a==b: case True: pass case False: pass default: pass
Go channels and select
def send_data( A:chan int, B:chan int, X:int, Y:int): while True: print('sending data..') A <- X B <- Y def select_loop(A:chan int, B:chan int, W:chan int) -> int: print('starting select loop') y = 0 while True: print('select loop:',y) select: case x = <- A: y += x W <- y case x = <- B: y += x W <- y print('end select loop', y) return y def main(): a = go.channel(int) b = go.channel(int) w = go.channel(int) go( select_loop(a,b, w) ) go( send_data(a,b, 5, 10) ) z = 0 while z < 100: z = <- w print('main loop', z) print('end test')