[m-rev.] fix lcc type errors in hlc grades

Simon Taylor stayl at cs.mu.OZ.AU
Mon Aug 18 00:31:48 AEST 2003


On 18-Aug-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> library/time.m:
> 	Fix an old XXX about representing time_t as a int: use a pragma
> 	foreign_type instead.  Then wrap this in a no-tag type,
> 	to avoid making time.time_t an abstract foreign_type.

> Index: library/time.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/time.m,v
> retrieving revision 1.34
> diff -u -d -r1.34 time.m
> --- library/time.m	29 May 2003 12:08:26 -0000	1.34
> +++ library/time.m	17 Aug 2003 13:48:08 -0000
> @@ -200,6 +196,21 @@
>  	#include ""mercury_string.h"" /* for MR_make_aligned_string_copy() */
>  ").
>  
> +% We use a no-tag wrapper type for time_t, rather than defining it as an
> +% equivalence type or just using a d.u./pragma foreign_type directly,
> +% to avoid the following problems:
> +%
> +%	- type errors in --high-level-code grades, due to the caller seeing
> +%	  the abstract type, but the callee seeing the equivalence type
> +%	  definition or the foreign_type definition.
> +%
> +%	- users can't define instance declarations for abstract equiv. types.
> +%
> +:- type time_t ---> time_t(time_t_rep).
> +
> +:- type time_t_rep ---> time_t_rep(c_pointer).
> +:- pragma foreign_type("C", time_t_rep, "time_t").

You should implement equality and comparison for time_t_rep.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list