vile / scheme / testdata / frontends / records.vile
21 lines · 21 sloc · 838 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1define-record-type(cell, make-cell(value), cell?, value(cell-value,set-cell-value!))
2c := make-cell(20)
3alias := c
4set-cell-value!(alias,21)
5import(prefix((rnrs,records,syntactic),r:))
6r:define-record-type(base, r:fields(r:mutable(x)))
7r:define-record-type(child, r:parent(base), r:fields(y),
8 r:protocol(fn(parent){fn(x,y){parent(x+1)(y+2)}}))
9inherited := make-child(19,20)
10base-x-set!(inherited,21)
11define-syntax(publish, syntax-rules((),
12 ((_,name), {
13 define-record-type(hidden,fields(value))
14 name(n) := hidden-value(make-hidden(n))
15 })))
16publish(first)
17publish(second)
18list(cell?(alias), cell-value(c), base?(inherited), child?(inherited),
19 base-x(inherited), child-y(inherited),
20 record-type-name(record-type-parent(record-type-descriptor(child))),
21 let((make-hidden(#f),hidden-value(#f)),list(first(20),second(22))))
22