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

semicolon support

Open isaeken opened this issue 3 years ago • 3 comments

now we can use like

func(a+b);
5 + 5;
"hello world";

the evalute method returns when semicolon exists: [(func result), 10, "hello world"]

isaeken avatar May 26 '22 03:05 isaeken

i like the idea of support for multiple expressions, it would make SMPL a little bit closer to an actual programming language :) but returning all expressions results in an array doesn't seem very useful imho.

what do you think about behavior similar to Ruby's where the last expression's result is returned?

leongrdic avatar May 26 '22 07:05 leongrdic

we can add return instead and no data such as void will be returned unless return is used.

isaeken avatar May 29 '22 19:05 isaeken

let me elaborate on this:

take a look at the following project that depends on SMPLang: https://github.com/leongrdic/php-dataplater

SMPLang should continue supporting single-expression execution without the return statement, which is why I am considering the Ruby approach. also, multiple expression support doesn't seem very useful without a way to set var values within the language.

i think implementing all of this at this stage is a lot of work and even then i'm not sure it'd be worth the effort.

leongrdic avatar Jul 12 '22 13:07 leongrdic