[racket-dev] A Const type constructor

From: Neil Toronto (neil.toronto at gmail.com)
Date: Wed Jul 25 13:31:23 EDT 2012

On 07/25/2012 10:26 AM, Sam Tobin-Hochstadt wrote:
> On Wed, Jul 25, 2012 at 9:29 AM, Neil Toronto <neil.toronto at gmail.com> wrote:
>> After thinking about it, I don't want an Immutable-Vector type, for which v
>> : Immutable-Vector proves (immutable? v) is #t. That would be seriously
>> annoying to users of a vector library.
>>
>> What if TR had a notion of const-ness, like in C? Suppose (Vectorof A) is a
>> subtype of (Const-Vectorof B) when A is a subtype of B, and (Const-Vectorof
>> A) is never a subtype of (Vectorof B).
>
> How exactly are these different?  An immutable vector is a vector, but
> could be covariant, which seems like what you want. However, a mutable
> vector can't be treated as an immutable vector.

I don't want to tell Typed Racket "This vector's values never change." I 
want to tell it "Code in this scope never changes this vector's values." 
That's why I called it "const" instead of "immutable".

Neil ⊥


Posted on the dev mailing list.