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
package main | |
import "errors" | |
func actionOk() (int, error) { | |
return 1, nil | |
} | |
func actionErr() (int, error) { | |
return 0, errors.New("err") |
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
// testing place | |
http://egonelbre.com/js/bigram/ | |
// test input | |
a = c ? t + 4 : f + 3 ? a : b | |
// replace the tokens on the right side with these: | |
// version: C ?( T ): F |
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
// V1 | |
public class Foo { | |
} | |
public class KungFoo extends Foo { | |
public KungFoo(string owner){ | |
// ... | |
} | |
} |
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
function Machine(first, $){ | |
var cur = {}, next = $[first]; | |
var self = { | |
go : function(to){ next = next ? next : ($[to] || $.undefined); }, | |
trigger : function(event){ var t = cur.tx && cur.tx[event]; t && self.go(t); } | |
}; | |
return function(){ | |
if(next){ | |
cur.exit && cur.exit.call(self); | |
cur = next; next = undefined; |
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
function Machine(first, $){ | |
var cur = {}, next = $[first]; | |
var self = { | |
go : function(to){ next = next ? next : ($[to] || $.undefined); }, | |
trigger : function(event){ var t = cur.tx && cur.tx[event]; t && self.go(t); } | |
}; | |
return function(){ | |
if(next){ | |
cur.exit && cur.exit.call(self); | |
cur = next; next = undefined; |
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
function Interface(decl){ | |
this.decl = decl; | |
this.impl = {}; // map funcname -> type | |
} | |
Interface.prototype = { | |
check : function(typedef){ | |
if(typedef.uuid === undefined){ | |
typedef.uuid = GenerateGloballyUniqueId(); | |
} |
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
function sayExt(obj){ | |
return obj.say(); | |
} | |
Zoo = Context(function(player){ | |
Lion = Role({ | |
say : function(){ return 'meow'; } | |
}); | |
function sayInt(obj){ |
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
// allows easily making an Actor with a Role | |
// if it's already an actor the context will be attached. | |
Object.defineProperty(Object.prototype, "as", {enumerable: false, value : function(role){ | |
// this will add a role to the object | |
if(this.__isActor__) { | |
this.__addRole__(role); | |
return this; | |
} | |
// if this is not an actor - |
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
public class Battle<LionPlayer, BearPlayer> { | |
private LionPlayer Lion; | |
private BearPlayer Bear; | |
private void Lion$fight(){ | |
System.out.println(Lion.getName() + ": meow..."); | |
}; | |
private void Bear$fight(){ | |
System.out.println(Bear.getName() + ": grrr..."); |
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
Battle = Context(function(bearPlayer, lionPlayer){ | |
Bear = bearPlayer; | |
Lion = lionPlayer; | |
Bear.fight(); | |
Lion.touch(); | |
Lion.fight(); | |
},{ | |
Lion : { | |
fight : function(){ | |
console.log(this.name + " : meow"); |