Plezuro/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 edit

At the beginning: How can you write the Hello World script in Plezuro? It is so simply:

'Hello World!'

Of course, the design of the language could be even simpler like that:

Hello World!

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.:

'Hello World!'.printl;

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 edit

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).

// this is a comment
/*
Another comment
*/

Variables edit

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:

$假借字=4;
假借字+假借字^2

Now, maybe a little less strange:

$x=4;
x+x^2

The nature of the language edit

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).

2*(3+4)^5.4


$x = 5;
{2<3}.if{x++}.else{x--};
x

Operators precedence edit

Two-arguments operators:

  • ;
  • :=
  • =
  • ,
  • <->
  • <<
  • >>
  • ?
  • |
  • &
  • <=>
  • >=
  • >
  • <=
  • <
  • !=
  • ==
  • ===
  • =~
  • -
  • %
  • *
  • /
  • ^
  • Together:
       * ^^
       * .
  • ..
  • :

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

  • !
  • &&
  • **
  • #
  • --
  • --
  • @

Important issues edit

Moreover you should remember about the following:

  1. 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.
  2. 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.