https://github.com/rusthon/Rusthon/blob/master/regtests/rust/simple_subclass.py https://github.com/rusthon/Rusthon/blob/master/regtests/rust/multiple_inheritance.py
. works with backends: go, rust, c++
a = []int(1,2,3)
b = []int(x for x in range(3))
push_something( a )
the append
method is translated to work with each backend.
def push_something( arr:[]int ):
arr.append( 4 )
https://github.com/rusthon/Rusthon/blob/master/regtests/rust/list_comp.py
a = map[string]int{'a':1, 'b':2}
The key value pairs can be looped over with a for loop.
def main():
a = map[string]int{'x':100, 'y':200}
b = ''
c = 0
for key,value in a:
b += key
c += value
https://github.com/rusthon/Rusthon/blob/master/regtests/rust/chan_universal_style.py
sender, recver = channel(int)
a <- b
switches to a given case when the channel data is ready.
select:
case x = <- a:
y += x
case x = <- b:
y += x
def sender_wrapper( sender: chan Sender<int> ):
sender <- 100
def recv_wrapper(recver: chan Receiver<int> ):
result = <- recver
switch a == b:
case True:
x = z
case False:
y = z
default:
break
. var
is allowed before a variable name in an assignment.
var x = 1
. 'new' can be used to create a new JavaScript object
a = new SomeObject()
. $
can be used to call a function like jquery
$(selector).something( {'param1':1, 'param2':2} )
. External Javascript functions that use an object as the last argument for optional named arguments, can be called with Python style keyword names instead.
$(selector).something( param1=1, param2=2 )
. $
can be used as a funtion parameter, and attributes can be get/set on $
.
def setup_my_jquery_class( $ ):
$.fn.someclass = myclass_init
. function expressions
F = def(x):
return x
this is a shortcut for writting simple try/except blocks that assign a value to a variable (PEP 463)
a = {}
b = a['somekey'] except KeyError: 'my-default'
. with
is reserved for special purposes.
. for/else
and while/else
are deprecated.