uLPC v1.0E-8 Reference Manual
This manual is far from complete, it still needs a lot of work to cover
all the aspects required of a good manual. However, I hope that it is
still useful in it's present state.
Getting started
For now this section is made up of example code with line by line
explanations. If there is a word you don't understand I suggest you
look it up in the index first time you encouter it because it might
be essential to understanding that piece of code.
- example1 - Let's write a small uLPC program:
- example2 - Now we will look at a slightly more useful example:
- example3 - This example is a very simple www-server.
Control structures
Control structures groups code into blocks and they control the order in
which statements are executed. Control structures in uLPC are basically
the same as those in C, with a few exceptions.
- break - break a loop or switch
- catch - catch errorrs
- continue - continue a loop
- do-while - execute a statement while an expression is true
- for - generic loop statement
- foreach - loop over an array
- if-else - run on condition
- return - return from a function
- switch - Complicated conditional statement
- while - execute a statement while an expression is true
Types
Data is stored in different ways, integers (eg. 1, 2, 3, 4 etc.) are
are stored in one way, real numbers (1.0, 1.1, etc.) in another. Each
different way get its own name. uLPC types are part of what makes uLPC
a powerful language. They make it easy to handle data without worrying
about memory management and other programming obstacles.
- array - an array of values
- float - floating point numbers
- function - a function pointer
- int - integers numbers
- list - a set of values
- mapping - an associative array
- mixed - any type
- object - an instance of a class (program)
- program - a class, or blueprint for an object
- string - a string of characters
uLPC and object orientation
This section is about the more fundamental workings of uLPC, such as
how uLPC compiles code and object orientation.
- cast - convert one type to another
- class - define a inlined program
- functions - how to write a function
- inherit - use definitions from another program
- lambda - write nameless functions
- modifier - modify function / variable definitions
- preprocessor - textually process code before compiling
- typeof - check return type of expression
- variables - how to declare a variable
Builtin functions
uLPC has a wide range of builtin functions. Most of these are implemented
in C, but some are implemented in uLPC using the add_efun function.
Here's a list of all built-in functions.
Operators
uLPC operators behave much like the onces in C, but have many many additional
features. Most of this added functionality is related to the new data types.
- && - logical and
- `! - is not true
- `!= - check if not equal
- `% - modulo
- `& - intersection
- `* - multiplication
- `+ - add things together
- `- - subtract/negate
- `/ - division
- `< - is lesser than?
- `<< - shift left
- `<= - is lesser or equal than?
- `== - compare values
- `> - is lesser than?
- `>= - is greater than or equal to?
- `>> - shift right
- `^ - exclusive or
- `| - union
- `~ - bitwise complement
- range - cut a slice of an array or string
- || - logical or
Keyword index
The rest of the written documentation is gathered here, without much
thought about order. Hopefully you should be able to use this section
anyway once you've looked at the sections above.
File
- cd - change directory
- combine_path - concatenate paths
- file_size - return the size of a file in bytes
- file_stat - stat a file
- get_dir - read a directory
- getcwd - return current working directory
- mkdir - make directory
- mv - move a file (may handle directiories as well)
- read_bytes - read a number of bytes into a string from a file
- rm - remove file or directory
- write_file - append a string to a file
Builtin programs:
Other pages
Here's a list of all pages.