delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/02/04/06:46:18

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: 04 Feb 2004 13:19:49 +0200
Message-Id: <uptcv9jmy.fsf@elta.co.il>
From: Eli Zaretskii <eliz AT elta DOT co DOT il>
To: djgpp AT delorie DOT com
In-reply-to: <20040204035022.22737.00000765@mb-m19.aol.com> (sterten@aol.com)
Subject: Re: array indices [i][j]
References: <uy8rj5r98 DOT fsf AT elta DOT co DOT il> <20040204035022 DOT 22737 DOT 00000765 AT mb-m19 DOT aol DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: sterten AT aol DOT com (Sterten)
> Newsgroups: comp.os.msdos.djgpp
> Date: 04 Feb 2004 08:50:22 GMT
> 
> why should someone want to take a value - and then discard it ?

It is useful when the computation has a side effect.  For example:

   for (x = 1, y = 0, z = 100; x < 100; x++, y++)

Here the expression "x = 1" yields a value of 1, but it also has a
side effect of assigning 1 to x.

> I mean, if this A[i,j,k] isn't really needed, then can't we
> define it to be A[i][j][k] ?

No, we can't, since the basic syntax of C cannot be changed without
changing the language.

>  >  #define MA(i,j,k) A[i][j][k]
>  >
>  >(note the use of parentheses instead of square brackets), or a similar
>  >definition of an inline function.
> 
> very good !

Actually, not very good because using macros to change a syntactic
appearance of a programming language is generally a bad habit.  For
starters, people who read your program will have difficulty
understanding the code.  And you yourself prevent yourself from
learning C faster.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019