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
| 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
| /* | |
| 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
| 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
| 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
| Foo: class { | |
| get_stuff: { /* do it */ } | |
| .property(#stuff, get_stuff, nil) | |
| } | |
| foo: Foo.new() | |
| foo.stuff // => get_stuff() | |
| foo.stuff: 2 // => ERROR |
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
| require("dlopen") | |
| Something: module { | |
| lib: dlopen("libsomething.dylib") | |
| .foo: lib.symbol("foo", INT, POINTER) | |
| .bar: lib.symbol("bar", POINTER) | |
| } | |
| ptr: Something.bar() |
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> | |
| #include <dlfcn.h> | |
| extern "C" int foo() { | |
| puts("LOOOOOL"); | |
| } | |
| int main() { | |
| void* handle = dlopen(NULL, RTLD_NOW); | |
| int(*my_foo)() = dlsym(handle, "foo"); |
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
| template <typename T> class Delegate; | |
| template <typaname T> class DelegateFunction; | |
| // Specialization for 2-argument callbacks: | |
| template <typename C, typename R, typename A1, typename A2> | |
| class DelegateMemberFunction : public DelegateFunction<R, A1, A2> { | |
| private: | |
| C* m_Instance; | |
| R (*m_Function)(A1, A2); | |
| public: |
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
| xml: XmlBuilder() | |
| xml { | |
| .root { | |
| .element1(attr: "hej") { | |
| .cdata("MUUUUH") | |
| } | |
| .element2(whatever: "lals") { | |
| .cdata("...") | |
| } |