HDTenEightyP/NetNews huggingface dataset:
From: steve@taumet.com (Steve Clamage)
Subject: Re: SWITCH Statement Question
Organization: TauMetric Corporation
Distribution: usa
Date: Wed, 16 Dec 1992 17:08:19 GMT

u-mwong%peruvian.cs.utah.edu@cs.utah.edu (Michael Wong) writes:

>   Will using a SWITCH statement run faster if it had few CASE statements and 
>IF statements were used to aid in the processing than using a SWITCH 
>statement that had a very long list of CASE statements.

It depends entirely on the compiler.  Some compilers will generate nearly
identical code for both methods.  Some will generate "better" code for
one than for the other.  "Better" might mean "smaller" or "faster" or both.

Invariable rule:  Write straightforward code that is easy to read,
understand, and modify.  This will be easier to get working, and will
be easier to see as being correct.  If you find BY MEASUREMENT that a
code fragment is the bottleneck which is slowing your program, look for
ways to make it faster.  Keep around the original code, since source
code that gives better results with one compiler/machine combination may
give worse results with a different combination.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: travelling salesman
Date: 14 Dec 92 14:48:29 GMT
Organization: AND Software BV Rotterdam

In article <FARID.92Dec11140244@gradient.cis.upenn.edu> farid@gradient.cis.upenn.edu (Hany Farid) writes:
|
|I am looking for code that enumerates the (N-1)!/2 possible paths of
|the travelling salesman for a map with N cities.  Any help would be
|appreciated.  

Note that only the first (N-1)! of all N! permutations need to be generated
(since it doesn't matter which city is the start/end point) Also not that,
when the cities are numbered 0 ... N-1, when the city _next_ to the starting
point has a lower rank than the last city of the tour, this particular tour
must occur somewhere earlier in the list of permutations (but backwards.)

Maybe an example clarifies things a bit: Consider N= 4:

1234, 1243, 1324, 1342 (not valid: 2 < 3), 1423 (not valid: 3 < 4),
1432 (not valid: 2 < 4)

So, 1234, 1243 and 1324 are the three possible tours for N= 4.

Also note that we can stop generating permutations when the city next
to the starting point has the highest rank number.

The following program does the job for you:

-----8<-----snip----------snip----------snip----------snip----------snip-----
#include <stdio.h>

#define N 6	/* or any number you want */

void print_perm(a) 
int *a;
{
	int i;

	for (i= 0; i < N; i++)
		printf("%d ", a[i]);
	printf("\n");

}

int main(void) {

   	int i, tmp, a[N], b[N];

	/*
	 * Set up first permutation 
	 */
   	for (i = 0; i < N; i++) 
		a[i] = b[i] = i;

	print_perm(a);

	/*
	 * Keep on generating permutations
	 */
   	for (i = 0; i < N; i++) {

      		if (b[i] < i) {
			tmp = a[i]; 
			a[i] = a[b[i]];
			a[b[i]] = tmp;
		}

      		if (--b[i] >= 0) {

         		tmp = a[i]; 
			a[i] = a[b[i]]; 
			a[b[i]] = tmp; 

			/* 
			 * Test for the same route backwards 
			 */
			if (a[N-2] > a[0])
				print_perm(a);
			/*
			 * Done first (N-1)!/2 ?
			 */
			else if (!a[N-2])
				break;

			/*
			 * Reiterate again 
			 */
			i= -1;
			continue;

      		}
      		b[i] = i;
   	}
}
-----8<-----snip----------snip----------snip----------snip----------snip-----

I hope this helps a bit,

kind regards,

Jos aka jos@and.nl
Xref: sparky comp.lang.c:18709 gnu.gcc.help:2785
From: dat@thinkage.on.ca (David Adrien Tanguay)
Newsgroups: comp.lang.c,gnu.gcc.help
Subject: Re: How precise is preprocessor math? (I'm using gcc)
Date: 20 Dec 92 16:45:23 GMT
Organization: Thinkage, Ltd.

steve@taumet.com (Steve Clamage) writes:

[concerning sin()]

>The compiler is indeed allowed to evaluate the above expression at
>compile time, but I don't know of any compilers which do.

The GCOS and Mark III compilers will accept sin(<constant_expression>)
as a constant expression.
-- 
David Tanguay       dat@Thinkage.on.ca  dat@Thinkage.com  uunet!thinkage!dat
Thinkage, Ltd.           Kitchener, Ontario, Canada          [43.40N 80.47W]
Xref: sparky comp.lang.c:18677 comp.std.c:3239
From: alane@wozzle.linet.org (J. Alan Eldridge)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re:  Is this ANSI: final (long)
Date: 18 Dec 92 14:51:27 GMT
Organization: Disorganization

martin@mwtech.UUCP (Martin Weitzel) writes:

> :The point is this:  If you are dynamically allocating *both* the
> :structure and the data, the approach you suggest requires *two*

> Yes, and there's another point:  With a single allocation you may
> memcpy/memmove/memcmp/[f]read/[f]write the whole easily.  Each of
> this would become a specialized operation if you separate the size
> from the data.

This is illegal in C++ for a good reason, and I find it inadvisable
in C for similar reasons. For one, structure assignment is broken. For
two, you are cheating what type safety there is in C. Neither one of
these results is attractive in my opinion. I vote quite vehemently for
allocating a separate data area and accessing it through an extra level 
of indirection... if your CPU has problems because of the extra one or
two instructions that are introduced, buy a real computer.

alane@wozzle.linet.org (J. Alan Eldridge)
Fido: The University of Walamaloo 1:272/38.473
Newsgroups: comp.lang.c
From: agrafiot@wl.com (Dimitris Agrafiotis)
Subject: questions on variable argument lists
Organization: Warner Lambert / Parke-Davis
Distribution: usa
Date: Mon, 14 Dec 1992 19:54:19 GMT


I want to define a function, alpha(), that takes as arguments a pointer to a
function, beta(), and the arguments to be passed to that function. Ideally,
the function would be implemented as follows:

void alpha(void (*beta)(...), ...)
{
   va_list arg;
   va_start(arg, beta);
   (*beta)(arg);
   va_end(arg);
}

but that doesn't work for several reasons. First, the compiler seems to
require at least one argument in the declaration of beta(). Is there
an elegant way around that ? Second, even when you avoid this problem
by introducing a dummy argument, you get garbage at run time (this was
run on an SGI Indigo). What is the reason? What's the best alternative
and how portable would it be?
Thanks in advance,

-- 
Dimitris K. Agrafiotis
Computer Assisted Drug Design
Parke-Davis Pharmaceutical Research
(agrafiot@wl.com)
From: potter@scan2.tamu.edu (Shane Potter)
Newsgroups: comp.lang.c
Subject: Data compression techniques.
Date: 15 Dec 1992 14:44 CST
Organization: Texas A&M University, Academic Computing Services
Distribution: world
NNTP-Posting-Host: scan2.tamu.edu
News-Software: VAX/VMS VNEWS 1.41    

Hi,

	I was wondering if anyone could reccommend some good books on data
compression techniques.  I'm writing a program that generates a struct that
contains some character string fields, and I want the best way to store the
generated data without having lines of strings having to be stored in a file.
Please e-mail me with responses, and I will post a summary if there is a
demand.

							Thanks,
							-Shane
							potter@scan2.tamu.edu
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 11 Dec 92 17:56:20 GMT
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development

In article <PTmLVB4w165w@quest.UUCP>, kdq@quest.UUCP (Kevin D. Quitt) writes:
|> jfw@ksr.com (John F. Woods) writes:
|> > 
|> > "After
|> > 	int i = 2;
|> > 	i = ++i;
|> >  what does i equal?"
|> > 
|> > If they answer, do not hire them.
|> 
|>     If they say other than "it's undefined", *then* don't hire them.

This is an interesting question. Is the value of I really being modified
more than once? There are two assignment operations going on, true. But,
does assigning a variable the value that it already has constitute a 
modification?


|> 
|> 
|>  _
|> Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Xref: sparky comp.lang.c:18595 comp.unix.xenix.sco:3508 comp.unix.xenix.misc:284
From: tgs@jjmhome.UUCP (Thomas G. Seidenberg)
Newsgroups: comp.lang.c,comp.unix.xenix.sco,comp.unix.xenix.misc
Subject: Overlays in SCO XENIX Sys V 386...
Date: 18 Dec 92 02:10:41 GMT
Followup-To: comp.lang.c
Distribution: na
Organization: Jims Place


   I am currently programming a large database application for a small company.
I am looking into possible ways to reduce the memory image of the resultant
program.  I have considered splitting the program into separate sections,
based on sub-menus, removing strings to shared memory, etc...  I have not
selected any method of reducing size, nor have I ruled out just 'one-big-
mother,' I am just looking into the possibilities, should the needs arise.
I would like to know if it is EASY to write overlays in XENIX C.  Portability
can be sacraficed, as this program will never go beyond the
walls of this company.  Specifically, The OS is SCO XENIX Sys V 386 version
2.3.something with the companion 386 Developement system (i.e cc, masm, etc)
Oh yah, one last little puzzle piece - The program MUST be compiled as a
LARGE model 286 binary because the functions to interface with the UNIFY DBMS
are pre-compiled - no source code.  It is also no problem to enable the
non-ANSI extensions.  Thanx in advance...

PLEASE E-MAIL, I don't login often & I usually miss a day or 2 of posts....

Thomas Seidenberg              Programmer/Systems Administrator
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: Getting input from the keyboard
Organization: University of Helsinki
Date: Wed, 16 Dec 1992 15:24:53 GMT

stuartj@esg.mentor.com, pal@regent.e-technik.tu-muenchen.dbp.de (Peter
Loibl), and paulk@garfield.cs.mun.ca (Paul E. King) ask about and
discuss reading characters from a keyboard without the user having to
type a carriage return.  This is covered by the FAQ, question 16.1.
It contains several pointers to how to do it in various systems.  (The
FAQ exists for a reason!)

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Xref: sparky comp.lang.c:18230 comp.lang.c++:17839 comp.misc:4553
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
Subject: Re: What is Object Oriented Programming? Is C doomed?
Date: 11 Dec 92 22:37:36 GMT
Followup-To: comp.lang.c
Distribution: usa
Organization: negligable

In article <1992Dec9.151051.3628@mcs.drexel.edu> tjhendry@mcs.drexel.edu (Jonathan Hendry) writes:
>>Now you run into another problem.  Prewritten code is FIXED.  Code can't learn
>>and modify itself and adapt.  Sorry you're out of luck.  Just put up, because
>>modularity is supposed to be a Good Thing.  In reality, it's a Goof Thing.
>
>Ah, but here is where OOPS shines.If a supplied object doesn't do what you 
>want it to do, just subclass it. That way, all you have to write is what you
>want to add. You don't have to redo the whole thing. The subclass inherits
>all the original class' behaviors and variables. You can add or change whatever
>you want. WITHOUT changing the original code. I've written tons of subclasses
>of NeXTSTEP objects, and I've never needed to change the original code 
>(and couldn't if I wanted to)

Not always.  I tried subclassing NIH's LinkedList class and ran into
tons of trouble due to the trick they pulled w/ the hidden dependancy
between their .addFirst() and .add() member functions.  I had to reduplicate
entire functions from their source code to properly handle something that
SHOULD have been subclassable (is that a word???).

It is truly bizarre -- in the LinkedList::addFirst() member function
there is a test: if the list is empty (size() == 0) they call LinkedList::add()
which has special case code for adding the first node to an empty list!

This should be the other way around, if .add() to an empty list, call
.addFirst() (if you need to do anything special at all).  As it was
since .add() was virtual, I had to DUPLICATE their special purpose
code in MY .add() routine because .addFirst() called MY .add() routine
when it thought it couldn't handle the job!  This entailed gaining access
to what should have been private member fields of their linked list class!

(note: the specifics of the problem may not be exact here -- I ran into
this over a year and a half ago, kvetched, fixed it, and moved on.  I am
pretty certain it was a hidden dependancy between these two routines as
described, but it could be some variant thereof....)

OOP and C++ is NOT a "silver bullet", any more than "structured programming"
was.  It is a new tool that gives us the potential for things that were
more difficult before, but in and of itself does NOTHING.  That is the
job of the software designer.  If it is done poorly, it is done poorly
no matter what the language or paradigm.

		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Never speak in absolutes.  It will always lead to trouble.
From: awright@gssec.bt.co.uk (Alan Wright)
Newsgroups: comp.lang.c
Subject: Re: What do you say.
Date: 16 Dec 92 12:49:15 GMT
Organization: BT, Software Engineering Centre, Glasgow, UK

In article <9DEC199211285049@accvio.intel.com>,
dmills@accvio.intel.com (Dave Mills) writes:
|> 
|> I did a lot of firmware development in the early eighties, and was always
|> running up against the wall on code size not fitting into the ROM's.  One
|> day, a marketing type was hanging around, and we were discussing this 
|> situation, and he suggested I remove all those comments from my code to
|> save some more space.
|> 
|> ..what do you say...  
|> 
|> Dave

Well having worked with the early versions of the Intel 80376 C compiler
(1.0 - 1.2) I think he may not be the only one that thinks that way.
We had many problems but there were two that caused much amusement
when considered together. Both involved the compiler producing incorrect
code. Don't take this the wrong way, I'm not attacking Intel.

One was that the base address of a lookup table was not loaded before
the table was indexed. The support-line suggested using a pointer to
index the array. The other was to do with indexing an array using a
pointer. The support-line suggested we use a lookup table.

Now in this case there is no difference between = and == because
invariably the answer is general protection fault.

However, if any of your funding comes from marketing then you should
ask for more money to buy bigger ROM's. After all, if you removed the
comments how would the processor know what to do with the code?

To answer the original question my old team leader would have said
"RTFM" and wandered off with a :-).

-- Alan
--------------------------------------------
awright@gssec.bt.co.uk (Alan Wright)
BT, Software Engineering Centre, Glasgow, UK
--------------------------------------------
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: Another C palindrome puzzle
Date: 21 Dec 92 00:05:59 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <BzGJt5.5nL@sci.kun.nl>, Ron Wichers Schreur <ronny@cs.kun.nl> writes:
> Manus Hand, manus@evolving.com writes:
> [...about palindromic programs...]
>> As Henderson did, I assert that new-line characters are not
>> significant when determining palindromism (palindromicity?).
> In this puzzle, new-line characters are significant.

Why?  If I write an English palindrome like "A man, a plan, a canal -
Panama!" you don't complain that it's not a palindrome because it
reverses to "!amanaP
- lanac a ,nalp a ,nam A".  Punctuation, case, and whitespace
(including line breaks) are ignored.

Hence, I submit that we should ignore whitespace, including newlines,
and alphabetic case.  (Not punctuation, because it's hard to say just
what "punctuation" is in C.)  Extra points, of course, for palindromes
that treat whitespace as significant....

>> Now I suppose I have to come up with the NEXT challenge.
>> Okaaaayyyy.... how about a palindromic "Hello world" program, with
>> no comments, #if's, #ifdef's, <<<OR #define's!>>>
> This looks a real challenge (I don't think there's a solution).

I don't either.  Consider what the first token in such a program might
be.  I don't think it's possible for its reversal to be the last token.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 20 Dec 92 23:07:03 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <1992Dec16.192652.65097@ns1.cc.lehigh.edu>, dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER) writes:
> D. SPENCER BEECHER) writes:
>>> varname%3
>>> varname&0x02
>> Well, [...]

> x&0x02 may be represented with modulo as:

>   x%=4,x>1?x:0;

> though this changes the value of x, where x&0x02 makes no assignment.

It also doesn't work.  For example, if x holds 7, x&2 is 2 whereas your
expression produces 3.  (And, as you note, changes x.)

I'm also not sure whether , or ?: has higher precedence.  For that to
work correctly, it has to be interpreted as (x%=4),((x>1)?x:0), but I'm
not sure it wouldn't be (((x%=4),x)>1)?x:0 instead, which I *think*
produces undefined behavior.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
From: marby@laura.harvard.edu (Craig Marby)
Newsgroups: comp.lang.c
Subject: Re: ISAM routines
Date: 16 Dec 92 22:26:37 GMT
Reply-To: marby@layla.harvard.edu
Organization: Chemistry Dept., Harvard University
In-reply-to: s9100786@cumulus.csd.unsw.oz.au's message of 16 Dec 92 01:47:57 GMT

>>>>> On 16 Dec 92 01:47:57 GMT, s9100786@cumulus.csd.unsw.oz.au (Matthew Jackson) said:

Matthew> Does anyone know of any routines to implement ISAM under C ? We are 
Matthew> working on a project which needs indexed sequential access and (as 
Matthew> always) don't want to reinvent the proverbial wheel.

Matthew,

You might try looking at MetalBase. The latest version is 5.0 which
is in alt.sources Vol. 33, Issue 119. I copy the flyer below:


MetalBase 5.0 is a simple database engine, designed to be portable between
almost any platform; Unix, MS-DOS, HP, Mac PW, NeXT, sgi, and many more, small-
model and up.  This latest release has more field types, three-phase locking
to ensure multi-user access without any system-based IPC, and internal caching
to provide twice the speed and up for rebalancing indices.  A conversion
utility for MetalBase 4.0 and 4.1a relations is provided.  Other features
include run-time encryption on all platforms, creation of relations on-the-fly
and a flexible report writer.



You should be able to lay your hands on the source, but if not e-mail
me.

--

    __o         
  _ \<,_       Craig A. Marby    marby@layla.harvard.edu
 (_)/ (_)      
~~~~~~~~~~
Newsgroups: comp.lang.c
From: billb@crpmks.uucp (Bill Bochnik (Info Systems))
Subject: VAX C and RMS
Reply-To: billb@crpmks.UUCP (Bill Bochnik (Info Systems))
Organization: Ciba-Geigy Corporation
Date: Fri, 18 Dec 1992 13:10:09 GMT

I'm new to using C to access VMS structures, such as RMS, so bear with me.  
Could somebody send me a sample of code, or point me toward a good book on 
using RMS files from C?  I'm working with MONITOR data files, which has 
variable length records (as per the layout in the back of the manual).  

Any ideas?  Thanks.

-- 
Bill Bochnik			| It's hard to be a James Bond in an Abbott
Systems Analyst 		|	and Costello world.
Ciba-Geigy Corporation		| Signed and sealed, they deliver oblivion.
philabs!crpmks!billb		| It's worse than that, he's dead Jim.
Newsgroups: comp.lang.objective-c,news.answers
From: lerman@seltd.UUCP (Kenneth Lerman)
Newsgroups: comp.lang.objective-c
Subject: Re: Advice on accepting/returning objects vs. copies of objects
Date: 10 Dec 92 22:36:22 GMT
Reply-To: lerman@seltd.UUCP (Kenneth Lerman)
Distribution: usa
Organization: Systems Essentials Limited

In article <1992Dec7.212541.20646@colorado.edu> fedor@hopper.Colorado.EDU (Adam Fedor) writes:
|I think I have an answer to this, but since I'm very new to Obj-C, I thought
|I'd ask:
|
|Say I have an instance of a class List (myList) that stores a 
|bunch of objects.  If some
|client asks for an object and myList returns it, instead of a copy 
|of the object, this leaves open the possibility that the client may 
|change and/or even free the object without myList knowing about - with
|disasterous consequences.

You are correct that the client may free the object.  Whether the
consequences are disasterous or not depends on the intent of the
creater of the list.

It is a matter of policy (which may vary from usage to usage) of "who"
owns an object which is "contained" in another object.  In the case of
container classes (like Stepstone's OrdCltn and, I assume, List) the
ownership is left up to the user.

|
|I suspect that you should make a copy of any object that is accepted/returned.
|This also jives with the theory that data within an object (including other
|objects) should not be accessable to the outside.
|

While the policy you suggest here is very simple to understand, it has
two major disadvantages:

1 -- It has the high overhead of making multiple copies of everything.

2 -- Sometimes you want a client to be able to make changes to an
object.  Consider the case of a List which is used to hold the members
of a family.  If I want to change the profession of one of the
members, I would first find the member in the List.  But under your
policy, this would give me a copy.  If I then changed the profession
of the member and printed the list, I would still get the old profession.

...Not to be confused with the oldest profession... :-)

|However, I have to be sure that all objects I accept/return implement a
|deepCopy or I might get other unwanted effects.
|
|Any thoughts on this?  Thanks.

|
|Adam Fedor. CU, Boulder		    | Fudd's Law of Opposition: Push something  
|fedor@boulder.colorado.edu (W)      |   hard enough and it will fall over. 
|adam@bastille.rmnug.org (H,NeXTMail)|

-- 
Kenneth Lerman                  ...!uunet!casey!gaboon!seltd!lerman
Systems Essentials Limited                            (203)426-4430
55 Main Street
Newtown, CT 06470
From: lozinski@cup.portal.com (Christopher A Lozinski)
Newsgroups: comp.lang.objective-c
Subject: Re: Windows/Macintosh Objective-C
Date: Wed, 16 Dec 92 22:34:19 PST
Organization: The Portal System (TM)
Distribution: world

Of course Objective-C runs on Microsoft Windows.  Develop on the
NeXT, then port to Windows.  Many of my clients are doing just that. 
There even is an Interface Builder clone called Window Builder in
Smalltalk.  The application kernel is in Objective-C, and the User
Interface is built using the Interface Builder on the NeXT, or Window
Builder under Microsoft Windows.  

Memory management under Windows is simplified by the Borland Compiler, 
which suballocates Window's limited number of memory blocs into 
object size memory allocations.

For more information, please send me your postal mail address, and I
will mail you information about the Borland Extensions to
Objective-C, the Smalltalk Interface to Objective-C, and the Window
Builder products.

Regards 
Christopher Lozinski
From: yikes@netcom.com (Michael Brill)
Subject: Windows/Macintosh Objective-C
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Tue, 15 Dec 1992 04:39:05 GMT

Is anyone using Objective-C for Windows or Macintosh development?  I'm 
developing an *ugh* Windows/Macintosh app but would like to continue 
much of the development on my trusty NeXT.

Specifically I'm interested in any user interface or memory management
anecdotes that anyone might have.

As a reality check... would anyone have second thoughts about developing
a commercial Windows or Macintosh app in Objective-C?

...Michael Brill

-- 
----
Newsgroups: comp.lang.objective-c,news.answers