Function Line Wrap

ASnake Documentation

Table Of Contents

Summary:

Lines starting with a defined function and no operator after it, will wrap the entire line as argument(s) if there is no left parenthesis after the function name.

The only predefined function this will work with is print. All others must be defined in the script. In the future it may support imported functions and other Python built-in functions.

print "hello, my favorite number is", 12
# result: hello, my favorite number is 12

puts does print x,end='' from x
puts 12
puts 14
# result: 1214
print '\n' # for newline

timesTwo does return x*2 from int x = 0
timesTwo + 2
# that would be equivalent to print(timesTwo() + 3)
# instead of timesTwo(+ 3) , as that is invalid syntax
# result: 2

timesTwo ( 2 ) + timesTwo( 2 )
# result: 8

print timesTwo 2  + timesTwo( 2 )
# result: 12
# default expression does not trigger due to it being a bare function, 
# thus a print statement is needed for output

Be careful inside conditional expressions, it will wrap the expression.

addOne does return x+1 from int x
if addOne 3 > 5 do 'thing'
# result: 'thing'
# it triggers the conditional as True
# 3 > 5 returns False, which is equal to 0
# but addOne adds 1, which makes the statement True
# it is equivalent to:
if addOne(3 > 5): print('thing')
Scroll to top