🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #3356

Re: The search for heterogeneous lists is still on!

#3356
From: Darren New
Date: Wed, 03 Apr 1991 20:55
47 lines
2213 bytes
In article <167:Mar3121:32:0891@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>Does anyone have an example of a heterogeneous list---something beyond
>unions and callback functions---used in a real program?
>I suspect not. After all, if a module is like printf and understands
>all the possible types of objects in the list, it's dealing with a union
>type. 


Hmmm....  I don't remember ever seeing unions in printf().  Let's see:

void printf(char *, ... );	/* no unions here */

printf("hello: %d, %f", 3 * 5, 18.2);	/* no unions here */

void printf(char * fmt, int args)	/* old style ... */
{	/* no flames about off-the-cuff code please */
   char * ptr = (char *) &args;
   char buf[big];
   ...
   switch (*fmt++) {
     case 'd':
	itoa(*(int *) ptr, buf);
	puts(buf);
	ptr += sizeof(int);
	break;  /* no unions there */
     case 'f':
	ftoa(*(float *) ptr, buf);
	puts(buf);
	ptr += sizeof(float);
	break;	/* no unions here */
    ...
    }
}

I don't see anywhere that this particular kind of printf implementation,
declaration, or use ever mentions a union.  Since sizeof(any_C_type) is
fixed, I don't see how printf() could be using a C union.  Unless you
meant some other kind of union, in which case you will have to tell me
how to distinguish between an array of sorta-unions-of-various-sizes
is different from an array of things of different types.   
				-- Darren

-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, FDTs -----
  +=+=+ My time is very valuable, but unfortunately only to me +=+=+
+ When you drive screws with a hammer, screwdrivers are unrecognisable +
Technical Details
Message-ID: <49711@nigel.ee.udel.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!ee.udel.edu
References: <167:Mar3121:32:0891@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!ee.udel.edu
From: new@ee.udel.edu (Darren New)
Newsgroups: comp.lang.misc
Subject: Re: The search for heterogeneous lists is still on!
Message-ID: <49711@nigel.ee.udel.edu>
Date: 3 Apr 91 20:55:49 GMT
References: <167:Mar3121:32:0891@kramden.acf.nyu.edu>
Sender: usenet@ee.udel.edu
Organization: University of Delaware
Lines: 47
Nntp-Posting-Host: snow-white.ee.udel.edu