Snakel/Syntax

From Esolang
Jump to navigation Jump to search
Back to Snakel

Every program starts with a definition, to actually define a function, you can do this:

­ 1: def name[arguments]; !Used for argumented functions
­ 2: ­ ­ ­ ­ ignore !"ignore" will go to the end of the function
­ 3: def name:none; !Used for argumentless functions
­ 4: ­ ­ ­ ­ ignore

translated into python:

def name(arguments):...
def name():...

I/O in Snakel also exist:

­ 1: def main:none;
­ 2: ­ ­ ­ ­ tell["anything here"] !Prints "anything here" in one line
­ 3: ­ ­ ­ ­ user !Gets user input. No argument required

translated into python:

print("""anything here""")
input()

By the way. The strings are actually multi-liners so:

­ 1: def main:none;
­ 2: ­ ­ ­ ­ tell["multi
­ 3: line"] !Will print "multi\nline"

translated into python:

print("""multi
line""")

Now let's talk about the "ignore" and "end".

­ 1: !we already know that "ignore" goes to the end of the function, But did you know that you can also ignore errors with "ignore" and with "test"?
­ 2: test:1/0 !Will rasie a zero devision error
­ 3: ignore Error:tell["inf"] !will print "inf" (or infinity) instead of raising zero devision error
­ 4: end !"end" just ends the program

translated into python:

try:1/0
except:print("""inf""")
exit()

Also i think i kinda stole the logic of rust's case statements for Snakel conditional

­ 1: num i=0
­ 2: if i=0;tell[0] | i=1;end | tell[3]

translated into python:

i:int=0
if i==0:print(0)
elif i==1:exit()
else:print(3)

Snakel also has the feature of making multiple files in one file (just like in DreamBerd). You can also import that file to another file as a internal module

­ 1: -one.sl-
­ 2: tell["executed one.sl"]
­ 3: -two.sl-
­ 4: import mod one.sl
­ 5: tell["executed two.sl"]