[m-rev.] for review: refactor mlds_to_il.m

Tyson Dowd trd at cs.mu.OZ.AU
Wed Jul 11 19:33:13 AEST 2001


On 11-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 10-Jul-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > 
> > +++ compiler/ml_elim_nested.m	10 Jul 2001 14:45:39 -0000
> > @@ -373,13 +373,22 @@
> >  	EnvTypeEntityName = type(EnvClassName, 0),
> >  	EnvTypeFlags = env_type_decl_flags,
> >  	Fields = list__map(convert_local_to_field, LocalVars),
> > +
> > +		% IL uses classes instead of structs, so the code
> > +		% generated needs to be a little different.
> > +		% XXX Perhaps if we used value classes this could go
> > +		% away.
> > +	globals__get_target(Globals, Target),
> >  	( Target = il ->
> > +			% Generate a ctor for the class which
> > +			% initilaises the commit field.
> 
> s/initilaises/initializes/
> 
> I don't understand what you mean by "the commit field".
> *What* commit field?  Why should there be any commit field???
> 
> Oh, I had a look at the code that mlds_to_il generates for commits.
> Now I finally understand what you're trying to do.
> But unless I'm wildly mistaken, the code you have here is quite wrong.
> 
> For some odd reason the code in mlds_to_il uses the "Ref" argument to
> do_commit as the value to throw.  This is both wierd and inefficient.
> I don't know why it is done that way; maybe it is because the person
> who wrote it didn't understand what the "Ref" argument was intended for,
> and didn't read or didn't understand the documentation in ml_code_gen.m
> about how to map do_commit/try_commit to exception handling.

I certainly didn't understand it -- as far as I can see the only
documentation on how to use try/catch for commits is:


%       model_non in semi context: (using catch/throw)
%               <succeeded = Goal>
%       ===>
%               void success() {
%                       throw COMMIT;
%               }
%               try {
%                       <Goal && success()>
%                       succeeded = FALSE;
%               } catch (COMMIT) {
%                       succeeded = TRUE;
%               }

The documentation doesn't say what COMMIT is and I assumed it must be Ref.

There is also no documentation explaining what Ref is (except that it
has type mlds__commit type).


> The Ref argument is supposed to hold information about where to resume
> execution, but for the .NET port the exception handling mechanism
> takes care of that.  So there's really no need to use the Ref argument
> at all.

It would be REALLY NICE if this information was somewhere
like mlds.m or ml_code_gen.m.

> Of course you do need an object to throw.  The simplest thing would
> be to allocate a new object in the do_commit instruction.  But a more
> efficient way would be to have a single such object defined in the
> Mercury runtime, allocated by the Mercury runtime startup code, and to
> always throw that one.

This is helpful too, thanks.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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