Releases: smuuf/primi
Releases · smuuf/primi
Primi 0.2
- New negation operator
!
. - Inference of most fitting function based on value type.
Primi 0.1
Simplified whole concept of Primi.
- No more ambitions to make everything a 'object'.
- No more ambitions to have prototypal or any other type of inheritance.
- No more Lazy values.
- No more value's methods and/or properties. These are now simple functions instead.
- Uniform Function Call Syntax supported.
- Extensions are applied during instantiation of interpreter.
Primi 0.0.15
-
New: Support binding native PHP functions as Primi variables and/or functions
- More of a "backend" feature.
- Those who want to use Primi as library now can predefine functions that are to be available during the execution. These can be passed in as ordinary PHP closures (PHP callables will be internally converted to PHP closures).
- New class
FunctionContainer
now acts as a universal wrapper for both standard Primi functions and also for newly supported native PHP functions. Note: Functions created from PHP callables won't have access to the caller context, but passing arguments from user-land to predefined native functions is fully supported. - Arguments are passed as Primi value objects (eg.
\Smuuf\Primi\Structures\StringValue
). A Primi value object is then also expected as the return value.
-
New: Array value now has 4 new methods:
-
Change: Invoked functions now capture the context of where it was defined. Previous behavior was that the context of the caller was passed into the function.
Example of binding native PHP functions:
use \Smuuf\Primi\Context;
use \Smuuf\Primi\Structures\FunctionContainer;
use \Smuuf\Primi\Structures\StringValue;
use \Smuuf\Primi\Structures\FuncValue;
$c = new Context;
// Build function container from a native PHP anonymous function...
$fnContainer = FunctionContainer::buildNative(function($a, $b) {
return new StringValue($a->getInternalValue() . "_" . $b->getInternalValue())
});
// Store the function value in the context as variable.
$c->setVariable('fun_fun', new FuncValue($fnContainer)));
// At this point the function "fun_fun" (which expects two arguments and returns a string)
// is available in user-land...
Primi 0.0.14
String
,Number
andArray
value methods were externalized (refactored outside of their classes).- Each type of value can be extended (eg. by a developer using Primi as library for their own project) to register more extensions via
ExtensionHub::register()
method - register custom methods for each value type. - Libs most recently registered are used to lookup methods first.
- Ie. Standard library methods can be easily overwritten, if the client wants/needs to.
- Massive reduction of AST preprocessing (AST reduction) processing time.
Old | New |
---|---|
█ (1 / 10) ./sample/bench_all.primi ... 79.227 s ./sample/bench_simple.primi ... 8.047 s |
█ (1 / 10) ./sample/bench_all.primi ... 1.770 s ./sample/bench_simple.primi ... 4.005 s |
Primi 0.0.13
- Use own, improved version (fork) of
php-peg
.
Primi 0.0.12
- Value objects now know how to represent themselves as strings in Primi syntax. (except functions)
- Fix: Fixed bug when echoing array values in REPL mode.
Primi 0.0.11
- Functions are now
Value
objects (same as other values) and can now be stored and used as variables. - New: Support for anonymous functions.
- Classic syntax:
function(arg1, arg2) { return arg1 + arg2; }
- Short syntax:
(arg1, arg2) => { return arg1 + arg2; }
- Higher order functions:
((fn, arg) => { return fn(arg); })((x) => { return x + 2;}, 8)
- Direct invocation is supported:
((arg1, arg2) => { return arg1 + arg2; })(1, 2);
returns3
- Classic syntax:
- Improvements: Array definitions can have trailing commas.
Primi 0.0.10
- "string" vs "number" comparison no longer throws an error.