From: Bardur A. <oca...@sc...> - 2004-12-24 11:32:16
|
On Fri, Dec 24, 2004 at 10:05:10PM +1100, skaller wrote: > On Fri, 2004-12-24 at 11:31, Janne Hellsten wrote: > > > Since I guess people are not willing to stop using unsafe_get/put (at > > least not completely), we should think of some other way to achieve > > bounds checking so that it doesn't hurt performance. > > Why doesn't just the usual get/put and compilation with -unsafe > for a production build work? I mean that's the idea of -unsafe > isn't it? Well, it probably works, but it requires even more confidence that the code is correct, because suddenly *every* array/string access becomes unsafe. I don't think I have that much confidence in the extlib code right now... [--snip--] > >The debug build would always have > >assertions on and thus be slower. However, it would only be used for > >testing purposes. I think this could be implemented by using pa_macro and adding something like (syntax might be slightly wrong, I usually use revised syntax) IFDEF DEBUG module String = struct include String val unsafe_get = get val unsafe_set = set end module Array = struct include Array val unsafe_get = ... ... end ENDIF at the beginning of modules using unsafe_get/set... (You can also use the pa_macro INCLUDE directive, add the above to a file and include that in the appropriate places). This should allow you to enable/disable bounds checking at compilation time. -- Bardur Arantsson <ba...@im...> <ba...@sc...> The best part? I became an ordained minister while not wearing pants. |