[m-rev.] for review: parser.m profiling

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 14 23:44:59 AEDT 2003


On 14-Mar-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> library/parser.m:
> 	Consistently use get and set functions to access the components
> 	of the parser state. This allows deep profiling to count how many
> 	times each component is accessed. However, make all these functions
> 	inlined by default, for performance.

Hmm.  The same issue could arise for any structure in any program, right?

I think it might be better to just change parser.m to use field notation
to access the fields, and then add an option to the compiler to have all
field access go via automatically-generated field access functions.
This option could be useful for both profiling and for debugging.

The advantage of this approach is that the source code remains a lot
simpler.  Defining explicit field access functions requires an extra
half a dozen lines of code or so per field:

	:- pragma inline(mytype_get_foo/1).
	:- func mytype_get_foo(mytype) = foo.
	mytype_get_foo(MyType) = MyType^foo.

	:- pragma inline(mytype_set_foo/2).
	:- func mytype_set_foo(mytype, foo) = mytype.
	mytype_set_foo(MyType, Foo) = (MyType^foo := Foo).

OK, you could probably safely drop the `pragma inline' -- I don't think
the compiler will get that wrong.  But even so, there's still quite
a bit of unnecessary extra guff in the source code that would need to
be defined every time you add a new field.  Furthermore, you then need to
remember to use `mytype_set_foo' rather than `^foo :='.

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