On Wed, Mar 12, 2008 at 06:17:36PM -0400, Swaroop Sridhar wrote:
> Sam Mason wrote:
> > One thing I haven't noticed is about introducing a simple operator:
> > 
> >   (fn (mutable 'a) (by-ref (mutable 'a)))
> 
> Is this a type annotation for functions?  If so, do you mean to say that
> this is a function accepting two arguments one by value and the other by
> reference? (note that nothing can be returned by reference).

No, it's a special operator that only the compiler could provide because
it returns a by-ref.  For example:

  (proclaim asref : (fn (mutable 'a) (by-ref (mutable 'a))))

  (define (inc (x : (by-ref (mutable int32))))
    (set! x (+ x 1)))

  (define (f (x))
    (inc (asref x))
    x)

I'm having trouble with the Lisp syntax, was that right?

If this function existed, then you'd never want to allow the compiler to
infer a by-ref to a mutable object.  It would probably also want to get
a nicer name/symbol.

> So, are you suggesting that if we write (by-ref 'a), where 'a cannot
> unify with a mutable type? This cannot be the case since the type
> variable must be able to unify with any type.

Yes, and that's why it's all a bit nasty.  This is still all coming from
a comment a long time ago that's stuck in my head about auditing and
seems to have taken on a life of its own.


  Sam
_______________________________________________
bitc-dev mailing list
bitc-dev@coyotos.org
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to