Skip to content

Commit

Permalink
make record types first-class only (not sure if it is good idea)
Browse files Browse the repository at this point in the history
  • Loading branch information
yinwang0 committed Feb 3, 2014
1 parent cd26b6d commit 3ae9359
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/yinwang/yin/ast/RecordDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public Value interp(Scope s) {
}
}

Value r = new RecordType(name.id, this, properties);
s.putValue(name.id, r);
return Value.VOID;
return new RecordType(name.id, this, properties);
}


Expand Down
26 changes: 18 additions & 8 deletions tests/types3.yin
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
-- (define f
-- (fun (x y)
-- (declare [x :type Int :default 1]
-- [y :type Bool :default true])
-- [x y]))


(define f
(fun (x y)
-- (declare [x :type Int :default 1]
-- [y :type Bool :default true])
(fun ([x :type Int :default 10]
[y :type Bool :default true])
[x y]))

(f :y 1 :x 2)
(f :x 20 :y false)


-- (record A
-- [x :type Int :default (+ 1 2)]
-- [y :type Bool :default true])
(define aa
(seq
(define x 1)
(record A
[x :type Int :default (+ x 2)]
[y :type Bool])))

-- (A :x 10 :y false :z 12)
(define x 10)
(aa :y 20)

0 comments on commit 3ae9359

Please sign in to comment.