Skip to content

The Lapis syntax

Sofia edited this page May 28, 2024 · 1 revision

Introduction

The Lapis syntax tries to be as much compatible with Ruby as possible. Lapis code feels almost exactly like Ruby, since programs are visually just functions chained as if they were methods (this is actually the exact way pipes are implemented in Lapis).
Despite my best effort, as of now Lapis differs from Ruby in a few more or less major ways. This page attempts to document all known problems with the current Lapis syntax.
Not all of these can/will be fixed, but most of these are here just because the project is in a very alpha stage.

Program pipes

Lapis program pipes require the method call operator (the .) to be separated from the first element of the pipe to work. This is only for programs. Functions are unaffected, including user-defined functions.
The aforementioned problem is a bug and will be fixed.

Examples (working behavior)

immagine

Examples (broken behavior)

immagine immagine

Unary minus

Since most UNIX-style programs use - and -- as program argument prefixes, in Lapis the unary - operator, which normally negates an integer, has a different semantics, illustrated in the following example. immagine

Note

The unary minus semantics will not be adjusted.

Is it a variable or a flag?

In Lapis, anything that looks like a variable is checked internally to see if it's defined as such. If it's not, it's treated like a program argument, i.e. a bareword.

Example (using a defined variable)

immagine

Example (using a function parameter)

immagine

Example (broken behavior)

However, trying to pass a variable to grep_fn as defined above fails. This is an bug and will be fixed. immagine