# Plezuro/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Plezuro

# introduction

The main purpose of creating of Plezuro was to enhance the software development process. It was created in 2014 while there existed many other scripting languages. However none of them had enough beautiful syntax to write the large pieces of codes without getting bored. Even Plezuro needs some improvements to achieve its main goals.

# getting started

One of the main principles of the Plezuro programming language says the following: "The module, the function and the source file are equivalent one to each other." What does it mean exactly? So you can pass arguments to a module in the same way like to a function and also the module returns a value in the same way like a function.

## Hello world

At the beginning: How can you write the Hello World script in Plezuro? It is so simply:
Of course, the design of the language could be even simpler like that:
But that would be much more like a mark-up language (eventually template language), not programming language. So the previous script is not correct. Moreover there exist other possibilities to write a Hello World script, ex.:
In the first script the module just returns a value (string 'Hello World!') and in the last one it prints this string to the standard output and finally returns the empty value (called just 'empty', its symbol: '').

## Comments

For simplicity the comments are in c++/Java/c# style. Therefore it enables commenting large blocks of code, in contrary to languages such as python or ruby (Of course you can use multi-line string in both cases but in many situations it outputs an error).

## Variables

Like any (including really bizarre ones almost any) languages Plezuro is based on using of variables. I bet you already know what a variable is (if not it is just a container for a piece of information). So at fist occurrence of a variable you should write the dollar sign ('$') immediately before the variable name. The name is in Java style (it allows using any Unicode letters, digits and underscore but at the beginning there must not be any letter). In the next occurrences the dollar sign is not required. Why do we write so many '$'? It seems like PHP, Perl or bash. The reason is really simple. Just for define the variable scope. It is like the 'var' keyword in Javascript (or in c♯ in case of local variables) but in Plezuro it is just shorted (one character '$' instead of four ones 'var '). It is really important feature in case of short anonymous functions and evaluation of code written in string. So let us write some strange example:
Now, maybe a little less strange:

## The nature of the language

Unlike other programming languages where there is just a list of instructions in a function, Plezuro is based on operators. Commands are separated with a semicolon (';') but it is only one of multiple operators. Even variable assignment and function call in intermediate code are translated into operators. Only brackets ('(', ')') and curly braces ('{', '}') are not translated into operators. What is their use? So brackets are used to change order of operators calculation while curly braces are used to write down code which should be executed in the future (or eventually never). That means curly braces are used to write a function definition, a conditional loop or a conditional expression (in these cases we have also some sort of functions - anonymous functions).

## Operators precedence

Two-arguments operators:
* Together:
Single-argument operators: (However here it doesn't matter, important is just the list.

## Important issues

Moreover you should remember about the following:
* The whitespace characters are not included in the intermediate code (that means you may write any number of spaces, tabs and newlines between the tokens (a number/ string/ name/ operator...), of course you cannot write spaces in the middle of variable names or operators.
* One of very important issues of Plezuro is the tuple. You can use it when passing to a multiple-argument function one variable that stores all these arguments. Moreover you can use it in similar way like in Python.

# built-in types

Plezuro provides some built-in classes (types). Moreover you can create your own classes. Each variable is an object of a class, like in Ruby. Therefore all variables are passes into reference. In the next chapter we will discuss the difference between reference and copying. The list of basic built-in classes with their using:

# let's code a little bit

Now you should try to code something in Plezuro.

# lists

One of important types of Plezuro is the list. It is an equivalent of .NET List<object> and Java ArrayList<object>. To create a list, just use square brackets ('[', ']'). In intermediate code it is translated to '::array'. Elements of a list can be of any type (including list), they are passed by reference, so it is possible that a list contains itself.
As you just have seen above, you can print elements of a list in many ways. The simplest way is to use the dumpl function (it is appropriate to any type in Plezuro). Another one is to use the each method. 'args' means all the arguments passed to a function (in this case a tuple (value, index)) and 'this' means the argument #0 (in this case only value).
Now, I guess, you wonder to get access to a specified element of a list (get and set its value). It is pretty simple, like in other languages use square brackets.
Lists like any other variables are passed by reference.
Now, how to sort a list?
Now, a little more about the indexing. You can access to a piece of a list in a similar way like in Ruby (using '..' operator). For example a[1..4]. The difference is in this case in Ruby it returns elements from index 1 up to index 4 but in Plezuro it returns elements from index 1 up to index 3. Another interesting feature is when using commas, you can access to disjoint pieces of a list (for example first and fourth element). Indexing may return an empty object, a single variable or a tuple. Of course, you can modify an all piece of a list.