Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!calma!clark From: clark@calma.uucp (Al Clark) Newsgroups: comp.lang.c Subject: Re: Question on structures Message-ID: <700@calma.uucp> Date: Mon, 2-Nov-87 01:44:17 EST Article-I.D.: calma.700 Posted: Mon Nov 2 01:44:17 1987 Date-Received: Thu, 5-Nov-87 22:25:00 EST References: <1025@phoenix.Princeton.EDU> <11782@beta.UUCP> Reply-To: clark@calma.UUCP (Al Clark) Organization: GE/Calma Co., R&D Systems Engineering, Milpitas, CA Lines: 41 Summary: Use #define for shorthand notations. 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.