Skip to content

v0.2

Compare
Choose a tag to compare
@NotAPenguin0 NotAPenguin0 released this 05 Jul 22:49
· 4 commits to master since this release

This second release of pscript brings a couple new language features and tools.

Major features

Range-for

This new type of loop comes in two flavours: one that uses range expressions and one that iterates over an iterable type.

for (let i : 0..10) { } // iterate over 0..10
for (let i : [1, 2, 3]) { } // iterate over the elements of a list

Variadics

Added variadic arguments for functions. This allows passing any number of parameters to a function without using lists. Their syntax is similar to C++.

fn printf(fmt: str, args...) -> void {
    std.io.print(fmt.format(args...));
}

printf("Hello {}, it is clear that {} + {} = {}", "there", 2, 3, 2.0 + 3.0);

Delete

Added a delete statement to delete a variable from its current scope. The variable's memory will be cleaned up and it can be redeclared as if it never existed.

let x = 10;
delete x;
let x = 20;

Tools

Two new tools were added to the repository.

  • A command-line tool for running scripts, which also allows for an interactive mode similar to Python's command line environment. The binary is simply named pscript.
  • A benchmarking tool which will run all scripts inside the benchmarks/ folder and time them.

Building these tools can be disabled by setting the PSCRIPT_BUILD_COMMAND_LINE and PSCRIPT_BUILD_BENCHMARKS cmake variables to OFF.

Bugfixes and minor additions

  • Added literal f suffix for creating floats.
  • Fix compilation on Linux.
  • Add continuous integration (GitHub Actions)
  • Added std.io.printf() using variadics feature to simplify syntax for formatted printing