This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add: [a, b] { | |
a + b | |
} | |
b: add(4, c) | |
c: add(5, 6) | |
sideeffect puts(c) | |
sideeffect puts(muh) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a: 0 | |
result: try { | |
8 / a | |
} | |
if result.error | |
// DivisionByZeroException, handle it... | |
else | |
puts(result.value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Why we need Continuations in Snow | |
*/ | |
ArticleController: controller { | |
.index: { | |
articles: Article.find(#all) | |
render(articles) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope_ext: Object.new() | |
scope_ext.lol: 123 | |
foo: { | |
puts(lol) | |
} | |
foo.inject_scope(scope_ext) | |
foo() // => "123" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
child: fork() | |
if !child | |
// this is the child process | |
while true | |
message: Process.message_queue.get_next() | |
// do something with the message | |
end | |
else | |
// this is the mother process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void foo() | |
{ | |
A a; | |
goto out; | |
B b; | |
out: | |
return; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct A { A() { printf("A()\n"); } ~A() { printf("~A()\n"); } }; | |
struct B { B() { printf("B()\n"); } ~B() { printf("~B()\n"); } }; | |
void foo(void* lbl) | |
{ | |
goto *lbl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func parse_function(input) | |
{ | |
return_type = parse_type(input) | |
name = parse_name_token(input) | |
parameters = parse_parameter_list(input) | |
body = parse_scope(input) | |
return new Function(return_type, name, parameters, body) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* simplified; no UNLESS. */ | |
conditional: IF expression EOL body EOL post_conditional { $$ = snow_ast_if_else($2, $4, $6); } | |
post_conditional: END | |
| ELSEIF expression EOL body EOL post_conditional { $$ = snow_ast_if_else($2, $4, $6); } | |
| ELSE body EOL { $$ = $2; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo: [a, b] { | |
a + b | |
} | |
foo(2, 3) // => 5 | |
ast: foo.ast.copy() | |
ast_addition: ast.children(0) | |
ast_call: ast_addition.children(0) | |
ast_call_target: ast_call.caller |