The Readable Programming Language - Handbook

Expressions

Numbers

A number constant in Lisilogic is written in the usual computer notation, without spaces.
The decimal separator is a dot (.). Floating point constants may use the scientific notation e. The prefix 0x introduces a hexadecimal number.

35
0xFF
1203.5
3e4
3.5e4

The precision and maximal values are the best ones allowed both by the programming environment (i.e. Java) and by the target language and database of the application (see Translators).

In Lisilogic, numbers can be associated with a unit, indicated after them, and carry along their precision. See Basic Syntax: Numbers.

Note that the dot (.) is also the sign used to mark the end of each sentence (see Basic Syntax: Sentences). That's why a number constant can't end with a dot: a dot not followed by a digit (0 to 9) will be interpreted as the end of the sentence, not as part of a number.
The same applies for the scientific e: an e not followed by a digit will be interpreted as the beginning of the unit, not as part of the number.

Character Strings

Text constants are defined between double quotes ("") and introduced by the words the text.
They may content calculated parts in braces ({}).

the text "Welcome {the user's username}!"

A text constant will be considered a short string if it is not longer than 30 characters and if it doesn't contain any line break. Otherwise it is a text (see Structures: Basic Types). Conversions are automatic.

Double quotes not introduced by the words the text will be interpreted as an enumeration value (see Enumerations), and converted to a short string, a text, an email address, a list of email addresses, a url, a list of enumeration values, a number, etc. (see Structures: Basic Types) when appropriate.
They can't contain calculated parts, the braces will be handled as normal characters.

Note that Lisilogic must have an information about the type whished in order to proceed to a conversion:
set the user's birthday to "01/27/1969"
OK, the user's birthday is a date, so convert the enumeration element "01/27/1969" to a date.
see "01/27/1969" + 3 months
Error: Lisilogic cannot guess that the enumeration element "01/27/1969" is intended to be a date.
In the future, Lisilogic might have a special notation for dates, email addresses, urls etc. (either just without quotes or with introductory words like "the date", "the email address", etc.) to reduce the ambiguities and enhance the efficiency.

Double quotes and opening braces placed between double quotes must be preceded by a backslash (\). See also Basic Syntax: Character Strings.

Simple Constants

The constant null has no type, it will be interpreted differently depending on its utilization (empty attribute, empty list, boolean false, number 0, empty character string, ...). It is also the value of any unreachable or not yet initialized attribute, see below.

false and true are the usual boolean values. In comparisons, false is smaller than true.

now is the current timestamp and today is the current date.

the application is the single instance of the application structure, see Structures: Predefined Structures.

Contextual Constants

the user is the instance of the user structure representing the logged in person (see Structures: Predefined Structures). It will be null if the person using the application is not logged in (it is a visitor, see Roles).

the given followed by a type name (structure or simple type) accesses the value passed as a parameter to a procedure (see Procedures), a page or the application, or a widget (see User Interface).
For now, since procedures, pages and widgets can receive at most one parameter, the type name is ignored. In the future, Lisilogic might use the type information (either to check that it matches the passed value, or to allow passing several parameters with different types, or to cope with procedure calling another procedure, oc.).

the current followed by a type name (structure or listable simple type) accesses the value being handled when iterating over a list. See User Interface: List and Table Displayers, Procedures: Loops.

Attribute Paths

An attribute of a structure instance (see Structures: Attributes) is accessed using 's:
the user's username
For now, the s can't be omitted when the preceding word ends with an s:
the user's address's zip_code
In the future, Lisilogic may observe this grammar rule.

Unlike other programming languages, Lisilogic has no "NullPointerException" or "Trying to get property of non-object" error: reading any attribute of null is allowed and will return null.
Writing into an attribute of null will issue an error (unlike PHP who creates a default object and issues a warning).

Note that the length of a character string and the element count of a list aren't structure attributes (strings and lists aren't structures). For now, Lisilogic allows to evaluate them only with the corresponding operators the length of and the count of (see below), not with 's. Contrarywise, structure attributes can't be accessed with "the ... of". This may change in the future.

Pronouns

In structure definitions (see Structures) and in "create" statements (see Procedures: "create" Statement)

Use its followed by an attribute name to define or initialize the corresponding attribute.
Each address has a short string called its zip_code.
create a new address as the user's address with the text "10829" as its zip_code

In "can" sentences (see User Interface and Roles), including anonymous procedures

he and himself refer to the role being defined, which will be an instance of the user structure if the person using the application is logged in, null otherwise. This is identical to the contextual constant the user.

his is the normal possessive pronoun corresponding to he.

On the "Home" page, the user can: - see the text "Hello {his username}!", - see himself using a profile_viewer.

In the future, he and himself in a "can" sentence about the visitor role may return a temporary visitor structure.

them can only be used in list or table viewers (see User Interface: List and Table Viewers) and refers to the element of the list being handled during the iteration (the row for a table viewer). It is identical to the contextual constant the current ....

their is the normal possessive pronoun corresponding to them. It can also be used in list filters (see below).

On the "Edit Gallery" page, the user can see his images having their state equal to "validated" as a table showing: - a "Preview" column containing them, - a "Filename" column containing their filename.

it refers to the value passed as a parameter to the page or widget being defined. It is identical to the contextual constant the given .... It will be null if no parameter value has been passed.

its is the normal possessive pronoun corresponding to it. Note that Lisilogic will understand "it's" as an attribute path identical to "its" instead of the correct grammatical meaning "it is". Many human people do a comparable mistake. It is recommended to use only "its" and "it is", not "it's".

Note that since the parameter of a page or a widget isn't defined explicitely, the readers of the code might expect "it" and "its" to refer to something else (the current element of an iteration, the last mentioned object, ...) or the passed parameter to be referred to using other pronouns ("him", "his"). In (anonymous) procedure definitions, the special usage of "its" in "create" statements (see above) may also interfere. It is recommended to use the given ... to prevent any ambiguities.

In "To" sentences (see Procedures)

it refers to the value passed as a parameter to the procedure being defined. It is identical to the contextual constant the given ....
It will be null if the procedure has no parameter. In the future, it might be a programming error to use the given ... or it in a procedure without parameter.

its is the normal possessive pronoun corresponding to it. Note that Lisilogic will understand "it's" as an attribute path identical to "its" instead of the correct grammatical meaning "it is". Many human people do a comparable mistake. It is recommended to use only "its" and "it is", not "it's".

Note that the readers of the code might expect "it" and "its" to refer to something else (the current element of an iteration, the last mentioned or created object, ...) or the parameter passed to the procedure to be addressed using other pronouns ("his", "him"). The special usage of "its" in "create" statements (see above) may also interfere. It is recommended to use the given ... to prevent any ambiguities.

them can only be used in loop statements (see Procedures: Loop Statements) and refers to the element of the list being handled during the iteration. It is identical to the contextual constant the current ....

their is the normal possessive pronoun corresponding to them. It can also be used in list filters (see below).

he, him and the possessive his refer to the person who's using the application, not to the parameter passed to the procedure, even if it is a role object (see Roles: Role Objects). It is recommended to use the user instead.

Unary Operators

the length of returns the length of a string in characters.
see the length of "Hello world!"12characters
Simple types (date, numbers, boolean, ...) will be converted to character strings before measuring their length.
Attempts to get the length of a structure will issue an error notification.
The length of a list is identical to its element count; it is recommended to use the count of instead.

the count of returns the number of elements of a list as a whole number without unit.
On the "Manage Images" page, the admin can see the count of all images.
Attempts to get the count of something that isn't a list will issue an error notification.

Special operators for dates and timestamps (the month of, the day of, the minute of, ...) are planned.

Note that the size of a file and the width, height and size of an image are attributes of these predefined structures, accessed with 's instead of "the ... of". In the future, Lisilogic may allow 's for length and count and "the ... of" for attributes.

Arithmetic Operators

The operators plus (+), minus (-), multiply (asterisk, *) and divide (/) have their usual meaning between numbers. The units, including percent (%), will be combined correctly, see Basic Syntax: Numbers.

Lisilogic tries to give a reasonable meaning to arithmetic operators used with other data types than numbers: adding a duration to a date or timestamp results in a new date or timestamp, subtracting a date or timestamp from another one returns a duration, adding an element to a list will return a new list, adding two listable elements will produce a list, subtracting an element or a sublist from a list and appending two character strings are possible, etc.. Note that the difference between string constants (introduced by the words "the text") and enumeration values (in double quotes without "the text", see Basic Syntax: Character Strings) may interfere: adding an enumeration value to a string results in a string, whereas adding two enumeration values results in a list.

Parentheses

The priorities of the operators are normal, and you may use parentheses ( ) in arithmetic expressions.
set the project's tax_advantage to (the project's fixed_costs + the project's yearly_costs) * 5%

Note that for readability's sake, parentheses are not allowed in logical expressions (operators and and or, see below). Use cascading "if" statements instead.

Comparisons, Notification Tests

The comparison operators are equal to, smaller than, greater than, in, contains, starts with and ends with.
They can be negated with the word not and must be completed with verbs (is, does) correctly.
"is" and "does" can be merged with "not" in the usual way.
"equal to" can be omitted. In list filters (see below), "is" must be omitted and the verbs must be conjugated properly (containing, starting, ending, ... instead of contains, starts, ends, ...).

if his address isn't null, the user can...
if the user's avatar's width is smaller than 100px, ...
... see all images having their width smaller than 100px

Note that smaller and greater mean "strictly smaller" and "strictly greater". There are no "greater or equal" or "smaller or equal" operators, use "not smaller" or "not greater" instead.

All comparison operators result in a boolean and will try to find a reasonable meaning if their operands are of unexpected types, issueing an error if they don't succeed.

The comparison operators "after" and "before" are in study, especially regarding their meaning for string constants (caseless comparison?) and the possibility to test the ordering of elements in a list.

there are or there are no followed by a notification type (success, error, warning, or just notification for any of these) test if notifications of this type have been issued and will be visible on the next displayed page.
if there are success notifications, the user can see the text "Changes Saved!" at the bottom of the page
if there are no errors...

See also Procedures: "issue" Statement.

Logical Operators

The operators and and or are available.
if the user's address is not null and the user's address's zip_code is null, ...

Note that the previous parts of a sentence don't change the meaning of pronouns: "if the user's address is null or its zip_code is null" is not a correct replacement for the previous example.

and has a stronger priority than or, but since the consequences of this convention aren't obvious to anybody, especially not to non-programmers, it is recommended to use cascading "if" statements instead of nested logical operators. For now, Lisilogic doesn't allow parentheses in logical expressions. This might change in the future, if research finds a way to restrict their utilization to cases where non-specialists still can understand the code.

The possibility to use "and" or "or" to produce lists ("set the user's roles to salesperson and supervisor") is in study.
The possibility to use "and" or "or" on values instead of comparisons ("if the user's roles contains salesperson or supervisor") is a research topic.
Further logical operators ("but", "though") are in study.

all

all followed by the name of a structure will return the list of all instances of this structure present in the database.
On the "Manage Images" page, the admin can see all images as a table showing...

Role objects are always replaced with the users who own them (see Roles: Role Objects, so "all" followed by a role name will in fact return all users whose "roles" attribute contains the given role.

List Filters

A list expression can be filtered with the operator having followed by a condition (see above) to be evaluated on each element of the list.
In the condition, the pronoun them and the possessive their refer to the element being evaluated, the verb "is" is omitted from the comparisons, and the other verbs (contains, starts with, ends with, ...) must be properly conjugated: containing, starting with, ending with, ....
On the "Edit Gallery" page, the user can see his images having their state equal to "validated" and their filename ending with the text ".jpg" as a table showing...

Element extraction operators (... having maximum/minimum ...) are in development.
Value extraction operators (the sum of, the min of, the max of) are planned, but their implementation is complicated by the fact that Lisilogic can't make lists of basic types, especially of numbers.