www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/24/12:31:45

From: "Paul 'Ozymandias' Harman" <ozzy AT kasterborus DOT demon DOT co DOT uk>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer
Subject: Re: pointer to function ??
Date: Tue, 24 Feb 1998 10:15:13 -0000
Organization: COLT Internet Services
Message-ID: <2061CEBD9141D1118CEF080009DE1692B92235@sun.panews.press.net>
References: <6c7ltq$ms1$1 AT o DOT online DOT no> <6c7u5l$mub$2 AT news DOT ox DOT ac DOT uk> <01bd4107$bba0dc60$77111111 AT jfisher DOT team17 DOT com>
NNTP-Posting-Host: sun.panews.press.net
Lines: 28
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

James E Fisher wrote in message
<01bd4107$bba0dc60$77111111 AT jfisher DOT team17 DOT com>...
>The first idea of a pointer to the code is the fastest way as there is only
>one call to the required function (after the address of the function has
>been fetched).  Using a SWITCH statement is slower as it can end up as a
>list of IF() statements by the compiler.


Agree with you 200% here.

>You also need to think about debugging.  Using the pointer to a function is
>much cleaner to debug than having to wade through switch statements.

Could not disagree more. As someone who's been on the receiving end of
maintenance of such programs, I can tell you it's a BASTARD debugging this
sort of thing: following the program trace back to the last time that
pointer was assigned. Especially if it can be assigned through other
pointed-to functions or in conditionals etc etc...

The switch() statement is INFINITELY clearer and easier to understand. It's
just slower.

    Ozzy
--
+-+ Paul Ian Harman +-+-+-+-+-+-+- Ozzy +-+ Games Guru & Sci-Fi Admirer +-+
-+- ozzy AT kasterborus DOT demon DOT co DOT uk +-+ http://www.kasterborus.demon.co.uk -+-


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019