[m-rev.] for review: implement io__file_modification_time_2 in C#

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 7 02:49:45 AEDT 2003


On 04-Nov-2003, Peter Moulder <Peter.Moulder at infotech.monash.edu.au> wrote:
> On Sat, Nov 01, 2003 at 04:17:49PM +1100, Fergus Henderson wrote:
> > Index: library/time.m
> > -	// XXX TicksPerSecond is long in .NET!
> > +	// TicksPerSecond is guaranteed to be 10,000,000
> >  	Ret = (int) System.TimeSpan.TicksPerSecond;
> >  }").
> 
> Such comments are usually better written as assertions.  If
> TicksPerSecond is a class constant, then the assertion should disappear
> at compile time.

Hmm, well, I don't want to abort if TicksPerSecond is not 10,000,000,
since the code doesn't actually depend on that.

I guess we could use a checked cast:

  	Ret = (int) System.TimeSpan.TicksPerSecond;
	// double-check that cast didn't overflow
  	assert(Ret == System.TimeSpan.TicksPerSecond);

Of course "assert(...)" is unlikely to work -- that's C syntax!
What's the C# syntax for assertions?  Is there a better alternative
than
	if (!cond) { throw new SomethingOrOther; }
?
Does C# have anything like the Java 1.4 "assert" keyword?

  	assert Ret == System.TimeSpan.TicksPerSecond;

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