[m-dev.] diff: cleanup of tabling

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jan 4 09:19:04 AEDT 2000


On 03-Jan-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> Fergus has reviewed my previous diff, and I have applied all his suggestions
> except the few we have discussed. However, in the meantime I have also added
> several new test cases and fixed the bugs they detected, switched to the
> use of a textbook separate chaining technique, and made the hash table
> implementation type-safe. Someone may therefore wish to look this over,
> although it is not necessary. This diff passes bootcheck, including all the
> tough new test cases, and I have committed it.

It would be nice if you could post relative diffs in cases like this.

library/io.m:
> +	% Write statistics about the operation of the tabling system to stderr.
> +
> +:- pred io__report_tabling_stats(io__state, io__state).
> +:- mode io__report_tabling_stats(di, uo) is det.

Hmm... tabling is an implementation-specific extension
(it's listed in the "implementation-dependent extensions"
chapter of the Mercury language reference manual).
Given that, I don't think that it is a good idea to include
features in the standard library that only make sense in
the presence of tabling.

> +#ifdef	MR_TABLE_STATISTICS
> +  #define declare_probe_count	Integer	probe_count = 0;
> +  #define record_probe_count	do { probe_count++; } while (0)
> +  #define record_lookup_count	do {					      \
> +					MR_table_hash_lookup_probes +=	      \
> +						probe_count;		      \
> +					MR_table_hash_lookups++;	      \
> +				} while (0)
> +  #define record_insert_count	do {					      \
> +					MR_table_hash_insert_probes +=	      \
> +						probe_count;		      \
> +					MR_table_hash_inserts++;	      \
> +				} while (0)
> +  #define record_resize_count	do { MR_table_hash_resizes++; } while (0)
> +  #define record_alloc_count	do { MR_table_hash_allocs++; } while (0)
> +#else
> +  #define declare_probe_count
> +  #define record_probe_count	((void) 0)
> +  #define record_lookup_count	((void) 0)
> +  #define record_insert_count	((void) 0)
> +  #define record_resize_count	((void) 0)
> +  #define record_alloc_count	((void) 0)
> +#endif

It would be better to use function-like macros,
e.g. `record_probe_count()' rather than `record_probe_count'.
Also the `declare_probe_count' macro should be in upper case,
since it is not a function-like macro.

> +#define	hash(key)		(hash_float(key))
> +#define	equal_keys(k1, k2)	(k1 == k2)

Using `==' to compare floats could cause problems with NaNs.
That is probably worth at least an XXX comment.

> +#undef	hash(key)
> +#undef	equal_keys(k1, k2)

That's a syntax error; it should be just `#undef hash',
not `#undef hash(key)'.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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