[m-rev.] for review: improve MC++ support

Tyson Dowd trd at cs.mu.OZ.AU
Sat Jun 1 09:34:32 AEST 2002


On 27-May-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Sat, May 25, 2002 at 10:59:47AM +1000, Tyson Dowd wrote:
> > If you have to give initial values for Mercury output variables then
> > this needs a small amount of documentation.
> > 
> It is not for all output variables, it is only for conditions like that
> follows.

While the example shows the problem it doesn't tell me what conditions I
have to initialize X under.

If the condition can be specified precisely, why can't the Mercury
compiler automatically generate initializers for these variables?

> 
> :- pragma foreign_proc("C#", f(X::out), "
>     func(ref X);
> ").
> 
> We used to generate the following C# code
> 
> f_1(ref int X)
> {
>     func(ref X);
> }
> 
> now we generate this
> 
> f_1(ref int X_1)
> {
>     f(ref X);
>     X_1 = X;
> }
> 
> so the C# compiler complains about X not having an intial value.  This
> could have been solved if we declared func to be func(out int x)
> instead.

Well we could do that.  Or we could initialize it ourselves.

> 
> Do you still think that this should be documented somewhere? If so
> where?

If the problem can't be solved then yes. But probably better to just fix
it, it looks like we could generate the appropriate initializers for
output arguments outselves (there are only a couple of data types to
generate initializers for and all most all of them can be initialized
with 0 or null I think).

It would have to be documented in the foreign language interfacing
section that describes the C# interface.

> The mode name will probably end up being in_managed_lang so I don't
> think it buys us anything.

Just a suggestion doesn't really matter.

Tyson.
--------------------------------------------------------------------------
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