473,413 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Alternative implementation examples?

http://www.cs.rutgers.edu/~pxk/rutge...pdf/Cstyle.pdf
has an example at the end of the document of an example of
an alternative implementation of interest to me. In this
example, the document provides an alternative implementation
to the if-else sequence of using strcmp to match a set of
strings. Such an example makes me think about the pro's and
con's of the different implementations.

I am looking for more of such examples. If you have any
examples to share, then I would like to see them. Perhaps
there is a website or book which contains such examples, if
so, then please provide the applicable information.

Thanks,
Doug
Nov 20 '06 #1
1 2012
On Mon, 20 Nov 2006 14:56:56 -0500, Doug Arnott
<da*********@rogers.comwrote:
>http://www.cs.rutgers.edu/~pxk/rutge...pdf/Cstyle.pdf
has an example at the end of the document of an example of
an alternative implementation of interest to me. In this
example, the document provides an alternative implementation
to the if-else sequence of using strcmp to match a set of
strings. Such an example makes me think about the pro's and
con's of the different implementations.
The example provided does two things:

It replaces a sequence of if (strcmp(str_var,str_const_i))
statements with a for loop containing if (strcmp(str_var,
str_const_ptr[i])). While the resulting code may be more compact, in
general the exact same number of calls to strcmp will be executed so
performance will probably be a little worse (looping and indexing are
not free).

It requires that all the functions to be called either have the
same prototype (which may not be possible) or you omit prototypes for
the functions (which is very undesirable).

He also has what I consider some strange ideas about acceptable style.
He likes
if (...){
...
}else{
...
}
and declares
if (...)
{
...
}
unacceptable.

I consider the that else style an abomination and code the second
because I like my braces to line up.

He also claims that a short explanation of a program's function and
prompts for input are overly verbose since everyone knows that a
program named fact can have no other purpose that to calculate
factorials.

The fact that his examples will not compile (e.g., fprintf with only
two arguments) does not improve his credibility.
>
I am looking for more of such examples. If you have any
examples to share, then I would like to see them. Perhaps
there is a website or book which contains such examples, if
so, then please provide the applicable information.

Thanks,
Doug

Remove del for email
Nov 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: Robin Becker | last post by:
It seems that the rotor module is being deprecated in 2.3, but there doesn't seem to be an obvious alternative. I'm using it just for obfuscation. It seems we have ssl available in 2.3 for sockets,...
99
by: Paul McGuire | last post by:
There are a number of messages on the python-dev mail list that indicate that Guido is looking for some concensus to come from this list as to what *one* alternative syntax for decorators we would...
28
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice...
6
by: Andy Fish | last post by:
Hi, I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()"> I've read endless usenet posts and hint sites on the net, they all...
0
by: EightNineThree | last post by:
I'm looking for examples for presenting text transcripts as an alternative to movies. TIA for ideas, pointers, and tutes. -- Karl Core Charles Sweeney says my sig is fine as it is.
62
by: christopher diggins | last post by:
Since nobody responded to my earlier post , I thought I would try to explain what I am doing a bit differently. When multiply inheriting pure virtual (abstract) base classes, a class obviously...
8
by: btober | last post by:
MY version 7.3 setup uses the default cluster data directory of /var/lib/pgsql/data and I'm aware that one suggested alternative is /usr/local/pgsql/data In my reading of server setup...
115
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
6
by: rshepard | last post by:
All my python books and references I find on the web have simplistic examples of the IF conditional. A few also provide examples of multiple conditions that are ANDed; e.g., if cond1: if cond2:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.