missing ->= operator

Eize Oosting eoo at let.rug.nl
Wed May 1 08:29:16 AEST 1991


In article <9104291641.AA00534 at dutiaa.tudelft.nl> schuller at DUTIAA.TUDELFT.NL (Schuller Schuller Oijen) writes:
>Hi all,
>recently I've been doing a lot of C pointer programming and I came upon
>a missing feature in C. Suppose you have this struct called mygod :
>	typedef struct mygod
>	{
>		int value;
>		struct mygod *next;
>	} mygod_struct
>What you do quite often is : mygodptr = mygodptr->next;
>Now C has all these wonderful operators : a += 7, g &= 0xf, etc, etc.
>But the ->= operator is missing! You cannot do mygodptr ->= next; !
>All of you who want to fill this gap, please react. Flames to /dev/null.
>Bye! Hildo Biersma, schuller at dutiad.tudelft.nl

It sounds wonderfull, but it would ask for an Object Oriented style, and
C is just not OO. Maybe this would be something for C++.

What you can do is something like this:

#define NEXT(ptr)  ptr = ptr->next

It isn't the nicest solution, but it works.

  /\__________/\   /\___________________________________________________/\
 /              \ /                                                       \
|   Letteren-    |  Marvin Minsky once defined Artificial Intelligence as: |
|   Faculteit    |   '... the science of making machines do things that    |
| R.U. Groningen |   would require intelligence if done by men'.           |
| The Netherlands|                                                         |
|                |  Does this include formatting a floppy?                 |
| eoo at let.rug.nl |                                           Eize Oosting  |
 \  __________  / \  ___________________________________________________  /
  \/          \/   \/                                                   \/



More information about the Comp.lang.c mailing list