asjoshi@phoenix.UUCP (10/30/87)
Hi,
I have a question on structures. It is as follows:
I have gotten really tired of typing things like a.b.c.d etc to refer to
elements of a structure. I remember that pascal provided me with a 'with'
construction which allowed me to say something like
"with a.b.c {now refering to d really means use a.b.c.d } ..."
I was wondering if there is some similar contruct in C. I might be missing
something obvious, I wonder if somebody could help me ?. I know I could of
course make a local copy in the program of every variable in the structures
and then use the local copy but that seems inefficient and would be quite
unclear.
Thanks,
--
Amit Joshi | BITNET : Q3696@PUCC.BITNET
| USENET : ...seismo!princeton!phoenix!asjoshi
"There's a pleasure in being mad ...which none but madmen know!" St.Dryden
jouvelot@mit-vax.LCS.MIT.EDU (Pierre Jouvelot) (10/31/87)
In article <1025@phoenix.Princeton.EDU> asjoshi@phoenix.UUCP (Amit S. Joshi) writes: > "with a.b.c {now refering to d really means use a.b.c.d } ..." >I was wondering if there is some similar contruct in C. I might be missing >something obvious, I wonder if somebody could help me ?. A simple solution (sligthly inefficient). Rewrite with a.b.c begin d = 10 ; e.f = 3.4 end as { struct <whatever> *s = &a.b.c ; s->d = 10 ; s->e.f = 3.4 ; } where <whatever> is the type of a.b.c. If you like, I guess to can define a WITH macro which will do that automatically (modulo the name of the local structure pointer). Pierre -- Pierre Jouvelot Room NE43-403 ARPA: jouvelot@xx.lcs.mit.edu Lab for Computer Science USENET: decvax!mit-vax!jouvelot MIT (or mcvax!litp!pj) 545, Technology Square TPH: (617) 253-0884 Cambridge, MA 02139 USA
hwe@beta.UUCP (Skip Egdorf) (11/02/87)
In article <1025@phoenix.Princeton.EDU>, asjoshi@phoenix.Princeton.EDU (Amit S. Joshi) writes: > Hi, > > I have a question on structures. It is as follows: > > I have gotten really tired of typing things like a.b.c.d etc to refer to > elements of a structure. I remember that pascal provided me with a 'with' > construction which allowed me to say something like > "with a.b.c {now refering to d really means use a.b.c.d } ..." > I was wondering if there is some similar contruct in C. I might be missing > something obvious, I wonder if somebody could help me ?. I know I could of > course make a local copy in the program of every variable in the structures > and then use the local copy but that seems inefficient and would be quite > unclear. > -- > Amit Joshi | BITNET : Q3696@PUCC.BITNET > | USENET : ...seismo!princeton!phoenix!asjoshi This question arises around here once in a while, and this is how I answer, for what it is worth. No, there is no equivalent to 'with' in C. However, your question is symptomatic of a deeper problem; You seem to be trying to write Pascal programs in C. Every language has a 'style' that encourages good programs in some way. Many programmers have seen Fortran programs written in PL/I that are awfull (structured control constructs not used, etc.). Lisp programmers have all seen at least one Fortran program written with lots of parens. (setq ...) (setq ...) (setq ...) (setq ...) (write ...) The point is that attempting to use one language's style with a different language usually produces a poor product. Pascal forces one into a style with all variables, types, and consts global at the highest level. Some block structure can be used, but many things must be global. This leads to a record being defined at a high level, and used with 'dot' notation throughout the entire program. This leads to 'a.b.c.d' references and the 'with' construct to cut down on the verbage. In C, it is much more common for the particular piece of the record (now a struct) being processed by some sub procedure, with the sub structure ('d' in a.b.c.d) being passed as an address. This leads to a style of several small routines dealing with 'struct a-b-c' pointers, and most references of the form 'p->d'. Neither of these styles is gospel, to be found everywhere always. The programmer, as always, is responsable for picking the best tool for the job at hand. However, the C style of dealing with deep structure references will usually fit best within C programs, and 'with' usage will fit best in most Pascal programs. Trying to use either in the wrong place will usually result in a clumsy construct in the program. Skip Egdorf hwe@lanl.gov
gwyn@brl-smoke.UUCP (11/02/87)
In article <1025@phoenix.Princeton.EDU> asjoshi@phoenix.UUCP (Amit S. Joshi) writes: > "with a.b.c {now refering to d really means use a.b.c.d } ..." >I was wondering if there is some similar contruct in C. No, C doesn't have anything quite like "with". Partly this is because most interesting code accesses several structures, and their members can have the same names, so "with" would be ambiguous. However, you can obtain some relief by using struct pointers: register struct foo *p = &a.b.c; ... access(p->d); ...
clark@calma.uucp (Al Clark) (11/02/87)
Follow up to: comp.lang.c Distribution: comp.lang.c Organization: GE/Calma, Milpitas CA Keywords: structures In article <11782@beta.UUCP> hwe@beta.UUCP (Skip Egdorf) writes: >In article <1025@phoenix.Princeton.EDU>, asjoshi@phoenix.Princeton.EDU (Amit S. Joshi) writes: >> Hi, >> >> I have a question on structures. It is as follows: >> >> I have gotten really tired of typing things like a.b.c.d etc to refer to (Discussion of pascal 'with' construction deleted) >> "with a.b.c {now refering to d really means use a.b.c.d } ..." >> I was wondering if there is some similar contruct in C. I might be missing >> Amit Joshi | BITNET : Q3696@PUCC.BITNET >> | USENET : ...seismo!princeton!phoenix!asjoshi > >This question arises around here once in a while, and this is how I answer, >for what it is worth. > >No, there is no equivalent to 'with' in C. >However, your question is symptomatic of a deeper problem; You seem to >be trying to write Pascal programs in C. Every language has a 'style' (Discussion of language styles and passing parts of structures deleted) > > Skip Egdorf > hwe@lanl.gov As Skip points out, each language has its own style. I use the #define capability of the cpp to generate shorthand notations; eg, #define Mtime statb.st_mtime Since you can use a #define anywhere, you could use: #define D a.b.c.d You should make sure you're not using a system defined character string, but case combinations such as the Mtime example above are usually safe. I'd use #define Dele a.b.c.d in the case you mention. -- Al Clark - {ucbvax,sun,...}calma!clark ...calma!gewest!aclark!al NOTE: The calma account is a courtesy account; I am not employed by calma.
bright@dataio.Data-IO.COM (Walter Bright) (11/02/87)
In article <1025@phoenix.Princeton.EDU> asjoshi@phoenix.UUCP (Amit S. Joshi) writes:
$I have gotten really tired of typing things like a.b.c.d etc to refer to
$elements of a structure. I remember that pascal provided me with a 'with'
$construction which allowed me to say something like
$ "with a.b.c {now refering to d really means use a.b.c.d } ..."
$I was wondering if there is some similar contruct in C. I might be missing
$something obvious, I wonder if somebody could help me ?.
I tend to do things like:
struct { union b { struct c { int d,e; }}} s;
#define d b.c.d
for many of the leaf members,
which greatly reduces the 'noise' typing. I also frequently have complicated
structs that have unions and pointers to other structs in them, and I am
constantly modifying the structure. Since I rarely modify the purpose of
the leaf members, usually only the #define needs to be edited.
rober@weitek.UUCP (Don Rober) (11/03/87)
>A simple solution (sligthly inefficient). Rewrite > with a.b.c begin > d = 10 ; > end >as > { > struct <whatever> *s = &a.b.c ; > s->d = 10 ; > } A vastly superior solution in that there is nothing implicit happening. The typical Pascal error is that it is never clear what 'd' is a reference to. (for example, declare a local variable by the name of 'd' - which one is referenced?) This C solution obviates the problem and is worth whatever the cost may be. -- ---------------------------------------------------------------------------- Don Rober UUCP: {pyramid, cae780}!weitek!rober Weitek Corporation 1060 East Arques Sunnyvale, CA 94086
karl@haddock.ISC.COM (Karl Heuer) (11/03/87)
In article <5673@weitek.UUCP> rober@weitek.UUCP (Don Rober) writes: >This C solution [of declaring a struct pointer to simulate Pascal's "with"] >... is worth whatever the cost may be. The cost (relative to the equivalent Pascal program) may even be zero. At least one Pascal compiler implements the "with" statement in exactly this way. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
schwartz@gondor.psu.edu (Scott E. Schwartz) (11/03/87)
In article <5673@weitek.UUCP> rober@weitek.UUCP (Don Rober) writes: >>A simple solution (sligthly inefficient). Rewrite >> with a.b.c begin >> d = 10 ; >> end >>as >> { >> struct <whatever> *s = &a.b.c ; >> s->d = 10 ; >> } >A vastly superior solution in that there is nothing implicit happening. The >typical Pascal error is that it is never clear what 'd' is a reference to. Typical for who? Anyone framiliar with nested block structured languages should have no problem with this. Certainly "never" is too strong a qualifier. >(for example, declare a local variable by the name of 'd' - which one is >referenced?) 'd' refers to the field in the record. That's part of the scoping rules. Don't you ever have local variables whose names clash with names of global variables? (If not, I applaud you, but since C doesn't allow nested procedures the temptation is very much less.) > This C solution obviates the problem and is worth whatever the >cost may be. I disagree. The 'cost' is clarity and efficiency. I want both of these. I mean, why declare, initialise and use a thoroughly useless local variable when all you wanted was a (constant offset) field in a record anyway? -- Scott Schwartz schwartz@gondor.psu.edu
rpd@F.GP.CS.CMU.EDU.UUCP (11/04/87)
The topic under discussion is the Pascal WITH statement and C equivalents. Dan Rober points out that, in C, it is easy to declare a local pointer variable and initialize it with the address of the structure to be manipulated. He claims that this approach avoids ambiguities present in the WITH statement. Scott Schwartz isn't convinced and feels that "Anyone framiliar [sic] with nested block structured languages should have no problem with this." I have to agree with Dan's position. In my experience, every WITH statement is a mystifying bug waiting to happen. Consider the following fragment of code: VAR foo : integer; BEGIN WITH a.b.c DO foo = bar + baz END; where bar & baz are fields of a.b.c. This is code buried in some obscure long-forgotten part of your program. Now you decide to add a new field to a.b.c, and call it foo. All of a sudden that old code which you didn't touch and certainly didn't think to look at stops working. The upshot is that by using WITH the programmer throws away the advantages that block structure is supposed to give him. Rich
garys@bunker.UUCP (Gary M. Samuelson) (11/04/87)
In article <1025@phoenix.Princeton.EDU> asjoshi@phoenix.UUCP (Amit S. Joshi) writes: >I have gotten really tired of typing things like a.b.c.d etc to refer to >elements of a structure. I remember that pascal provided me with a 'with' >construction which allowed me to say something like > "with a.b.c {now refering to d really means use a.b.c.d } ..." >I was wondering if there is some similar contruct in C. No, there is nothing in C like Pascal's 'with'. But you can use: #define d a.b.c.d and "now referring to d really means use a.b.c.d". You have to do this with each member name you use, but that's not too bad if you have an editor which makes it easy to make several copies of the same line. Then where the end of the 'with' is, you could put #undef d Or you can use #define W(x) a.b.c.x W(d) = 1; W(e) = 2; etc. Hope this helps. Gary Samuelson AyoDu'reVweAlcNomCeE
henry@utzoo.UUCP (Henry Spencer) (11/05/87)
> I have gotten really tired of typing things like a.b.c.d etc to refer to > elements of a structure. I remember that pascal provided me with a 'with' > construction which allowed me to say something like > "with a.b.c {now refering to d really means use a.b.c.d } ..." > I was wondering if there is some similar contruct in C... Nothing quite the same, but you can come close. If all you want is the abbreviation, just #define IT a.b.c and then refer to IT.d or whatever. If you also want the efficiency boost that some Pascal compilers give you this way, then struct whatever *it = &a.b.c; and then refer to it->d or whatever. These aren't quite as convenient as Pascal when there is only one structure in use, but unlike Pascal they work even when there is more than one (just use separate IT/it names). -- Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology are condemned to reinvent it. | {allegra,ihnp4,decvax,utai}!utzoo!henry
mccaugh@uiucdcsb.cs.uiuc.edu (11/07/87)
Re: The one Pascal compiler which implements WITH using pointers ---- If it does, it is most atypical, as every one of the Pascal compilers I have experience with do NOT use this approach, but resort instead to strictly relative-addressing, with no resort to indirection (which MAY carry a cost). -- Scott (mccaugh@uiucmsl)
cik@l.cc.purdue.edu (Herman Rubin) (11/07/87)
In article <8888@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: > > I have gotten really tired of typing things like a.b.c.d etc to refer to > > elements of a structure. .... ...... > Nothing quite the same, but you can come close. If all you want is the > abbreviation, just > > #define IT a.b.c > > and then refer to IT.d or whatever. If you also want the efficiency boost > that some Pascal compilers give you this way, then > > struct whatever *it = &a.b.c; > > and then refer to it->d or whatever. .... > Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology > are condemned to reinvent it. | {allegra,ihnp4,decvax,utai}!utzoo!henry This is another example of the use of unnecessarily complicated syntax. The use of unions in C is far more messy than that of equivalence in FORTRAN. What is needed is a massive extension of the common block idea in FORTRAN without forcing common together with extension of equivalence. In addition, if the block is external, only the first part need be given, with an indication that this is the case. As an example, I use a subroutine linkage call in which I would like my declaration to read #extern array block{*routine r, *TYPE abc[3]}; and my call to read r(array); and referring the the I-th pointer in abc as abc[I], instead of what I am now doing, which is using union point array[]; and then making the call array[0].r(array); and having to use array[I+1].T instead of abc[I]. Since "a pointer is a pointer is a pointer", someone like myself who does not believe in requiring strong typing would like to have a type "pointer" which can be any type of pointer. This would help since I could use pointer array. We should let the compiler read through the chain of structures instead of requiring the programmer to use ->'s and .'s. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (ARPA or UUCP) or hrubin@purccvm.bitnet
ljz@fxgrp.UUCP (Lloyd Zusman) (11/08/87)
In article <3022@bunker.UUCP> garys@bunker.UUCP (Gary M. Samuelson) writes: >In article <1025@phoenix.Princeton.EDU> asjoshi@phoenix.UUCP (Amit S. Joshi) writes: >>I have gotten really tired of typing things like a.b.c.d etc to refer to >>elements of a structure ... There have been several suggestions, most of them involving the use of #define's for the higher-order structure elements (i.e., "#define foo a.b.c", thereby causing foo.d to refer to the a.b.c.d element). But I came up with a slightly different approach you might want to try ... #define WITH(Name, Type, Struct) { Type *Name = &(Struct); #define ENDWITH } Assume these three macros are defined. The following program fragment illustrates how they can be used ... struct baz { int a; int b; int c; }; struct bar { struct baz i; struct baz j; struct baz k; }; struct foo { struct bar x; struct bar y; struct bar z; }; struct foo p; struct foo q; struct foo r; . . . WITH (X, struct baz, p.z.i) X->a = 1; X->b = 2; X->c = 3; ENDWITH The above 5 lines translate to { struct baz *X = &(p.z.i); X->a = 1; X->b = 2; X->c = 3; } This is a variation of another method I saw here on the net. I do it this way so that you still have a WITH-like environment and the WITH section is in a separate block of code wherein you can define local variables, etc. If #define's could be nested within other #define's, you could get rid of one or two of the arguments to the WITH macro. Oh well. -- Lloyd Zusman, Master Byte Software, Los Gatos, California "We take things well in hand." ...!ames!fxgrp!ljz
peter@sugar.UUCP (Peter da Silva) (11/09/87)
In article <3048@psuvax1.psu.edu>, schwartz@gondor.psu.edu (Scott E. Schwartz) writes: > In article <5673@weitek.UUCP> rober@weitek.UUCP (Don Rober) writes: > >>A simple solution (sligthly inefficient). Rewrite > >> with a.b.c begin > >> d = 10 ; > >> end > >>as > >> { > >> struct <whatever> *s = &a.b.c ; > >> s->d = 10 ; > >> } > >A vastly superior solution in that there is nothing implicit happening. The > >typical Pascal error is that it is never clear what 'd' is a reference to. > > Typical for who? Anyone framiliar with nested block structured languages > should have no problem with this. Certainly "never" is too strong a > qualifier. {$include structs.hdr} procedure mung(e: integer); var d: integer; begin with a.b.c begin d = 10.5; d = d + e end end; Looking at this program, can you tell me what the compiler will do? Is d an element of a.b.c, of type float, or isn't it? Is e part of d, or the calling argument to mung. Now whenever you add an element to a record you have to look at ALL the code that might use the record to look for puns like this. In 'C' it's explicit. Yes, Virginia, there are advantages to 'C' over Pascal. (and vice-versa, naturally). -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- Disclaimer: These U aren't mere opinions... these are *values*.
levy@ttrdc.UUCP (Daniel R. Levy) (11/10/87)
In article <8888@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: > Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology ^^^^ That's THE UNIX* OPERATING SYSTEM, Buster! * Registered Trademark of AT&T > are condemned to reinvent it. | {allegra,ihnp4,decvax,utai}!utzoo!henry -- |------------Dan Levy------------| Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, | an Engihacker @ | vax135}!ttrdc!ttrda!levy | AT&T Computer Systems Division | Disclaimer? Huh? What disclaimer??? |--------Skokie, Illinois--------|
karl@haddock.ISC.COM (Karl Heuer) (11/10/87)
In article <608@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >Since "a pointer is a pointer is a pointer", someone like myself who does not >believe in requiring strong typing would like to have a type "pointer" which >can be any type of pointer. This would help since I could use pointer array. /* ENFLAME */ Since all the world's a VAX, someone like yourself would probably be better off using assembler. /* DEFLAME */ There is a "universal pointer type"; it's called "char *" in K&R C and "void *" in ANSI. (Added to distinguish generic pointers from char pointers, but otherwise pretty much equivalent to "char *".) What this means is that any pointer type can be cast into "void *" and back again. It does not imply that all pointer types are the same format or size. The existence of "pointer to array" is an independent issue. In a sense, it's always been legal, but PCC-based compilers have traditionally misinterpreted any attempts to use such an object. ANSI has fixed this. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
ljz@fxgrp.UUCP (Lloyd Zusman) (11/11/87)
In article <1953@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >> Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology > >That's THE UNIX* OPERATING SYSTEM, Buster! > >* Registered Trademark of AT&T Oops! I guess we should change the names of all the newsgroups that contain the word "unix" in them. For example, comp.sources.unix should now be called comp.sources.THE_UNIX_(Registered_Trademark_of_AT&T)_OPERATING_SYSTEM No problem. -- Lloyd Zusman, Master Byte Software, Los Gatos, California "We take things well in hand." ...!ames!fxgrp!ljz
chris@mimsy.UUCP (Chris Torek) (11/12/87)
[Aside to ljz: you are misusing the `Followup-To' header. It is supposed to redirect followup messages to another newsgroup, not indicate the article to which this message is a followup. *That* funciton belongs to the `References' line, which is maintained automatically by current netnews software (including yours).] In article <150@fxgrp.UUCP> ljz@fxgrp.UUCP (Lloyd Zusman) writes: >#define WITH(Name, Type, Struct) { Type *Name = &(Struct); >#define ENDWITH } ... > WITH (X, struct baz, p.z.i) > X->a = 1; > X->b = 2; > X->c = 3; > ENDWITH The problem with such macros is that they rapidly get out of hand. Perhaps no one will sue me for posting the following extract: readsym() { REG char *p; p = isymbol; REP IF p < &isymbol[sizeof(isymbol)-1] THEN *p++ = lastc; FI readchar(); PER symchar(1) DONE *p++ = 0; } symchar(dig) { IF lastc=='\\' THEN readchar(); return(TRUE); FI return( isalpha(lastc) ORF lastc=='_' ORF dig ANDF isdigit(lastc) ); } (Yes, the above *is* C code.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
chris@mimsy.UUCP (Chris Torek) (11/12/87)
In article <608@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: [a great deal of stuff that makes C sound bad] >Since "a pointer is a pointer is a pointer", It is? Obviously you have never used an IBM PC. Nor a DG MV/10000. Nor . . . . -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
daveb@geac.UUCP (11/12/87)
|In article <8888@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes: || struct whatever *it = &a.b.c; || and then refer to it-|d or whatever. .... || || Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology || are condemned to reinvent it. | {allegra,ihnp4,decvax,utai}!utzoo!henry In article <608@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: |We should let the compiler read through the chain of structures instead of |requiring the programmer to use ->'s and .'s. Apologies to Mr Rubin in advance: I just couldn't resist the following... >> Those who do not understand PL/I | Imaginary Guru @ Somewhere >> are condemned to reimplement it. |{place,place,place}!Somewhere!guru --dave (mea culpa, mea maxima culpa) c-b -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.
levy@ttrdc.UUCP (Daniel R. Levy) (11/12/87)
In article <158@fxgrp.UUCP>, ljz@fxgrp.UUCP (Lloyd Zusman) writes: #> In article <1953@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: #> >> Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology #> > #> >That's THE UNIX* OPERATING SYSTEM, Buster! #> > #> >* Registered Trademark of AT&T #> #> Oops! I guess we should change the names of all the newsgroups that #> contain the word "unix" in them. For example, comp.sources.unix should #> now be called #> comp.sources.THE_UNIX_(Registered_Trademark_of_AT&T)_OPERATING_SYSTEM #> No problem. This is not a valid analogy. It is quite proper to use the term "UNIX" as an adjective. -- |------------Dan Levy------------| Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, | an Engihacker @ | vax135}!ttrdc!ttrda!levy | AT&T Computer Systems Division | Disclaimer? Huh? What disclaimer??? |--------Skokie, Illinois--------|
TGMIKEY%CALSTATE.BITNET@wiscvm.wisc.EDU (Account Manager) (11/12/87)
Received: by CALSTATE via BITNet with NJF for TGMIKEY@CALSTATE; Comment: 10 Nov 87 02:54:35 PST Received: by BYUADMIN (Mailer X1.24) id 1937; Tue, 10 Nov 87 03:52:33 MST Date: 30 Oct 87 17:44:39 GMT Reply-To: Info-C@BRL.ARPA Sender: INFO-C@NDSUVM1 From: asjoshi@phoenix.Princeton.EDU Subject: Question on structures Comments: To: info-c@BRL-SMOKE.arpa To: TGMIKEY@CCS.CSUSCC.CALSTATE.EDU Hi, I have a question on structures. It is as follows: I have gotten really tired of typing things like a.b.c.d etc to refer to elements of a structure. I remember that pascal provided me with a 'with' construction which allowed me to say something like "with a.b.c {now refering to d really means use a.b.c.d } ..." I was wondering if there is some similar contruct in C. I might be missing something obvious, I wonder if somebody could help me ?. I know I could of course make a local copy in the program of every variable in the structures and then use the local copy but that seems inefficient and would be quite unclear. Thanks, -- Amit Joshi BITNET : Q3696@PUCC.BITNET USENET : ...seismo!princeton!phoenix!asjoshi "There's a pleasure in being mad ...which none but madmen know!" St.Dryden ===== Reply from Mike Khosraviani <TGMIKEY> ========================== Unfortunately, C has nothing like the WITH statement in Pascal. Howerver, there are many ways of getting around the extra typing that you have to do! One quick and dirty way is to use SUPERKEY. I am assuming that you know what SUPERKEY is and how it works. If not, let me know and I'll provide you with more information. For short, SUPERKEY can reduce a lot of typing that you have to do. It is GREAT!!!! Mike says hi and have lots of FUN
henry@utzoo.UUCP (Henry Spencer) (11/15/87)
> > Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology > ^^^^ > > That's THE UNIX* OPERATING SYSTEM, Buster! > > * Registered Trademark of AT&T My my, touchy, aren't we? :-) I'm afraid I'm just an old fogey who can't used to AT&T Newspeak. I picked up the habit of writing it "Unix" from dubious, sloppy people like Ken Thompson and Dennis Ritchie :-), back in the mid-1970s when nobody wrote it any other way. As for the mandatory inclusion of "Operating System" (or, worse, "OPERATING SYSTEM"), I'm afraid I picked up my sloppiness in this regard from subversive influences like Bell/WE/AT&T software licenses and official letters signed by people like Western Electric's licensing director. References available on request [I knew that hanging onto all that old paperwork would come in handy someday]. Obviously I shouldn't have listened to such villains... Now, boys and girls, remember that the sarcastic, uncooperative attitude displayed above demonstrates clear contempt for AT&T trademarks -- an obvious case of CRIMETHINK. Everyone, including me, who has varied from Officially Approved Practices in speaking of certain items of AT&T software should at once face in the direction of New Jersey and abase themselves three times in hopes of forgiveness, while swearing to (a) faithfully follow whatever AT&T's Terminology Of The Week happens to be this week, and (b) firmly believe that it was never any other way. -- Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry
daveb@geac.UUCP (11/17/87)
In article <1953@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >> Those who do not understand Unix | Henry Spencer @ U of Toronto Zoology > >That's THE UNIX* OPERATING SYSTEM, Buster! >* Registered Trademark of AT&T ... [some complaints from elsewhere] ... >This is not a valid analogy. It is quite proper to use the term "UNIX" as >an adjective. Er, if there's a copyright on it, the term "Unix" will be being used as an adjective, modifying the noun phrase "time-sharing system". Otherwise the copyright would apply to all posible uses of the term, and would fail/be rejected. --dave -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.
chet@mandrill.UUCP (11/19/87)
In article <9308@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
[two C functions with a distinct Algol flavor]
Ah yes, the V7 Bourne Shell, still alive and kicking in 4.3BSD. But
how could you leave out LOOP-POOL, IF, ORF, and ANDF, not to mention
ELIF, WHILE-DO-OD, and SWITCH-IN-ENDSW?
Did Steve really feel that much more comfortable writing Algol than C?
Chet Ramey chet@mandrill.CWRU.Edu {cbosgd,decvax,sun}!mandrill!chet
I think that all right-thinking people in this country are sick and
tired of being told that ordinary decent people are fed up in this
country with being sick and tired. I'm certainly not. But I'm
sick and tired of being told that I am.
Monty Python