Tyl Programming Language
▶ TYL STATEMENT ORDER
Tyl statement structure:
[ENTITY] [REST]
ENTITY - scalar variable, list variable or function
REST - the rest of the statement after removing ENTITY

REST is interpreted by ENTITY:

Let's start with a basic variable assignment:
num 21
num is the entity, and rest is: 21.

So the code will read:
num gets the value: 21
Using len system function, we can calculate the length of the string: 'Kilimanjaro':
len 'Kilimanjaro'
Again, len is the entity, and rest is: 'Kilimanjaro'.

So the code will read:

len calculates the length of the value: 'Kilimanjaro', and returns the result

The above statement will do nothing with the result: 11.

So let's assign that result to num:
num len 'Kilimanjaro'
num is the entity, and rest is: len 'Kilimanjaro'.

So the code will read:
num gets the result of len of 'Kilimanjaro'
To print num:
num len 'Kilimanjaro'
print num
11
print function can print strings, numbers, and even the result of other statements.

To print the result of a statement:
print len 'Kilimanjaro'
11
Now, print is the entity, and rest is again: len 'Kilimanjaro'.

So the code will read:
print the result of len of 'Kilimanjaro'
Or, assuming we know the meaning of len:
print the length of 'Kilimanjaro'
And why not combine the assignment and the printing:
print num len 'Kilimanjaro'
11
First, the length of string: 'Kilimanjaro', will be assigned to num, and than will be printed.

Is there a limit to these one-line statements?

Well, as long as the line can be interpreted correctly, it's all fine. But, there are some cases where it is not that simple.

Consider this print-key-value function:
pkv key value » print key + ': ' + value
We want to print 'Kilimanjaro: 11':
pkv 'Kilimanjaro' 11
pkv is the entity, and rest is: 'Kilimanjaro' 11., which are the two parameters of pkv function

Or using the len funcion:
pkv 'Kilimanjaro' len 'Kilimanjaro'
pkv function has two parameters, and the parameters code is: 'Kilimanjaro' len 'Kilimanjaro'
The first parameter gets the string: 'Kilimanjaro', the second gets the rest of the parameters code: len 'Kilimanjaro'.

In Tyl, if a parameter is the sole or last parameter of a function, it gets all the statement as its contained statement. So the second parameter will be the result of: len 'Kilimanjaro'.

But, what if we switch pkv parameters?
pkv value key » print key + ': ' + value
Using the len funcion as before:
pkv len 'Kilimanjaro' 'Kilimanjaro'
The system will take len funcion without parameters, as pkv first parameter, which does not meet our intentions.

In this case, enclose the first parameter code in parentheses:
pkv ( len 'Kilimanjaro' ) 'Kilimanjaro'
Thus, signalling the system to take all the enclosed code: len 'Kilimanjaro', as pkv first parameter.