[racket-dev] enum returns #f on c->racket no match?

From: John Clements (clements at brinckerhoff.org)
Date: Mon Nov 15 18:02:06 EST 2010

The documentation for '_enum" says this:

3.8 Enumerations and Masks

Although the constructors below are describes as procedures, they are implemented as syntax, so that error messages can report a type name where the syntactic context implies one.

(_enum symbols [basetype]) → ctype?
  symbols : list?
  basetype : ctype? = _ufixint
Takes a list of symbols and generates an enumeration type. The enumeration maps between a symbol in the given symbols list and corresponding integers, counting from0.
The list symbols can also set the values of symbols by putting '= and an exact integer after the symbol. For example, the list '(x y = 10 z) maps 'x to 0, 'y to 10, and 'z to11.

The basetype argument specifies the base type to use.

This says nothing about what happens when using racket->C on a symbol that's not mentioned by the enumeration, or what happens when using C->racket on a number that's not mentioned in the enumeration. 

Based on my tests, it appears that the conversion signals an error in the racket->C direction, but simply returns #f in the C->racket direction.  

Should I document the current behavior, or would it make more sense to change it to signal an error rather than returning #f?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20101115/0222c16e/attachment.p7s>

Posted on the dev mailing list.