HDTenEightyP/NetNews huggingface dataset:
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: discriminated unions (Re: C/C++ Correctness (was: Re: C/C++ Speed))
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
Date: Fri, 22 Jan 1993 20:03:03 GMT

In article <TMB.93Jan21014916@arolla.idiap.ch> tmb@idiap.ch writes:
>
>People who believe in purely OO design will argue that switching on
>types will not occur in "well designed code". 

	And in a statically typed, class based language
like C++ these people would in my opinion be wrong.

>But it does in practice, even in well-designed code.  

	It is not just a hack, as your comment might be 
interpreted as suggesting.

	IMHO: there is a *fundamental* difference between
vectoring (virtual functions) and indexing (switching).
Neither can be correctly used in place of the other.

	The whole notion of a polymorphism in a static class
based language rests on being able to CLOSE the base class,
while at the same time leaving it open for ARBITRARY
extension (leave it OPEN). Inheritance enables this.

	There is a restriction: the class must be
closed yet left open for ARBITRARY extension. In otherwords,
you can derive any classes you like from a base class.

	As such, the only thing you can rely on is the
declared interface of the base class: then number
of derived class is effectively infinite.

	On the other hand, with unions and type switching,
there is always a FINITE number of classes. These classes
are specifically known, and may have different interfaces.

	So the distinction is simple:

	Inheritance/virtual functions is used when
	a common interface supports arbitrary implementations.

	Unions/switching is used when there is a finite number
	of declared and disparate interfaces.

Attempting to replace one of these mechanisms with the other
is committing the gravest category error: claiming
one can substitue for the other is just absurd.

We need them both.

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: offsetof in case labels
Organization: TauMetric Corporation
Date: Fri, 22 Jan 1993 19:05:18 GMT

roberts@g2syd.genasys.com.au (Robert Swan) writes:

>We have a problem on various machines using the offsetof macro from
>stddef.h in case labels.  These machines all reject the expression as
>being non-constant.

>A representative of one of the machine vendors (IBM), has glibly stated
>that the compiler is doing the right thing by rejecting it.  He has
>quoted the ANSI standard arguing (in fairly obscure terms) that the
>compiler is free to treat various pointer expressions as non constant.

ANSI C Standard, section 3.6.4.1, "The switch Statement":
"The expression of each case label shall be an integral constant expression."

ANSI C Standard, section 4.1.5, "Common Definitions <stddef.h>":
"... offsetof ... expands to an integral constant expression that has
type size_t ..."

It seems pretty clear that what you want to do is supposed to be legal.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: ggruscho@nyx.cs.du.edu (George Gruschow)
Newsgroups: comp.lang.c
Subject: Re: Telling if the SHIFT key is down.
Date: 26 Jan 93 22:38:32 GMT
Organization: University of Denver, Dept. of Math & Comp. Sci.

ooprb@Msu.oscs.montana.edu writes:

>TRIED:
>I've tried kbhit() and bioskey(0/1) with no success.

>Rocky B.  -  ooprb@trex.oscs.montana.edu

Try using some inline assembly! Check out any Interupt list (I'd suggest the
"Ultimate DOS programmer's Manual") for the shift key bios routine, call it,
and place the returned value in the address specified at the top of the stack
(assuming your passing a variable to set)...
--
-------------------------------------------------------------------------------
George Gruschow                                Death do you gronk.
ag625@yfn.ysu.edu                              ggruscho@nyx.cs.du.edu
-------------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: mvarg@ctp.com (Michael Vargo)
Subject: Performance question
Organization: Cambridge Technology Partners
Date: Thu, 28 Jan 1993 15:12:01 GMT

Hello,
        I would like to throw this question on the table...

If I had a string with a format like "data1|data2|data3|data4|data5|...etc."
and it's **HUGE**, what do you think the FASTEST way is to extract the
data and put it into an array of strings....Any help is appreciated....

#------------------------------------------------------------------#
# Michael Vargo                      II  Internet: mvarg@ctp.com   #
# Cambridge Technology Partners - LA II  ICBMnet:  33.55 N         #
# 310-606-0952                       II           118.25 W         #
# 310-606-0933 - FAX                 II                            #
#------------------------------------------------------------------#
# |\/\/\/| # "A spirit with a vision... is a dream with a mission" #
# |      | # "I was lined up for glory, But the tickets sold out   #
# |   0 0) #______________ in advance."                            #
# C      _) Hey, dude!   #                                         #
#  | ,__| He's Mike V.,  #______    "Be cool or be cast out..."    #
#  |  /   Who the hell are you?#                                   #
#------------------------------------------------------------------#
Newsgroups: comp.lang.c
From: pnarsipu@ringer.cs.utsa.edu (Praasad Y. Narsipur)
Subject: Re: Few simple questions
Organization: University of Texas at San Antonio
Date: Fri, 22 Jan 1993 22:52:19 GMT

In article <1993Jan21.001022.46578@kuhub.cc.ukans.edu> kugold@kuhub.cc.ukans.edu writes:
>L.S.
>
>I have a few questions (I am programming in ANSI-C on a UNIX machine) :
>
>1. In unix, the backspace key does not work properly. I already 
>   found out that this can be changed by typing stty erase ^?, where '^?' 
>   means ctrl-?. I tried to include this in my .login file, but emacs does 
>   not accept ^?. How do I put this line in my .login file?
>
>2. In C I need an input function like INKEY$ in BASIC, that is a function that
>   does _not_ wait for input, but just an empty string or so returns if no 
>   character is entered. (I am trying to measure the time between two key-
>   presses). Does this function exist, and if not, is there any way to do
>   what I want?
>
>3. In C again, I want to initialize and array of integers, like
>   
>   main()
>   {
>     int ttime[6]={0,0,0,0,0,0}
>     /* rest of program */
>   }
>
>   but the compiler keeps saying:
>    
>" 
>ccom: Error: tr.c, line 12: no automatic aggregate initialization
>        int     ttime[6]={0,0,0,0,0,0};
>      ------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      ---------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      -----------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      -------------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      ---------------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      -----------------------------^
>ccom: Error: tr.c, line 12: illegal lhs of assignment operator
>        int     ttime[6]={0,0,0,0,0,0};
>      -------------------------------^
>"
This looks perfect. This should probably u would have left something
in your program. This works for me. 
Try giving blanks between '0' and `,`.


>   I really don't see what is wrong, the more because in my c-book,
>   "C by discovery" by L.S. Foster on page 213, almost exactly the
>   same thing is done.

read K&R c book chapter on Arrays.

Prasad V Narsipur.

>Thanks a lot in advance for any answer and I am sorry if the UNIX question 
>doesn't belong in this newsgroup.
>
>Regards,
>
>Wimjan
>
>kugold@kuhub.cc.ukans.edu
From: dmarer@td2cad.intel.com (Dennis Marer)
Newsgroups: comp.lang.c
Subject: Unwanted float to double conversion in variable length arg lists?
Date: 21 Jan 93 23:25:15 GMT
Organization: Intel Corporation, Santa Clara, CA USA

I've got a curious problem when passing floats in a variable length argument
list...they are automatically converted to doubles, EVEN when I typecast.
Consider:

#include <stdarg.h>

void func(int num,...) {
    va_list va;
    float x,y;
    int i;

va_start(va,num);

for (i=0; i<num; i++) {
    x = va_arg(va,float);
    y = va_arg(va,float);
    printf("%d: %g %g\n",i,x,y);
    }

va_end(va);
}



int main() {


func(4,1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0);

func(2,(float)1.0,(float)1.0,(float)2.0,(float)2.0);


}


The output of which is:		The output I assumed I'd get is:

0: 1 0				0: 1 1
1: 1 0				1: 2 2
2: 2 0				2: 3 3
3: 2 0				3: 4 4
0: 1 0				0: 1 1
1: 1 0				1: 2 2


I have explicitly typecast a real number to (float), and it still ends 
up on the stack as a double!  This is the same on various compilers,
including Gnu C and IBM C for the AIX operating system.  This seems incorrect
to me, and I'm afraid that if I assume it how things are supposed to be
implemented, I'll have portability problems.

Is this correct? Are all ANSI C compilers implemented this way?  --> Why?

				Dennis
				dmarer@td2cad.intel.com
Newsgroups: comp.lang.c,comp.lang.c++
From: twallace@gmuvax2.gmu.edu (Todd Wallace)
Subject: Re: Basic 3D equations
Organization: George Mason University, Fairfax, Va.
Date: Mon, 25 Jan 1993 15:56:15 GMT

I am looking for code or pseudocode that will allow me to
calculate the screen coordinates of a point in 3-space, given
the coordinates of the viewer in 3-space.  These equations are
the basis of programming 3D graphics, but I have not been able
to find them.

Any help/hints greatly appreciated.
----------------------------------------------------------------
|    Todd Wallace               |  "A pessimist is surprised   |
|    twallace@gmuvax2.gmu.edu   |   as often as an optimist,   |
|                               |   but always pleasantly."    |
|                               |            - Robert Heinlein |
----------------------------------------------------------------
From: ren@math.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c
Subject: How to compute Pi to 100 (or more ) digits in C?
Date: 28 Jan 1993 21:30:21 -0500
Organization: Department of Mathematics, The Ohio State University
Distribution: world
NNTP-Posting-Host: function.mps.ohio-state.edu

Recently I need to deal with very small real numbers. Sometime it is just too 
small for SUN to handle. Does anybody has or know where I can find a good C 
program to compute

        ______________
          |      |
          |      |

to more than 100 digits? I assume there must be something I can borrow.

Many thanks!

Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: Possible bug in BC 3.1: ellipsis in proto argument list
Organization: TauMetric Corporation
Date: Mon, 25 Jan 1993 16:47:22 GMT

steve@taumet.com (Steve Clamage) writes:

>...  The ellipsis-only notation
	[ void foo(...); ]
> is to allow
>linking to functions written in another language (not C++) where the
>calling conventions just happen to work and you are willing to forgo type
>checking and default promotion of actual arguments.

I meant to say
"...forgo type checking and accept default promotion of actual arguments."
                            ^^^^^^
>-- 

>Steve Clamage, TauMetric Corp, steve@taumet.com
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Newsgroups: comp.lang.c
From: mkhan@sdf.lonestar.org (Muhammad Khan)
Subject: Re: Telling if the SHIFT key is down.
Organization: sdf public access Unix, Dallas -- 214-436-3281
Date: Sun, 24 Jan 1993 07:48:52 GMT


he he he....
This was one of my surprises when I played a pinball game on a PC.
Hitting the left SHIFT would move the left bat and right SHIFT the
right bat.  Actually PC BIOS gives this info.  Interrupt 16, service
2.  Following is a short program to detect left/right shift key presses.
This is for Microsoft C, find appropriate subst. for _REGS, _int86 in
Borland.

#include <stdio.h>
#include <dos.h>

main()
{
     union _REGS inregs, outregs;
     char LEFT_SHIFT=2, RIGHT_SHIFT=1;

     while (1) {    //infinite loop, change this as you like
	inregs.h.ah=2;			     //request shift status
	_int86(0x16, &inregs, &outregs);     //BIOS service 16H

	if (outregs.h.al & LEFT_SHIFT)	     //left shift pressed
	     printf("Left shift pressed.\n");
	else if (outregs.h.al & RIGHT_SHIFT) //right shift pressed
	     printf("Right shift pressed.\n");

     }


}

===========================================================================
signed amjad;
Muhammad Amjad Khan
mkhan@sdf.lonestar.org

Newsgroups: comp.lang.c
From: swostal@dante.nmsu.edu (WOSTAL)
Subject: Re: Problem opening files on older versions of DOS
Organization: New Mexico State University, Las Cruces, NM
Date: Sun, 24 Jan 1993 10:15:13 GMT

I know this may sound stupid, but is there a possibility that their
drive is bad?  And, just out of curiousity, what version of DOS are
they running?

-- Steve	swostal@dante.nmsu.edu

Nope, no cute header ... just don't have the time!  :) 
Newsgroups: comp.lang.c
From: ktf@bc3.gun.de (Klaus ter Fehn)
Subject: Re: Why does curses make my Wyse50 flicker?
Organization: private
Date: Thu, 21 Jan 1993 11:02:46 GMT
X-Newsreader: TIN [version 1.1 PL6]

Jack Strangio (jvs@jacks.apana.org.au) wrote:
 > I have a comms program which uses curses to display characters on
 > the screen. If I use this program with an ansi terminal (PC) it works
 > very well. But if I use it on a Wyse50 (both the real McCoy or an
 > emulation) I get a most annoying flicker as the characters are
 > written on the screen.
 > I use a refresh after every character because I don't know how many
 > characters will be sent in a screen-full.
 > How can I prevent this flicker? 

1. Maybe the terminfo- and/or termcap-entry for the Wyse 50 is not set
   up properly on your System. In this case other programs will
   'flicker' too.

2. Maybe the Handshaking Host-Terminal is not set up properly

3. Maybe the program is not well-written (some terminal-dependent
   codings inside?)
-- 
LONDON ---*            *--- BERLIN                      Klaus ter Fehn
                *--- <ktf@bc3.gun.de>                   Neanderstr. 4
              {mcshh,smurf,unido}!easix!bc3!ktf    4000 Duesseldorf 1
   PARIS ---*      Tel.: +49-211-676331                 FRG / Germany
Newsgroups: comp.lang.c
From: usgtemx@gsusgi2.gsu.edu (Tracy Monteith)
Subject: DOUBLE TEXT WINDOW DISPLAY
Organization: Georgia State University
Date: Wed, 27 Jan 1993 18:23:22 GMT

I need some help defining and displaying two concurrent text windows. These win-dows will be stacked and I will be alternatively displaying text in each. I 
have been using  _settextwindow and _outtext with success but I can't seem to 
be able to define two regions using this method. If you have tried something 
similer to this please let me know. Also any cursor control funtions that
you have heard of will be of help.



Thank you in advance for your time.


 
Newsgroups: comp.lang.c
From: dsiebert@icaen.uiowa.edu (Doug Siebert)
Subject: Program to meld multiple C source files into one?
Date: Sat, 23 Jan 1993 03:51:58 GMT
Organization: University of Iowa, Iowa City, IA, USA

Does anyone have a program to take a number of C source files which together
are a single C program and meld them together into a single file?  Such a
program would have to deal with parsing the C source to make sure all globals
are defined before referenced, rename statically defined globals to avoid name
collisions and other issues.  The advantage of doing this would of course be
that optimization will work over multiple object files, instead of over a
single file -- there are certain companies designing newer compilers that will
do this (HP is one, I know of for sure) but most people do not have access to
such a capability at this time and it might provide some extra optimization
that could prove useful.

If I was more up on parsing tools I might try to tackle this myself, but it
occurs to me that someone else may have already done this.  Anyone know of
anything that does this?  I know that improvements in algorithms will net
much better improvements in efficiency than something like this, but my main
goal in this would be using it on a program I already know is fairly well
optimized to the bone (and spends 80% of its time inside the kernel anyway,
so the gains would likely be small)  But I'd still be interested in trying
this out.  I just mashed my source together manually in about an hour, but
haven't had a chance to do any real performance testing, but by tracking
stack sizes I can see the effect of some inlining across object files...

-- 
/-----------------------------------------------------------------------------\
| Doug Siebert                             | "I don't have to take this abuse |
| Internet:  dsiebert@isca.uiowa.edu       |  from you - I've got hundreds of |
| NeXTMail:  dsiebert@chop.isca.uiowa.edu  |  people waiting in line to abuse |
|     ICBM:  41d 39m 55s N, 91d 30m 43s W  |  me!"  Bill Murray, Ghostbusters |
\-----------------------------------------------------------------------------/
From: david.brooks@cutting.hou.tx.us (David Brooks) 
Newsgroups: comp.lang.c
Subject: Re: Conversion of BASIC c
Date: 21 Jan 93  4:23:00 GMT
Distribution: world
Organization: The Cutting Edge - Houston, TX - 713-466-1525
Reply-To: david.brooks@cutting.hou.tx.us (David Brooks) 

RMH> I am tired of hearing this!  I don't care what they claim, but that
RMH> new language with functions, subroutines, etc is NOT BASIC!  They've
RMH> reinvented Algol or Pascal, or something, but >BASIC< is the language
RMH> with numbers on every line that you find on C64, Atari 800 and old
RMH> Apples.
RMH> You know, the one that already has billions of variants even before
RMH> trying to bring in an entirely new structured language and giving it
RMH> the same name?  To call the new language by the same name is a
RMH> disservice
RMH> to everyone still making use of the real one.

RMH>                -Richard Hartman
RMH>                hartman@uLogic.COM

   What should we call a language that will compile old BASIC code and yet
adds functions, subroutines, etc., which still looks a lot like BASIC but
with added flexibility? How about BASIC++ ? =)

David
david.brooks@cutting.hou.tx.us

 * Q-Blue v0.7 [NR] *                                                                                                     
----
+---------------------------------------------------------------------+
| The Cutting Edge BBS (cutting.hou.tx.us)    A PCBoard 14.5a system  |
| Houston, Texas, USA    +1 713 466 1525          running uuPCB       |
+---------------------------------------------------------------------+
Newsgroups: comp.lang.c
From: law40003@nusunix1.nus.sg (TAN YEW KEONG)
Subject: Legal Advice
Organization: National University of Singapore
X-Newsreader: TIN [version 1.1 PL6]
Date: Mon, 25 Jan 1993 09:59:01 GMT



I am a final year law student planning to specialise in law regarding
all aspects of computing. I am computer literate and will be able to
understand most computer jargon except highly technical subjects like
Huffman coding etc.

If you have any legal problems or queries, post to me, and I will
endeavour to give free advice as far as possible.

It will be good practice for me, and free legal advice for you.

Disclaimer :

I will not be liable for any prosecution, both civil and criminal,
arising in any way connected to my giving the advice, whether it may be
your reliance on my advice, or my advice leading to criminal behaviour.
No one should interpret my advice as conclusive, and my advice is given
in the same manner as suggestions, and I do not profess any expert
knowledge on the advice I give. I disclaim responsibility for any losses
you incur by relying on my advice, and if any advice I give is illegal,
let it be known that I have no knowledge of collaboration with any
criminal.

I wonder if this disclaimer works, but it sure sounds legal. But I mean
all this mumbo jumbo, and if my drafting skills leave much to be
desired, read it in spirit, not in form.
--

_________________________________________________________________________
Michael Tan Yew Keong | law40003@nusunix1.nus.sg | law40003@nusvm.nus.sg|
Final Year Law student - OH GOD, IT'S BEEN A HELLUVA LONG TIME!!!       |
________________________________________________________________________|
--

_________________________________________________________________________
Michael Tan Yew Keong | law40003@nusunix1.nus.sg | law40003@nusvm.nus.sg|
Final Year Law student - OH GOD, IT'S BEEN A HELLUVA LONG TIME!!!       |
________________________________________________________________________|
From: cc100aa@xray.gatech.edu (Ray Spalding)
Newsgroups: comp.lang.c
Subject: Re: Performance question
Date: 29 Jan 93 02:08:23 GMT
Organization: Georgia Institute of Technology

In article <1993Jan28.151201.12690@ctp.com> mvarg@ctp.com (Michael Vargo) writes:
>If I had a string with a format like "data1|data2|data3|data4|data5|...etc."
>and it's **HUGE**, what do you think the FASTEST way is to extract the
>data and put it into an array of strings....Any help is appreciated....

The fastest way is of course subject to change depending on your
machine, compiler, library, optimization options, etc.  However,
my advice would be to use library functions (such as strchr())
where possible rather than stepping through the string char-by-char.
This is because library functions may be faster than any C code
could be, perhaps, for example, by being implemented in assembler.
Also, avoid copying if possible, or use one strcpy() on the whole
original string rather than the individual substrings.

A sample:

#include	<stdio.h>
#include	<string.h>

#define	MAXSTR	32

int
main()
{
	static char data[] = "data1|data2|data3|data4|data5";
	char *datptr[MAXSTR];
	char *sp;
	char *cp;
	int nstr;
	int i;

	sp = data;
	nstr = 0;
	for (;;) {
		if (nstr >= MAXSTR) {
			printf("Too many strings\n");
			break;
		}
		datptr[nstr++] = sp;
		cp = strchr(sp,'|');
		if (!cp) break;
		*cp = '\0';
		sp = cp + 1;
	}
	for (i = 0; i < nstr; ++i) printf("%d: %s\n",i,datptr[i]);
	return 0;
}
-- 
Ray Spalding, Office of Information Technology
Georgia Institute of Technology, Atlanta Georgia, 30332-0715
Internet: ray.spalding@oit.gatech.edu (NeXT Mail accepted)
From: gor@cs.strath.ac.uk (Gordon Russell)
Newsgroups: comp.lang.c
Subject: Networking Package
Date: 21 Jan 93 18:09:53 GMT
Organization: Comp. Sci. Dept., Strathclyde Univ., Glasgow, Scotland.


  Does anyone have a networking library which would support connectionless
datagrams, broadcasted reliably, allowing packet sizes greater than the
maximum ethernet packet size. I am just about to write such a library, and
would rather not reinvent the wheel.

 I am using an Unix system (sun4 sparc), and am writing the application in
C. The network is ethernet.  Any help appreciated, and feel free to email me.

 Gordon


+--------------------------------+-------------------------------------------+
|  Gordon Russell                |  EMAIL     : gor@cs.strath.ac.uk          |
|  L13.13a, Livingstone Tower,   |  TELEPHONE : 041-552-4400   Ex 3703       |
|  University Of Strathclyde,    |  FAX       : 041-552-0775                 |
|  26 Richmond Street,           +-------------------------------------------+
|  Glasgow, G1 1XH               | Spelling mistakes within this document are|
|  Scotland, UK                  | caused by internet compaction algorithms. |
+--------------------------------+-------------------------------------------+