Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/4d4020315e21fe39b0fa to your computer and use it in GitHub Desktop.
Save rightfold/4d4020315e21fe39b0fa to your computer and use it in GitHub Desktop.
meth f a b : int // dispatch based on runtime type of a and b
interface baseOfTAndV
f _ baseOfUAndW
end
interface baseOfUAndW
f baseOfTAndV _
end
struct T; end
struct U; end
struct V; end
struct W; end
impl f (a: T) (b: U) : int; …; end
impl f (a: V) (b: W) : int; …; end
var a: baseOfTAndV = random [makeT!, makeV!]
var b: baseOfUAndW = random [makeU!, makeW!]
f a b // error; f T W and f U V not implemented
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment