[m-dev.] foreign type syntax

Peter Schachte schachte at cs.mu.OZ.AU
Mon Oct 29 16:59:01 AEDT 2001


On Thu, Oct 25, 2001 at 10:13:57PM +1000, Fergus Henderson wrote:
> On 25-Oct-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> I think it would be nicer to just use whatever syntax the foreign language
> uses.

A few problems with this:

     o	As Tyson said, the foreign language may not have the concept of type
	declarations.

     o	The foreign language may not make the same distinctions Mercury
	wants to, such as between a pointer to a thing and a pointer to an
	array of things.

     o	The choice of language and platform does not determine the layout of
	the structure.  Eg, different C implementations could use different
	alignment rules.  In C++ it's completely hopeless.  If you're just
	generating back end code to access data members, I guess this
	shouldn't be a problem.

     o	It would be good if it were possible to somehow have a d.u. Mercury
	type corresponding to an ordinary foreign type.  Eg, maybe you could
	specify than an enum data member of a struct indicated which member
	of a union in the same struct was present, or that a long at the
	front of a string indicates how long the string is.  That might be a
	tall order, but a flexible Mercury-oriented syntax at least leaves
	open that possibility.  Restricting yourself to the foreign
	language's syntax removes that possibility (unless you come up with
	some creaky annotations put in comments or something similarly ugly).


-- 
Peter Schachte              Many men stumble across the truth, but most
schachte at cs.mu.OZ.AU        manage to pick themselves up and continue as if
www.cs.mu.oz.au/~schachte/  nothing had happened.
Phone: +61 3 8344 9166          -- Winston Churchill 
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list