Adventures in tearing: type creation and access in Wat

28 views
Skip to first unread message

Michael Fogus

unread,
Aug 7, 2012, 8:12:55 PM8/7/12
to ll-...@googlegroups.com
Manuel Simoni's language Wat[1] defines a way to define a type in the
following way:

(def (type-tag type-creator type-accessor) (make-type))

Where the `make-type` function returns a triplet described by the
names above. The interesting part about this is that it separates
creation from access allowing one to limit access to one aspect or
both using ad hoc encapsulation mechanisms. This very much in the
spirit of Scheme in that it provides a very clean and powerful core
for programmers to experiment. Additionally, it is a very clever
extension to Scheme that seems fairly obvious in hindsight.

Mr. Simoni talks more about this capability in his blog post at
http://axisofeval.blogspot.com/2012/08/schemes-missing-ingredient.html

Thoughts?

Sam Tobin-Hochstadt

unread,
Aug 7, 2012, 10:59:52 PM8/7/12
to ll-...@googlegroups.com
This is very similar to the structure creation mechanism in Racket,
called `make-struct-type` [1]. This also separates creators,
predicates, accessors and mutators, while also providing a reflection
mechanism [2] that can be selectively controlled [3].

I think the more interesting aspect of Manuel's design is that
built-in data structures can be reflectively examined, and their type
tags extracted.

Sam

[1] http://docs.racket-lang.org/reference/creatingmorestructs.html
[2] http://docs.racket-lang.org/reference/inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-info%29%29
[3] http://docs.racket-lang.org/reference/inspectors.html
--
sam th
sa...@ccs.neu.edu
Reply all
Reply to author
Forward
0 new messages