Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 1997 01:07:42 -0400
From:      Joel Ray Holveck <joelh@gnu.ai.mit.edu>
To:        sef@kithrup.com
Cc:        chat@FreeBSD.ORG
Subject:   Re: variable sized arrays and gcc
Message-ID:  <199708110507.BAA06614@ethanol.gnu.ai.mit.edu>
In-Reply-To: <199708101845.LAA21530@kithrup.com> (message from Sean Eric Fagan on Sun, 10 Aug 1997 11:45:58 -0700)

next in thread | previous in thread | raw e-mail | index | archive | help

>>> The feature will now make it into the next ANSI C version.  (Along with a
>>> bunch of stuff that is *WRONG* and *EVIL*.  But this particular feature I
>>> happen to like.)
>> Like what?
> The one I particularly hate, which distresses me greatly, is the C++-ish
> ability to declare a variable anywhere.  E.g.,

Okay, why is this a lose?  Remember that computer languages must be
readable by humans to win; the ability to declare variables where they
are used means a more readable, ergo more maintainable, language.

> It's not as if any existing code truly uses this --

It wasn't that long ago that all existing code used K&R declarations.
Were you out on your soapbox at the proposal of ANSI declarations,
saying that no existing code used them?

> It adds very little to the language, except
> for an ability to have even more badly written code,

Why is this badly written code?  Because of the portability issue?  If
you are targeting a single compiler, then portability isn't an issue.
If you aren't, then ignore the feature, and wait for other compiler
vendors to catch on.

> and will make some compilers a bit harder to write (but that's
> balanced by making others a bit easier to write).

The requirement to declare variables at the top of a function is an
anachronism from when the stack had to be manipulated in a particular
manner.  In this day and age of modern register manipulation and
dynamic variable allocation, your preferred rule is an ugly
requirement that means that declarations cannot appear near where they
are used, and decreases the readability-- hence maintainability-- of
the code.

GCC defines a language which is a superset of C.  It has some features
that make writing programs nicer and easier.  I prefer the language
that GCC defines to the one that the ANSI committee defined.  It is a
more readable, more flexible, language.

Happy hacking,
joelh

-- 
Second law of programming:
Anything that can go wrong wi
sendmail: segmentation violation -- core dumped



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708110507.BAA06614>