php-smplang icon indicating copy to clipboard operation
php-smplang copied to clipboard

extension support & some extensions

Open isaeken opened this issue 3 years ago • 1 comments

isaeken avatar May 26 '22 04:05 isaeken

thank you again for your contributions!

what do you think about making extensions optional for each object? we could also allow users to make their own extensions and load them when needed.

i'm not really sure that the unset() function is a good idea for now. first of all, changing a var's value is currently not possible in SMPL - we could at some point introduce a syntax for settings a var value (e.g. a = 1) but that on its own wouldn't make sense without support for executing multiple expressions at once because currently each execution of evaluate() has its own isolated state (which is by design).

besides that, the isset() function wouldn't work properly for var.element or var['element'] which is something that should work if we provide a builtin isset() function. what we could do is evaluate the first parameter passed to the function and if any value comes out, it returns true, but if a var not defined exception occurs it catches it and returns false instead. the problem with this approach is that isset('some string') would return true, and that doesn't seem to be good (php throws a fatal error if you try to do that).

all in all, i'm not sure if we should have any builtin state-changing functions.

i definitely appreciate your efforts very much but let's discuss this before you write more code, I want to hear your opinions!

p.s. if you haven't already, take a peak at Dataplater - another project of mine that uses SMPL

leongrdic avatar May 26 '22 08:05 leongrdic