Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposal] control flow design #65

Open
chinesebear opened this issue Nov 12, 2020 · 0 comments
Open

[proposal] control flow design #65

chinesebear opened this issue Nov 12, 2020 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@chinesebear
Copy link
Contributor

控制流

// now
if expr { 
  expr
} else { 
  expr
}

expr ? expr : expr
// new
func name() {
}
keyword name() {
}
=>
keyword () {
}
<=>
if () {}
for () {}
// c
if (expr) expr
for (expr) expr
fun (params) expr

keyword () (expr|'{' expr* '}')
// if
if (expr) expr else expr // expr ? expr : expr
if (expr) { expr } else { expr }
// for 
for (expr) expr
for (expr) { expr }
// while
while () expr
// fun
fun (params) expr // (parmas) => expr
fun (params) { expr } // (parmas) => { expr }

// change 
if (else if) else // else if
if expr {} else if expr {} else {}
if (expr) expr else ifexpr // == 'if (expr) {} else {}'' // 不需要定义 else if

// fun decl
let f = fun (params) f() // 因为是 let,所以可以优化成函数声明,可以递归
==> 
fun f(params) { return f() } // 等价于上面,可以递归

let mut f2 = fun (params) expr // 不能递归 f2
// 变量定义 | 类型定义

let fn = fun(arr:[int]) for(i in arr) if (i % 2 == 0 ) print(i)

let main = fun() expr
@chinesebear chinesebear added the documentation Improvements or additions to documentation label Nov 12, 2020
@chinesebear chinesebear added this to the deeplang 1.0 milestone Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants