Re: Poll: global buffers

From: Welcor (
Date: 07/21/01

----- Original Message -----
From: "George Greer" <greerga@CIRCLEMUD.ORG>
> Who thinks the global buffers (buf, buf1, buf2, arg) need to go?
> Who wants to keep them?
I might be going against the general trend here; I'm quite happy with the
global buffer system, thank you.

> and why?
First off, it makes for better memory efficiency to have those 4 global
buffers to write to, instead of allocating stack space for every function.

Second, about shadowing: It is ok to declare a local variable named buf.
This will shadow the global buffer, and in that particular function you
can act as if the (global) buf didn't exist. As long as you know when you're
doing it, shadowing isn't necessarily such a bad thing. (I figure some of
you don't agree on this, reading your previous posts. I'm afraid it's a
question of personal taste, and cannot be discussed.)

In short: The global buffers are a help as long as you know what you're
doing. Being a newbie coder is something we've all tried. Having to deal
with *buf = '\0' is just another thing. Heck, in the beginning I just
added that line to all of my new functions. It worked. :P
As long as you always assume buf to contain (strange/garbage) data from the
beginning, you can make it work just as you want.

> I'm curious.

Anything to satisfy your curiousity.


   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/06/01 PST