[m-rev.] for review: item sequence numbers

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jul 28 16:42:12 AEST 2008


On Mon, 28 Jul 2008, Zoltan Somogyi wrote:

> Add a sequence number to the information we collect for each kind of item.
> The purpose of this is to prepare for a later change that will switch from
> representing the stuff we read in from a file as a list of items to
> representing it is a data structure that groups all items of a given kind
> together. This will lose the original order of the items. The sequence number
> will allow us to recreate it if necessary, e.g. for pretty-printing.
>
> compiler/prog_item.m:
> 	Add the sequence number field to the information we have about each
> 	kind of item.
>
> compiler/prog_io.m:
> compiler/prog_io_dcg.m:
> compiler/prog_io_pragma.m:
> compiler/prog_io_typeclass.m:
> 	Add code to generate the item sequence numbers.
>
> 	In prog_io.m, change some predicates that used to return an
> 	intermediate type such as processed_type_body to make them return
> 	an item, since this simplifies adding sequence numbers; it also
> 	simplifies the code in general and reduces memory allocation.
>
> 	Rename some uninformatively-named variables that I missed in my last
> 	diff.
>
> compiler/*.m:
> 	Minor changes to conform to the above. Mostly this involves either
> 	ignoring the seqnum field, or copying it when an item is updated.

An alternative to this change would be to store the sequence number
in the `user' constructor of the item_origin type.  (This would also
mean adding an origin field to those items that don't already have one.)

The above is likely to be clearer although less efficient when, for
example, attempting to reconstruct the original order of items.
As such, I'm not particularly fussed about which approach is used.

The diff looks fine.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list