Received: from mail5.microsoft.com (INET-VRS-05 [157.54.7.195]) by
 inet-imc-05.microsoft.com with SMTP (Microsoft Exchange Internet Mail Service
 Version 5.5.2650.21) id X64QT1DW; Mon, 29 Nov 1999 11:01:04 -0800
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Received: from 144.32.40.9 by mail5.microsoft.com (InterScan E-Mail VirusWall
 NT); Mon, 29 Nov 1999 11:01:00 -0800 (Pacific Standard Time)
X-Mailer: Microsoft Outlook, Build 10.0.2627
X-MimeOLE: Produced By Microsoft Exchange V6.0.6177.0
X-MS-TNEF-Correlator: <swordfish.943902061@cs.york.ac.uk>
x-olkeid: D724812074AE94027DF32746A074642692B648F6
content-class: urn:content-classes:message
Subject: Re: FFI library proposal, 1st shot
Date: Mon, 29 Nov 1999 19:57:27 +0100
Message-ID: <swordfish.943902061@cs.york.ac.uk>
X-MS-Has-Attach: 
Thread-Topic: FFI library proposal, 1st shot
Thread-Index: Ab86nBXvRmHHMHvrTr+Re19NYQufrw==
From: "Malcolm Wallace" <Malcolm.Wallace@cs.york.ac.uk>
To: "Sven Panne" <Sven.Panne@informatik.uni-muenchen.de>
Cc: "Simon Peyton-Jones" <simonpj@microsoft.com>,
	<Simon Marlow>,
	<Sigbjorn Finne>,
	<Michael.Weber@Post.RWTH-Aachen.DE>,
	"Julian Seward (Intl Vendor)" <v-julsew@microsoft.com>,
	<andy@cse.ogi.edu>,
	<erik@cs.uu.nl>,
	<chak@is.tsukuba.ac.jp>

>    * The type of the second argument of makeForeignObj (the finalizer)
>      has been changed from Addr to IO (). This is more consistent and
>      IMHO Addr is a hack here.

I liked it better before :-( as
    makeForeignObj :: Addr -> Addr -> IO ForeignObj
I would guess that the motivation to make the "finalizer" argument of
type IO () is that you want to write finalizers in Haskell.
Personally, I like to use the C finalizer, because if I'm importing the
value itself as an opaque type, then why not simply use the finalizer
code opaquely too?  In any case, the C finalizer has type
    void finalizer(real_c_type_for_foreign_obj);
Surely if you have this finalizer in the Haskell world, its type
must be something like the following?
    finalizer :: Addr -> IO ()
rather than
    finalizer :: IO ()
So we should really have
    makeForeignObj :: Addr -> (Addr->IO ()) -> IO ForeignObj
    writeForeignFinalizer :: ForeignObj -> (Addr->IO ()) -> IO ()
no?


> To finish the first round, I'd like to make a quick poll: Should
> stable names be mandatory for the new FFI libs or not?

I haven't got any immediate use for stable names, so I would vote to
exclude them (for simplicity) until they are better understood.

>    * The mapping of StablePtr to a C type.

I go with Manuel's (void*).

>    * Should addresses on the Haskell side be parameterized by the
>      type of the object they point to? How exactly should they be
>      mapped to C types?

Yes, I go with (Ptr a).  For simplicity, I think there should be no
compiler-supported mapping to C-types at this stage.
[  In earlier discussions, we thought it would be nice to have
   Ptr Char  -->  char*  and so on.  However, you can quickly run
   into tricky cases once the types become more complex, e.g.
   Ptr (a -> IO a)  ->  void**()(void*)
]

>    * Are the lifetime rules for ForeignObj (section 2.4 of the FFI
>      document) satisfying?

I'm still not sure that I fully understand the difficulties with
ForeignObj finalisation in systems other than nhc98, so I'm reasonably
happy with the current (minimal) rules.

Regards,
    Malcolm
