[m-dev.] record syntax

David Overton dmo at hydra.cs.mu.oz.au
Wed Feb 23 16:55:14 AEDT 2000


On Wed, Feb 23, 2000 at 04:17:00PM +1100, Thomas Conway wrote:
> Hi
> 
> I've just been fiddling with record syntax, and it doesn't quite
> do what I want, so I need someone to convince me to do it a *better*
> way. ;-)
> 

[...]

> So, I'd like to write:
> 
> :- type ppid
> 	--->	pred(modname::string, name::string, arity::int, modenum::int)
> 	;	func(modname::string, name::string, arity::int, modenum::int)
> 	;	comp(typemod::string, typename::string,
> 			modname::string, name::string, arity::int, modenum::int)
> 	.

[...]

> Comments?

Here's one way you could achieve this interface to the ppid type with
the current system, with just a bit more typing and slightly less
efficiency:

	:- type ppid
		--->	ppid(
				ppid_2 :: ppid_2,
				modname :: string,
				predname :: string,
				arity :: int,
				modenum :: int
			).

	:- type ppid_2
		--->	pred
		;	func
		;	comp(typemod_2::string, typename_2::string).

	:- func typemod(ppid) = string is semidet.
	:- func 'typemod:='(ppid, string) = ppid is semidet.
	:- func typename(ppid) = string is semidet.
	:- func 'typename:='(ppid, string) = ppid is semidet.

	typemod(PPID) = PPID^ppid_2^typemod_2.
	'typemod:='(PPID, Mod) = PPID^ppid_2^typemod_2 := Mod.
	typename(PPID) = PPID^ppid_2^typename_2.
	'typemod:='(PPID, Name) = PPID^ppid_2^typename_2 := Name.

Of course, I agree that what you're proposing would be much nicer.


David
-- 
David Overton       Department of Computer Science & Software Engineering
PhD Student         The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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