[racket] proposal for variant types

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Tue Jun 11 10:06:09 EDT 2013

Hi Stephan,

Thanks for the feedback. 

The tradeoff with your suggestion is the error messages:

> (expr)
. expr: bad syntax;
 identifier for static struct-type information cannot be used as an expression in: (expr)

as opposed to:

> (expr)
. . cannot construct value of type expr: use one of the variants (num add sub)

I'm pretty sure my students would be more at ease with the latter version. (and to be honest, it took me more time to make sense of the former too)


-- Éric

On Jun 11, 2013, at 3:44 AM, Stephan Houben <stephanh42 at gmail.com> wrote:

> Hi Eric,
> I like it!
> One thing though: instead of adding a guard which forbids use of the constructor,
> what about simply hiding the constructor , like this:
> (define-syntax-rule (define-type t (variant vfield ...) ...)
>   (begin
>     (struct t () #:transparent #:constructor-name ?dummy)

Posted on the users mailing list.