SyL
SyL is an esoteric language by Abraham Karplus designed to use no punctuation and pronounceable names. The syllables from which the language gets its name are all of the form CV. The extension .syl is used for SyL program files. Program file names are required to use the syntax for variable names.
Consonants
The SyL consonants are
p b f v m t d s z n
k g y w l r h
The top row are normal consonants for use in variable names, while the bottom row consonants have special uses (syntax, numbers, built-in commands).
Vowels
The SyL vowels are
a e i o u
Pronunciation
All letters are pronounced with their IPA values, except that ‹y› should be pronounced /j/, to match normal English pronunciation. (Additionally, ‹l› and ‹r› can be pronounced as any lateral approximant and any rhotic, respectively.) If needed for clarity, newlines can be pronounced with any click.
Comments
The wihu keyword begins a comment and wihe ends it.
Variable names
Variable names are 1 or more syllables, each consisting of a normal consonant followed by a vowel.
Numbers
Numbers are written in base 10 with these digits:
0 la 1 le 2 li 3 lo 4 lu 5 ra 6 re 7 ri 8 ro 9 ru
The decimal point is written hi. Nonnegative numbers must be followed ha and negative numbers by hu.
The decimal point cannot go at the beginning or end of a number—put a zero next to it.
For example, -13 is lelohu and 71.06 is rilehilareha. Booleans are not specially represented—they are just numbers, with 0 false and everything else true.
Variable creation / assignment
Variables are created and assigned to by the ke statement. It functions like so:
ke pabi wu luroha wihu Variable pabi with value luroha (48) wihe ke no wu laha wihu Variable no with value laha (0) wihe
Enhanced assignment is supported by putting the operator name between ke and the variable name.
Arithmetic
The arithmetic operators are prefix. Operators separate their operands with wu.
Binary Plus gahaha Minus gahahe Times gahiha Divide gahihe Exponent gahoha Root gahohi Logarithm gahohu Modulo gaheha
Unary Truncate gahuho Floor gahuhe Ceiling gahuhi
Division does not truncate. Root(x, y) is equivalent to Exponent(y, 1/x). Logarithm takes the base before the main argument.
For example, pabi plus raha (5) is written gahaha pabi wu raha.
Comparisons
The comparison operators are also prefix, and function on lists and the special value yuhi as well.
Equal goho Less Than gohi Greater Than gohu
For objects of different types, only goho is defined, and it is always false. On lists and maps, the comparisons function element-by-element.
Blocks
The keyword we begins a block, which is a set of statements. The keyword wo ends it. It is standard practice to put each of these keywords on their own line, and to indent four spaces within a block. For a single-statement block, the keywords are still required, but it is customary to put them on the same line as the statement. These block keywords are also used in function definition and calling, with a different meaning in the latter.
Conditional
The conditional keyword is ki, used like this:
ki zabo wihu If zabo wihe we wihu Begin block wihe ke gahe pune wu leha wihu Decrement pune by leha (1) wihe ke mana rohu wihu Set mana to rohu (-8) wihe wo wihu End block wihe
While
The while keyword is ku, used in the same manner as the conditional.
Lists
Lists are created by assigning the keyword yuhe, representing the empty list, to a variable using the standard ke syntax.
Lists may contain objects of any type.
Iterations over a list is supported by the keyword ko, used similar to while as follows:
ko tazo wu di wihu For di in tazo wihe we ke gaha pune wu di wo wihu Increment pune by di wihe wihu The block keywords were placed on the same line as the single statement wihe
Membership in a list may be tested by the geho operator which takes a list and an item and returns a boolean. An item may be added to a list by the geha operator which takes a list and an item and returns a new list with the item appended. The gehu operator takes a list, an index, and a value and returns a new list with the item at the given index replaced by the given value. Recreate a list to clear it. The gehi operator takes a list and an index and returns the item of the list at that index. The gehe operator takes a list and returns its length.
Two of the arithmetic operations work on lists: Plus and Times. Plus concatenates two lists. Times repeats a list a number of times given in the second argument.
Strings and I/O
Strings are represented as lists of characters, which are just integers.
To output a list as a string, use the giho command followed by the name of a list. To input a line, use gihe, which returns a list of the line read. To input a character, use gihi, which returns an integer representing the character read. EOF has the value lehu (-1).
Maps
A map is a variable type, similar to a list, which maps keys to values. Keys and values may be of any type. The keyword for an empty map is yuhu. Maps are also created by imports.
Most of the list functions work on maps, specifically geho, which checks if the map contains a key, gehu and gehi, which allow a generic key instead of only an index, and gehe.
Imports
The keyword wa imports a program file named following the keyword.
To import from the standard library (when there is one), add hi between wa and the filename. To import from a lower-level folder, use he as a folder separator. Folder names must be valid variable names. To import from a higher-level folder, ho can be used to go up one level from the current folder.
The file name should not have the .syl extension, that will be added by the program.
The result of the import is a new map variable, named as the file (though without the extension, of course), that has the defined variables and functions of the file as entries, with their names as string keys.
Functions
A function definition uses the syntax
ya {arguments} we {body} wo {return} ya
which can be written on one line as
ya {arguments} we {body} wo {return} ya
where {arguments} is a set of variable names separated by wu, {body} a set of commands, and {return} the expression that the function returns.
The syntax is used by assigning the function to a variable, which then holds the function. Functions are first-class and can be passed around, etc.
If {arguments} is omitted, the function takes no arguments. If {return} is omitted, the function returns the special value yuhi. Note that {body} may contain zero statements.
To call a function, use the syntax
yo {name} we {arguments} wo
where {name} is an expression that evaluates to a function, and {arguments} is a set of expressions separated by wu to pass to the function.
Note that arguments are only accessible from within their function, and are passed by value, so changing them inside a function does not affect the outside values.
Examples
Please comment on the talk page if you notice any bugs in these examples.
Hello World
Prints 'Hello World' (using no punctuation to better fit the spirit of the language).
ke ta wu yuhe wihu Create a list ta wihe wihu Append to the list numbers for characters wihe ke geha ta wu riliha wihu H wihe ke geha ta wu lelaleha wihu e wihe ke geha ta wu lelaroha wihu l wihe ke geha ta wu lelaroha wihu l wihe ke geha ta wu leleleha wihu o wihe ke geha ta wu loliha wihu space wihe ke geha ta wu roriha wihu W wihe ke geha ta wu leleleha wihu o wihe ke geha ta wu leleluha wihu r wihe ke geha ta wu lelaroha wihu l wihe ke geha ta wu lelalaha wihu d wihe giho ta wihu Output the list as a string wihe
Cat
Copies input to output a line at a time
ke notadone wu leha wihu Create a variable notadone (not done) with value 1 wihe ku notadone wihu While notadone wihe we wihu Begin block wihe ke ta gihe wihu Read a line to ta wihe giho ta wihu Output ta wihe ki geho ta wu luha wihu If EOF in ta wihe we ke notadone wu laha wo wihu Set notadone to 0 (done) wihe wo wihu End block wihe
Successor Function
Function that returns one more than its argument
ke suseso wu ya nu we wo gaha nu wu leha ya wihu Create a function suseso that takes one argument, nu doesn't do anything then returns nu plus 1 wihe ke ta wu yo suseso we reliha wo wihu Calls suseso on reliha (62) and stores the result (63) in ta wihe
To-Do
- Add more examples
- Classes
- OS interfaces
If you have more ideas, please post on the talk page.