[m-dev.] for review: new module for handling file offsets

Peter Schachte schachte at cs.mu.OZ.AU
Tue Mar 9 14:41:40 AEDT 1999


On Tue, Mar 09, 1999 at 12:43:08PM +1100, Fergus Henderson wrote:
> On 09-Mar-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> > Peter Schachte wrote:
> > > Therefore, I suggest adding a `file_region' type to this module
> > 
> > I don't really see a need for this. A file_region is nothing more than
> > a pair of line_columns, and surely the callers of this module can handle that
> > themselves.
> 
> In this particular case it would be more efficient for the pair
> of line_columns to be unfolded into the term__contexts, rather than the
> term_contexts containing a pointer to a pair.
> So I vote with Zoltan on this one ;-)

I thought Mercury could do structure unfolding (untupling) now, no?
If not, that might be a good reason to implement regions as a separate
datatype:  it'll add another motivation to implement untupling, which
would be useful in all sorts of contexts.

In any case, it might be worth considering packing a whole region into
a single int (18 bits for region start and 14 for size would allow for
256K byte files and 16K byte regions, which would almost always be
enough for human-written code; on 64 bit machines there's plenty of
room).  Of course, if you store the region as two separate ints, then
you can't do that, so from the standpoint of efficiency, the separate
type could be better.

The point is really that this is notionally a separate abstract
datatype with a few well defined operations, and so it should be
implemented that way.  Once it's implemented throughout the system as
pairs of ints that happen to travel and be stored together, it's too
late to define it properly or experiment with different
representations.  It might even be a good idea to make it a type
class, so it could store multiple disjoint regions, or have a
secondary region in cases where two things conflict.

-- 
Peter Schachte                     Hofstadter's Law: It always takes longer
mailto:schachte at cs.mu.OZ.AU        than you expect, even when you take
http://www.cs.mu.oz.au/~schachte/  Hofstadter's Law into account. 
PGP: finger schachte at 128.250.37.3  



More information about the developers mailing list