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

Tyson Dowd trd at cs.mu.OZ.AU
Mon Jun 10 14:41:19 AEST 2002


On 01-Jun-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Sat, Jun 01, 2002 at 09:34:32AM +1000, Tyson Dowd wrote:
> > 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).
> > 
> For any reference type you can initialise it to null, but for a value
> type what can you initialise it to?  Will zero work for any value type?

Oh sorry good point.

Microsoft's documentation says that good little C# programmers should
consider the default value of a value type to be a valid state.

But when handling ref parameters obviously they decided that it might
not be a valid state, unless the programmer explicitly sets it to that state.

So you have to call the default constructor.  Which will explicitly
intialize the value to the default value it has anyway.  But since you
are doing it it on purpose now the C# compiler shuts up.

Something like this:

struct bar {
	....
}


public static foo (ref bar X) {
	bar local_bar;
	local_bar = new bar();		// add this initializer

	X = local_bar;

}

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