We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The for { T => ; } statement can be used in an adt[T] as well.
for { T => ; }
From qrstuv on #inferno:
implement Dongmap; include "sys.m"; sys: Sys; include "draw.m"; Dongmap: module { init: fn(nil: ref Draw->Context, nil: list of string); }; Map: adt[K, V] for { K => hash: fn(nil: self K): int; } { # ← This right here v: V; add: fn(nil: self ref Map[K, V], key: K, val: V); find: fn(nil: self ref Map[K, V], key: K): V; }; Wang: adt { hash: fn(nil: self ref Wang): int; }; WingDingDingaling: adt { sz: int; }; Map[K, V].add(m: self ref Map[K, V], key: K, val: V) { m.v = val; } Map[K, V].find(m: self ref Map[K, V], key: K): V { return m.v; } Wang.hash(nil: self ref Wang): int { return 69105; } init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; m := ref Map[ref Wang, ref WingDingDingaling](ref WingDingDingaling(2)); m.add(ref Wang, ref WingDingDingaling(10)); sys->print("%d\n", m.find(ref Wang).sz); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The
for { T => ; }
statement can be used in an adt[T] as well.From qrstuv on #inferno:
The text was updated successfully, but these errors were encountered: