[bitc-dev] Mutability
Swaroop Sridhar
swaroop at cs.jhu.edu
Mon May 22 19:17:26 EDT 2006
Swaroop Sridhar wrote:
> iii) The issue we came across for literals wrt mutability is actually
> true for all constructors in general. If I write:
>
> (define x:(mutable t) T)
>
> then, x is a mutable value of type (mutable t) constructed from T the
> constructor for type t.
>
To be a little more explicit here, what I am saying here is that we
should probably reconsider the use of typeclasses to deal with
mutability. Otherwise, every type will have its own type class that
qualifies the value constructors of that type (literals being a special
case).
That is,
(defunion t T) is the same as writing :
(deftypeclass (__class_t 'a))
(definstance (__class_t t))
(definstance (__class_t (mutable t)))
;; class closed here because no input of an identifier beginning
;; with __ is possible.
(forall ((__class_t 'a)) (defunion (t 'a) T))
And,
(define (f) T) will be typed as:
f: (forall ((__class_t 'a)) (fn () (t 'a)))
rather than
f: (fn () t)
and, depending on the mutability restriction for return types,
(set! (f) T) will be OK, which is probably not what the user had intended.
Swaroop.
More information about the bitc-dev
mailing list