Files
Sheerka-Old/docs/source/blog/concepts.rst
T

43 lines
884 B
ReStructuredText

Concepts
========
Basic definition
****************
To define a new concept
::
> def concept hello a as "hello" + a
Note that if the left part of the keyword 'as', the traditional quotes that would surround 'hello' and 'a' are not necessary.
In this example 'a' is a variable, as it appears as variable in the 'as' section (while hello
appears as a string)
You have just defined a concept name 'hello'. Sheerka now can understand
>>> hello kodjo
>>> hello my friend
When you do so, an instance of the concept will be created in memory. In the first case,
it will a variable ``'a'`` filled with the value ``'kodjo'``, in the second case, the variable
will be filled with the value ``'my friend'``
Another example:
::
> def concept one as 1
> def concept two as 2
> def concept a plus b as a + b
That's enough to define the addition
>>> one plus two
3