Chapter 3. The P* language

Table of Contents

Basic program layout and scenes
Basic types
Regular expressions
Scene inheritance
Expressions and operators
Hashes and arrays
Data types GET, POST and ENV
HTML templates in P*
File I/O
Example of web-application

All programming languages have advantages and disadvantages. These two creatures are happily married, and they can't be separated. If you try to kill a disadvantage, it's beloved advantage will commit suicide, and you're back where you started. If you overlap a disadvantage with another advantage, a new disadvantage comes along with it.

Does this mean that we will never have a perfect programming lanuage? It probably does. However, P* has made an attempt to get around this by selecting which bad things to have first and seeing what advantages we get with those afterwards.

A P* program is run by an interpreter engine, and this is bad for speed. We compensate for that by making the language simple, which actually has the side effect of making it suitable for web programming. What web programming is about is, yes you guessed correct, "web", and the tools to create the web should be designed with that in mind.

Basic program layout and scenes

All code in P* programs sits inside SCENE blocks. A program is required to provide a SCENE called main, which is the first one to be run by the interpreter. P* will crash with an error message if the SCENE main is missing. There may be no duplicate scene names, and they cannot nest.

Scenes, apart from the main scene are called using the #SCENE-pragma. A scene may access all variables from it's caller.

A simple P* program with two scenes might look like this:

#!/usr/bin/wpl -f
SCENE my_scene {
	/* Print out the value of the 'text'-variable */
	echo "This is my_scene: '$text'\n";

SCENE main {
	/* Create a string variable */
	string text = "Hello world!";

	/* Call the other scene */
	#SCENE my_scene;
/* This program will output
This is my_scene: 'Hello world!'