[Shootout-list] Many tests cheat

skaller skaller@users.sourceforge.net
03 Nov 2004 11:14:46 +1100


On Wed, 2004-11-03 at 02:41, Isaac Gouy wrote:
> > The fact is several languages cheat
> 
> afaict felix doesn't have an exception handling mechanism?
> 
> Isn't the felix program for the exception handling test completely
> ignoring what the test asks to be done?

That depends on what you mean by exception handling.

As the test code demonstrates, for some requirements
the technique for handling errors actually used is
not only faster than C++ style exceptions, it is also
superior from a safety viewpoint -- there's no way
to get an uncaught exception, there's no way the
programmer can forget an exception handler is
required.

If you mean C++ exception handling, you'd be right,
but that's a language specific constraint which
excludes all languages other than C++.

So it isn't clear exactly what is meant by exception handling.
My contention here would be -- there's no sensible way
to actually define it and use the definition as a constraint.
You'd need a semantic model of 'all programming languages'
to specify what that means .. which would defeat
the pluralistic intent of the shootout.

Instead, define a test which discriminates against the technique
used in the Felix test operationally. Please note I'd be quite
willing to help do that! For example, if you have to discriminate
between 20 pssible errors .. that's 20 handlers passed to
the Felix code. It will work, but the LOC will go through
the roof. The code will *look* bad. It will also get slower.
C++ EH won't suffer these deficiencies. So the test
would look something like the current one, but with
20 levels instead of just two (and be careful or I'll
pass an array of handlers in as a solution :)

FYI: Felix is using a non-local goto to transfer control
from the point the error is detected to the handler.
This actually does require unwinding the stack.

In addition, there's no way to use the technique
from a function -- it *only* works for procedures.

I'd note you would need to careful to use an operational
constraint -- you just can't ban the Felix solution
because it isn't 'throwing an exception'. Python can't
throw exceptions either. Underneath, it passes them
around as special values (a kind of C version of a
Haskell monad .. :)

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net