Re: Essential feature: assertions
- Posted by David Cuny <dcuny at LANSET.COM> Jan 29, 2001
- 600 views
George Henry wrote: > <assorted flamebait about b&d features> > > Right now I would be happy with a simple assert() > facility, such as any ANSI C compiler (or anything > close to one) provides. I think this would probably be a good thing to add. The addition of Derek's with/without assert would be a requirement. I've used asserts in Euphoria code before: global procedure assert( integer test, sequence msg ) if not test then -- print message puts( 1, msg & "\n" ) -- force traceback ? 1/0 end if end procedure In lieu of a "with/without assert" option, I just did a global replace of "assert(" with "-- assert(" There are obviously potential problems with asserts - for example, the test may have unexepected side effects. Sometimes just changing the length of the code or number of statments can have odd side effects. I still recall struggling with Euphoria, trying to figure out why the interpreted version of the code behaved differently than the bound version. All things considered, it's probably more useful than not. -- David Cuny ____________________________________________________________ T O P I C A -- Learn More. Surf Less. Newsletters, Tips and Discussions on Topics You Choose. http://www.topica.com/partner/tag01