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
| PrimeGenerator: { | |
| return [idx] { | |
| .cache: .cache? || @ | |
| cached: .cache(idx) | |
| return cached if cached | |
| max: .cache.last || 2 | |
| is_prime: [n] { |
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
| PrimeGenerator for new, experimental Snow syntax | |
| -------------8<----------------- | |
| PrimeGenerator: { | |
| return [idx] { | |
| .cache: .cache? || @() | |
| cached: .cache(idx) | |
| return cached if cached |
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
| SomeGenericClass: class(ThePrototype) { | |
| .initialize: [a] { | |
| .a: a | |
| } | |
| .attribute("attr", get: { .a }, set: { .a: it }) | |
| // Maybe this? | |
| .attribute("a", get: { .get_member("a") }, set: { .set_member("a", it) }) | |
| } |
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() { | |
| .attribute("bar", get: { [z]{print(z)} }) | |
| } | |
| foo: Foo() | |
| foo.bar(123) //=> output "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
| /* | |
| Snow Private Methods | |
| */ | |
| SomeClass: class() { | |
| private_method: [arg] { | |
| print(arg) | |
| } | |
| .initialize: [arg] { |
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
| tIDENTIFIER = tNORMAL_IDENTIFIER | tOPERATOR_IDENTIFIER | |
| tNORMAL_IDENTIFIER = [\w][\w\d*]* | |
| tOPERATOR_IDENTIFIER = [\+\-\*\/\\]* | |
| tOPERATOR_CALL = tIDENTIFIER tIDENTIFIER tIDENTIFIER | |
| tNORMAL_CALL = tIDENTIFIER tDOT tSTART_PAREN tARG_LIST tEND_PAREN | |
| tEXPR = ... | ... | tOPERATOR_CALL | tNORMAL_CALL | ... | ... |
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
| SomeClass: class() { | |
| .initialize: { ... } | |
| } | |
| foo: SomeClass() | |
| bar: SomeClass() | |
| foo.lol: { print "HELLO" } | |
| bar.lol() // => ERROR | |
| foo.lol() // => "HELLO" |
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
| Mutexed: class { | |
| .initialize: [closure] { | |
| .closure: closure | |
| .mutex: Mutex | |
| } | |
| .(): [*args] { | |
| .mutex.lock | |
| .closure(*args) | |
| .mutex.unlock |
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
| window: Window("Test") { | |
| .button1: Button("Lol") { print "HELLO WORLD" } | |
| } | |
| window.show | |
| window.button1.click | |
| window.on_close << { print ":(" } |
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 whatever(Object* raw_ptr) { | |
| Handle<Object> ptr = raw_ptr; // bookkeeping pointer | |
| ptr->lals(); | |
| return; | |
| // ptr destroyed, book kept | |
| } |