Designed by Atle Solbakken Typing discipline Static, weak Filename extensions .pstar or no extension | First appeared 2013 License GPLv3 | |
OS Cross-platform (multi-platform) |
P* (pronounced "P-star") is a programming language meant to be useful in web development for creating dynamic HTML documents. The language provides syntax for templates and prepared SQL-statements. P* programs are scripts which are run by the P* interpreter.
Contents
Syntax
The syntax is inspired from other C-family languages. Program Blocks starts with the open curly bracket {
and ends with the close curly bracket }
.
Scenes and templates
The code of a P* program is placed into scenes [1], and the HTML markup is typically placed inside templates. A scene is a special type of function which does not take arguments. All programs must provide exactly one scene called 'main', which is the first to run by the interpreter.
A small P* web page, where the code for the program sits inside the scene called 'main' and the HTML markup is put inside a template, can look like this:
When scenes and templates in P* are called, the callee inherhits all variables which is available from where the call is made. This is opposed to when functions are called, where only a set of paramenters is passed.
Data types
P* provides eight basic types [2] for storing data in variables. All variables is required to have a type, but P* automatically converts between them.
In the following example program, one variable, int a
, is assigned the value 2
, and another variable, string b
is assigned the text string "3"
. When the operator +
is run, the left associativity of the operator will lead to an implicit conversion of the right argument to the same type as the left side (type int
) before the addition is performed.
Implementation
P* programs are run by the P* interpreter. A typical way to run scripts is to include a shebang on the first line of the scripts (like #!/usr/bin/wpl -f
) and execute the scripts from the shell, or placing the scripts inside CGI-configured directories of a webserver. An interpreter module for the Apache web server is also available.