return keyword + idea for how to use it in for
This commit is contained in:
parent
b920fae93b
commit
8fe7c85b00
@ -38,6 +38,7 @@ pub enum Kw {
|
|||||||
For,
|
For,
|
||||||
Match,
|
Match,
|
||||||
Var, Const, Let, In,
|
Var, Const, Let, In,
|
||||||
|
Return,
|
||||||
Alias, Type, SelfType, SelfIdent,
|
Alias, Type, SelfType, SelfIdent,
|
||||||
Trait, Impl,
|
Trait, Impl,
|
||||||
True, False
|
True, False
|
||||||
@ -56,6 +57,7 @@ lazy_static! {
|
|||||||
"const" => Kw::Const,
|
"const" => Kw::Const,
|
||||||
"let" => Kw::Let,
|
"let" => Kw::Let,
|
||||||
"in" => Kw::In,
|
"in" => Kw::In,
|
||||||
|
"return" => Kw::Return,
|
||||||
"alias" => Kw::Alias,
|
"alias" => Kw::Alias,
|
||||||
"type" => Kw::Type,
|
"type" => Kw::Type,
|
||||||
"Self" => Kw::SelfType,
|
"Self" => Kw::SelfType,
|
||||||
|
11
test.schala
11
test.schala
@ -42,17 +42,20 @@ fn main() {
|
|||||||
#iteration over a variable
|
#iteration over a variable
|
||||||
for i <- [1..1000] {
|
for i <- [1..1000] {
|
||||||
|
|
||||||
}
|
} #return type is return type of block
|
||||||
|
|
||||||
#while loop
|
#while loop
|
||||||
for a != 3 || fuckTard() {
|
for a != 3 || fuckTard() {
|
||||||
break
|
break
|
||||||
}
|
} #return type is return type of block
|
||||||
|
|
||||||
#monadic decomposition
|
#monadic decomposition
|
||||||
for a <- maybeInt(); s <- foo() {
|
for {
|
||||||
|
a <- maybeInt();
|
||||||
|
s <- foo()
|
||||||
|
} return {
|
||||||
a + s
|
a + s
|
||||||
}
|
} #return type is Monad<return type of block>
|
||||||
|
|
||||||
# let statements too!!
|
# let statements too!!
|
||||||
for (a = 20
|
for (a = 20
|
||||||
|
Loading…
Reference in New Issue
Block a user