# Manipulating Functions

There are only two predefined functions for invoking functions:

• `<expression> of <list>`
• `continuation <expression> of <list>`

###Calling a Function There are two way to get a function as a value.

The first way is the function alias. When you give an alias to a function, you have the power to reference this function without calling it:

``````phrase pi : the pi function
set the result to 3.14
end

phrase (x) is odd : odd number
set the result to x % 2 = 1
end
``````

Now, `the pi function` references to a function that has no argument, `odd number` references to a function that has one argument. In Phrases, Sentences and Blocks we have already know that we can call a function by passing it to an argument declared as a function. But if we store the function in a variable, Tinymoe still offer another way to directly call it. So the following statements are the same:

``````print pi
``````
``````print the pi function of ()
``````
``````set f to the pi function
print f of ()
``````

And so as these statements:

``````print 1 is odd
``````
``````print odd number of (1)
``````
``````set f to odd number
print f of (1)
``````

The second way to get a function as a value is not declaraing the block body as a function. So the following 2 functions are exactly in the same meaning:

``````block (sentence deal with (it)) repeat (number) times with (argument counter)
repeat with i from 1 to numbers
deal with i
end
end
``````
``````block (body) repeat (number) times with (argument counter)
repeat with i from 1 to numbers
call body of (i)
end
end
``````

`call <expression>` is a standard library function, which evaluate an expression and throw away the result. Because `<expression> of <list>` is an expression, which means that it cannot be a statement.

###Calling a Continuation

The detail of continuation is described in State and Continuation.

Calling a continuation is different from calling a function. Because continuation means "the next step", so if you call a continuation, the rest of the code in this function will not be executed.

This is why Tinymoe provide a different function `continuation <expression> of <list>` to call a continuation.

If you call a continuation using `<expression> of <list>`, or call a function using `continuation <expression> of <list>`, it will crash, but the timing of the crashing is undefined.

##### Clone this wiki locally
You can’t perform that action at this time.
Press h to open a hovercard with more details.