vrodedanya / naobi

Naobi language
https://vrodedanya.github.io/naobi/
MIT License
4 stars 0 forks source link

[FEATURE] Scopes #25

Open vrodedanya opened 2 years ago

vrodedanya commented 2 years ago

Is your feature request related to a problem? Please describe. Current implementation of if else or for loops is a bit bad. That blocks are collected by parser with extra code which is not good idea. Also, parser doesn't support blocks in code which will be useful to separate different variables scopes

Describe the solution you'd like Add supporting of scopes without if else and for oriented code. That blocks can be executed if stack has true value on the top. So control statements can be just a function! :) It's a bit weird, but very interesting 'cause users can create their own statements like if else or for, while and e.t.c. Else and if else statements require the previous statement's state. It's a bit difficult. Probably we can push result of if statement and scope after if statement will be pop it if result is true else scope will be leave false result. Need to continue research. I think it's a very good idea that will improve code quality and will make naobi more flexible.

Additional context Examples

workflow example
{
    true 
    {
    }

    if (true) 
    {
    }
    if true // In that case it is not a function. Remove this feature or add function call without ()?
    {
    }
    some_user_func()
    {
    }
}