Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22223 > unrolled thread

What a stupid gcc!

Started byzgene <nospam@nospam.com>
First post2012-06-13 21:41 +0000
Last post2012-06-14 23:21 +0000
Articles 17 on this page of 97 — 29 participants

Back to article view | Back to comp.lang.c


Contents

  What a stupid gcc! zgene <nospam@nospam.com> - 2012-06-13 21:41 +0000
    Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-13 18:01 -0400
      Re: What a stupid gcc! Noob <root@127.0.0.1> - 2012-06-14 13:00 +0200
        Re: What a stupid gcc! Nomen Nescio <nobody@dizum.com> - 2012-06-14 14:33 +0200
          Re: What a stupid gcc! Rui Maciel <rui.maciel@gmail.com> - 2012-06-14 14:46 +0100
          Re: What a stupid gcc! Noob <root@127.0.0.1> - 2012-06-14 18:19 +0200
    Re: What a stupid gcc! Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-13 18:06 -0400
    Re: What a stupid gcc! jt@toerring.de (Jens Thoms Toerring) - 2012-06-13 22:19 +0000
      Re: What a stupid gcc! Rui Maciel <rui.maciel@gmail.com> - 2012-06-14 09:47 +0100
        Re: What a stupid gcc! Rui Maciel <rui.maciel@gmail.com> - 2012-06-14 14:37 +0100
    Re: What a stupid gcc! Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-06-13 17:05 -0600
    Re: What a stupid gcc! Nick Bowler <nbowler@draconx.ca> - 2012-06-14 00:09 +0000
    Re: What a stupid gcc! Varun Tewari <tewari.varun@gmail.com> - 2012-06-14 03:14 -0700
      Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-14 06:56 -0400
      Re: What a stupid gcc! Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-06-17 07:18 +0000
        Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-17 11:47 +0100
          Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-17 09:31 -0400
            Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-18 12:34 +0100
              Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-18 08:18 -0400
                Re: What a stupid gcc! gwowen <gwowen@gmail.com> - 2012-06-18 05:42 -0700
                  Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-18 09:39 -0400
                Re: What a stupid gcc! Rich Webb <bbew.ar@mapson.nozirev.ten> - 2012-06-18 09:06 -0400
                  Re: What a stupid gcc! ImpalerCore <jadill33@gmail.com> - 2012-06-18 07:18 -0700
              Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-19 00:13 -0700
                Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 11:28 +0100
                  Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 07:30 -0400
                  Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-20 00:16 -0700
          Re: What a stupid gcc! Rui Maciel <rui.maciel@gmail.com> - 2012-06-17 15:52 +0100
          Re: What a stupid gcc! Noob <root@localhost> - 2012-06-18 09:07 +0200
          Re: What a stupid gcc! Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-06-18 09:03 +0000
          Re: What a stupid gcc! Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-06-18 16:02 +0000
            Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-18 19:40 +0100
              Re: What a stupid gcc! Noob <root@localhost> - 2012-06-18 23:52 +0200
              Re: What a stupid gcc! Ike Naar <ike@iceland.freeshell.org> - 2012-06-18 23:09 +0000
                Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 01:30 +0100
                  Re: What a stupid gcc! Ian Collins <ian-news@hotmail.com> - 2012-06-19 13:03 +1200
                    Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 06:34 -0400
                  Re: What a stupid gcc! Ike Naar <ike@sverige.freeshell.org> - 2012-06-19 08:43 +0000
                    Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 11:00 +0100
                      Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 07:05 -0400
                      Re: What a stupid gcc! Ian Collins <ian-news@hotmail.com> - 2012-06-19 23:21 +1200
                        Re: What a stupid gcc! Ian Collins <ian-news@hotmail.com> - 2012-06-19 23:22 +1200
                      Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-19 13:45 +0100
                        Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 15:23 +0100
                          Re: What a stupid gcc! Ike Naar <ike@iceland.freeshell.org> - 2012-06-19 16:14 +0000
                            Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 18:01 +0100
                              Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 13:59 -0400
                              Re: What a stupid gcc! Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-06-19 15:29 -0600
                          Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-19 18:22 +0100
                            Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-19 21:13 +0100
                              Re: What a stupid gcc! Lew Pitcher <lpitcher@teksavvy.com> - 2012-06-19 16:27 -0400
                              Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 16:38 -0400
                                Re: What a stupid gcc! Kenneth Brody <kenbrody@spamcop.net> - 2012-06-20 09:47 -0400
                              Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-19 22:44 +0100
                                Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-21 01:39 -0700
                                  Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-21 10:55 +0100
                                    Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-21 04:11 -0700
                                      Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-21 12:36 +0100
                                        Re: What a stupid gcc! David Brown <david@westcontrol.removethisbit.com> - 2012-06-21 15:33 +0200
                                    Re: What a stupid gcc! Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-06-21 14:15 +0000
                              Re: What a stupid gcc! Kenneth Brody <kenbrody@spamcop.net> - 2012-06-20 09:37 -0400
                                Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-20 14:54 +0100
                                  Re: What a stupid gcc! Kenneth Brody <kenbrody@spamcop.net> - 2012-06-20 18:19 -0400
                                    Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-21 00:13 +0100
                                      Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-21 02:09 +0100
                                        Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-21 02:05 -0700
                                        Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-21 11:49 +0100
                                          Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-21 14:24 +0100
                                          Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-22 00:38 -0700
                                            Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-22 13:37 +0100
                                      Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-21 01:57 -0700
                                        Re: What a stupid gcc! "BartC" <bc@freeuk.com> - 2012-06-21 11:46 +0100
                                      Re: What a stupid gcc! Kenneth Brody <kenbrody@spamcop.net> - 2012-06-21 14:37 -0400
                                        Re: What a stupid gcc! Andrew Smallshaw <andrews@sdf.lonestar.org> - 2012-06-21 19:38 +0000
                                  Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-21 01:41 -0700
                                    Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-21 12:28 +0100
                Re: What a stupid gcc! Kaz Kylheku <kaz@kylheku.com> - 2012-06-19 15:05 +0000
          Re: What a stupid gcc! Ian Collins <ian-news@hotmail.com> - 2012-06-19 09:37 +1200
            Re: What a stupid gcc! ImpalerCore <jadill33@gmail.com> - 2012-06-18 15:18 -0700
            Re: What a stupid gcc! Paul J Gans <gansno@panix.com> - 2012-06-18 23:21 +0000
              Re: What a stupid gcc! Ian Collins <ian-news@hotmail.com> - 2012-06-19 11:26 +1200
                Re: What a stupid gcc! Paul J Gans <gansno@panix.com> - 2012-06-19 01:46 +0000
                  Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 07:19 -0400
                  Re: What a stupid gcc! Stephen Sprunk <stephen@sprunk.org> - 2012-06-19 08:01 -0500
                  Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 09:25 -0400
                    Re: What a stupid gcc! Les Cargill <lcargill99@comcast.com> - 2012-06-19 12:57 -0500
                      Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-19 14:59 -0400
              Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-19 01:36 +0100
                Re: What a stupid gcc! Paul J Gans <gansno@panix.com> - 2012-06-19 01:48 +0000
            Re: What a stupid gcc! Les Cargill <lcargill99@comcast.com> - 2012-06-18 19:50 -0500
            Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-19 00:19 -0700
              Re: What a stupid gcc! Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-19 12:56 +0100
                Re: What a stupid gcc! nick_keighley_nospam@hotmail.com - 2012-06-20 00:26 -0700
                  Re: What a stupid gcc! James Kuyper <jameskuyper@verizon.net> - 2012-06-20 06:31 -0400
        Re: What a stupid gcc! Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-06-18 00:18 -0600
          Re: What a stupid gcc! Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-06-18 09:15 +0000
    Re: What a stupid gcc! Kaz Kylheku <kaz@kylheku.com> - 2012-06-14 23:21 +0000

Page 5 of 5 — ← Prev page 1 2 3 4 [5]


#22381

FromIan Collins <ian-news@hotmail.com>
Date2012-06-19 11:26 +1200
Message-ID<a49rouF7l4U2@mid.individual.net>
In reply to#22380
On 06/19/12 11:21 AM, Paul J Gans wrote:
> Ian Collins<ian-news@hotmail.com>  wrote:
>> On 06/17/12 10:47 PM, BartC wrote:
>>>
>>>
>>> "Jorgen Grahn"<grahn+nntp@snipabacken.se>   wrote in message
>>> news:slrnjtr16f.rk7.grahn+nntp@frailea.sa.invalid...
>>>> On Thu, 2012-06-14, Varun Tewari wrote:
>>>>> Its simply not stupid, its a simple fact the C++/Java allow
>>>>> decalaration anywhere in the code, but C wants them the first thing
>>>>> when you code. That's all
>>>>
>>>> You could say that "declarations only at the start of block" was a
>>>> stupid design ... I'm very happy this got changed, and it should
>>>> probably have happened earlier, when 'const' and such things were
>>>> introduced.
>>>>
>>>> Now all that remains is to educate the users.  Most code I read
>>>> doesn't even use the C89 "at the start of block" rule. It lumps all
>>>> the variables at the start of the function -- even those that are only
>>>> used and only make sense inside some loop, two pages down ...
>>>
>>> But what happens when the code defines a variable two pages into a function,
>>> but you happen to be reading some code using that same variable four pages
>>> into the function!
>
>> Then you (or the original authour) are doing something very very wrong.
>
>>> Where do you go to find the definition? At the start of a
>>> function is usually a good place! You don't always know that a variable is
>>> only used once.
>
>> C is the only language I know that had (in the last century) such
>> restrictive declaration rules.  You wouldn't see this argument on a
>> forum for another language.  If old C's declaration rules were such a
>> good idea, why have thy been ignored by most (all?) subsequent languages?
>
> I'd think the argument works the other way.  Back when C was
> new the other dominant language was FORTRAN.  Later came both
> Basic, Algol, and Cobol.  All were strongly typed languages.
>
> Of these only C survives to any major extent, proving, it seems
> to me, that it was the most *successful* of these languages.
> Indeed, it also shows that perhaps in spite of its strong typing,
> it has held up under the barrage of "new" languages.

What has strong typing do do with where a variable is declared?

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#22388

FromPaul J Gans <gansno@panix.com>
Date2012-06-19 01:46 +0000
Message-ID<jrolkr$eef$1@reader1.panix.com>
In reply to#22381
Ian Collins <ian-news@hotmail.com> wrote:
>On 06/19/12 11:21 AM, Paul J Gans wrote:
>> Ian Collins<ian-news@hotmail.com>  wrote:
>>> On 06/17/12 10:47 PM, BartC wrote:
>>>>
>>>>
>>>> "Jorgen Grahn"<grahn+nntp@snipabacken.se>   wrote in message
>>>> news:slrnjtr16f.rk7.grahn+nntp@frailea.sa.invalid...
>>>>> On Thu, 2012-06-14, Varun Tewari wrote:
>>>>>> Its simply not stupid, its a simple fact the C++/Java allow
>>>>>> decalaration anywhere in the code, but C wants them the first thing
>>>>>> when you code. That's all
>>>>>
>>>>> You could say that "declarations only at the start of block" was a
>>>>> stupid design ... I'm very happy this got changed, and it should
>>>>> probably have happened earlier, when 'const' and such things were
>>>>> introduced.
>>>>>
>>>>> Now all that remains is to educate the users.  Most code I read
>>>>> doesn't even use the C89 "at the start of block" rule. It lumps all
>>>>> the variables at the start of the function -- even those that are only
>>>>> used and only make sense inside some loop, two pages down ...
>>>>
>>>> But what happens when the code defines a variable two pages into a function,
>>>> but you happen to be reading some code using that same variable four pages
>>>> into the function!
>>
>>> Then you (or the original authour) are doing something very very wrong.
>>
>>>> Where do you go to find the definition? At the start of a
>>>> function is usually a good place! You don't always know that a variable is
>>>> only used once.
>>
>>> C is the only language I know that had (in the last century) such
>>> restrictive declaration rules.  You wouldn't see this argument on a
>>> forum for another language.  If old C's declaration rules were such a
>>> good idea, why have thy been ignored by most (all?) subsequent languages?
>>
>> I'd think the argument works the other way.  Back when C was
>> new the other dominant language was FORTRAN.  Later came both
>> Basic, Algol, and Cobol.  All were strongly typed languages.
>>
>> Of these only C survives to any major extent, proving, it seems
>> to me, that it was the most *successful* of these languages.
>> Indeed, it also shows that perhaps in spite of its strong typing,
>> it has held up under the barrage of "new" languages.

>What has strong typing do do with where a variable is declared?

Historically?  Back when computers were slow and compilations
took forever, one wanted a one-pass compiler.  To do that (even
if there was a post-compilation "fix-up" cycle) one had to
have things declared prior to use.

Today that isn't so important, though programmers have their 
preferences. 

Speaking for myself I have no objection to block-level declaration
of temporary variables such as i or j.  However giving them
names that look like important variables in a routine can be
quite confusing, especially if you did not write the code and
are only maintaining it.

-- 
   --- Paul J. Gans

[toc] | [prev] | [next] | [standalone]


#22400

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-06-19 07:19 -0400
Message-ID<jrpn8s$ppu$1@dont-email.me>
In reply to#22388
On 06/18/2012 09:46 PM, Paul J Gans wrote:
> Ian Collins <ian-news@hotmail.com> wrote:
>> On 06/19/12 11:21 AM, Paul J Gans wrote:
...
>>> I'd think the argument works the other way.  Back when C was
>>> new the other dominant language was FORTRAN.  Later came both
>>> Basic, Algol, and Cobol.  All were strongly typed languages.
>>>
>>> Of these only C survives to any major extent, proving, it seems
>>> to me, that it was the most *successful* of these languages.
>>> Indeed, it also shows that perhaps in spite of its strong typing,
>>> it has held up under the barrage of "new" languages.
> 
>> What has strong typing do do with where a variable is declared?
> 
> Historically?  Back when computers were slow and compilations
> took forever, one wanted a one-pass compiler.  To do that (even
> if there was a post-compilation "fix-up" cycle) one had to
> have things declared prior to use.

That's a separate issue, though a related one. In C, the scope of a
block-scope declaration does not start until it's declarator is
complete, a fact which is related to the issue you raise. However, the
scope ends with the enclosing block, and that's what's relevant to the
issue we're talking about.

What we're talking about would remain an issue even if C were modified
to extend the scope of a declaration to beginning of the enclosing
block. The key issue is the fact that the scope is associated with the
enclosing block, and whether or not it's a good idea to take advantage
of this fact in any block other than the outermost one.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#22407

FromStephen Sprunk <stephen@sprunk.org>
Date2012-06-19 08:01 -0500
Message-ID<jrpt88$tho$1@dont-email.me>
In reply to#22388
On 18-Jun-12 20:46, Paul J Gans wrote:
> Historically?  Back when computers were slow and compilations
> took forever, one wanted a one-pass compiler.  To do that (even
> if there was a post-compilation "fix-up" cycle) one had to
> have things declared prior to use.

I thought the issue wasn't so much speed but rather that computers of
the day didn't have enough memory to hold a source file entirely in
memory, which would be required for two (or more) passes.  Being able to
emit object code as the compiler progressed and then forget it allowed a
compiler to handle arbitrarily large source files.

S


-- 
Stephen Sprunk         "God does not play dice."  --Albert Einstein
CCIE #3723         "God is an inveterate gambler, and He throws the
K5SSS        dice at every possible opportunity." --Stephen Hawking

[toc] | [prev] | [next] | [standalone]


#22408

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-06-19 09:25 -0400
Message-ID<jrpukn$4s7$1@dont-email.me>
In reply to#22388
On 06/18/2012 09:46 PM, Paul J Gans wrote:
...
> Historically?  Back when computers were slow and compilations
> took forever, one wanted a one-pass compiler.  To do that (even
> if there was a post-compilation "fix-up" cycle) one had to
> have things declared prior to use.

Keep in mind that C's permission for the existence of tentative
definitions interferes with on-pass compilation.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#22417

FromLes Cargill <lcargill99@comcast.com>
Date2012-06-19 12:57 -0500
Message-ID<jrqec2$dam$1@dont-email.me>
In reply to#22408
James Kuyper wrote:
> On 06/18/2012 09:46 PM, Paul J Gans wrote:
> ...
>> Historically?  Back when computers were slow and compilations
>> took forever, one wanted a one-pass compiler.  To do that (even
>> if there was a post-compilation "fix-up" cycle) one had to
>> have things declared prior to use.
>
> Keep in mind that C's permission for the existence of tentative
> definitions interferes with on-pass compilation.
>


I can't say what ancient compiler chains did, but at
least since the '80s, the *linker* fixes up all the
tentative declarations ( unless I miss your meaning* ).

The compilation phase "knows" every jot and tittle except
externally referenced things.

*SFAIK, that's 100% "extern" stuff... in the case
of variably sized arrays, even that is fully nailed down
at compile time (by declarations of instances ) unless I've missed 
something. It'll gen an error if you don't fully qualify
the size of something, and idioms like "extern long gee[]" do
not allow for knowing the size of "gee[]" in that scope.

--
Les Cargill

[toc] | [prev] | [next] | [standalone]


#22419

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-06-19 14:59 -0400
Message-ID<4FE0CC24.5000007@verizon.net>
In reply to#22417
On 06/19/2012 01:57 PM, Les Cargill wrote:
> James Kuyper wrote:
...
>> Keep in mind that C's permission for the existence of tentative
>> definitions interferes with on-pass compilation.

on => one

> I can't say what ancient compiler chains did, but at
> least since the '80s, the *linker* fixes up all the
> tentative declarations ( unless I miss your meaning* ).
> 
> The compilation phase "knows" every jot and tittle except
> externally referenced things.
> 
> *SFAIK, that's 100% "extern" stuff... in the case
> of variably sized arrays, even that is fully nailed down
> at compile time (by declarations of instances ) unless I've missed 
> something. It'll gen an error if you don't fully qualify
> the size of something, and idioms like "extern long gee[]" do
> not allow for knowing the size of "gee[]" in that scope.

Tentative definitions aren't 100% 'extern'. That keyword appears only
once in the code below, and that usage is unnecessary, because it
doesn't change anything. 'a' and 'b' below both have internal linkage.
However, if a tentative definition has internal linkage, it must have a
complete type, so such declarations don't cause problems for one-pass
compilation. However, I believe that the fact that the declarations for
'd' and 'e' below are allowed does make one-pass compilation a little
more difficult:

/* Tentative definitions:	*/
static int a, b;
int c;
int d[];
struct mystruct e;

/* Code which makes use of these variables, but never uses d or e in any
way that requires them to have a complete type. */

/* More tentative definitions:	*/
int d[10];
struct mystruct {
    int i;
    double d;
} e;

/* External definitions:	*/
static int a=1;
int b=2;

/* Neither a tentative definition nor an external definition */	
extern int c;

[toc] | [prev] | [next] | [standalone]


#22384

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-06-19 01:36 +0100
Message-ID<0.21bd50a61c77bedd19ff.20120619013652BST.87vciorvbv.fsf@bsb.me.uk>
In reply to#22380
Paul J Gans <gansno@panix.com> writes:
I've snipped all the context because I don't think you address the issue
where variables are declared.  But I do want to comment...

> I'd think the argument works the other way.  Back when C was
> new the other dominant language was FORTRAN.  Later came both
> Basic, Algol, and Cobol.  All were strongly typed languages.

Cobol was massive long before C came along, and Algol dates from the
1950s.  Basic is a little younger than Algol, but it was around in the
1960s and was riding a wave caused by the boom in microprocessors
(admittedly in a dizzying array of dialects) when most people started to
became aware of C.

> Of these only C survives to any major extent, proving, it seems
> to me, that it was the most *successful* of these languages. 
> Indeed, it also shows that perhaps in spite of its strong typing,
> it has held up under the barrage of "new" languages. 

I would not say that C has strong typing.  It added typing to its
predecessor (B) but it did so in such a way that the types rules are
deliberately easy to break or circumvent.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#22389

FromPaul J Gans <gansno@panix.com>
Date2012-06-19 01:48 +0000
Message-ID<jrolpb$eef$2@reader1.panix.com>
In reply to#22384
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>Paul J Gans <gansno@panix.com> writes:
>I've snipped all the context because I don't think you address the issue
>where variables are declared.  But I do want to comment...

>> I'd think the argument works the other way.  Back when C was
>> new the other dominant language was FORTRAN.  Later came both
>> Basic, Algol, and Cobol.  All were strongly typed languages.

>Cobol was massive long before C came along, and Algol dates from the
>1950s.  Basic is a little younger than Algol, but it was around in the
>1960s and was riding a wave caused by the boom in microprocessors
>(admittedly in a dizzying array of dialects) when most people started to
>became aware of C.

>> Of these only C survives to any major extent, proving, it seems
>> to me, that it was the most *successful* of these languages. 
>> Indeed, it also shows that perhaps in spite of its strong typing,
>> it has held up under the barrage of "new" languages. 

>I would not say that C has strong typing.  It added typing to its
>predecessor (B) but it did so in such a way that the types rules are
>deliberately easy to break or circumvent.

True.  I've always thought of that as a "fall out" of being
"close to the hardware", whatever that means.

-- 
   --- Paul J. Gans

[toc] | [prev] | [next] | [standalone]


#22386

FromLes Cargill <lcargill99@comcast.com>
Date2012-06-18 19:50 -0500
Message-ID<jroi72$909$2@dont-email.me>
In reply to#22373
Ian Collins wrote:
> On 06/17/12 10:47 PM, BartC wrote:
>>
>>
>> "Jorgen Grahn"<grahn+nntp@snipabacken.se>  wrote in message
>> news:slrnjtr16f.rk7.grahn+nntp@frailea.sa.invalid...
>>> On Thu, 2012-06-14, Varun Tewari wrote:
>>>> Its simply not stupid, its a simple fact the C++/Java allow
>>>> decalaration anywhere in the code, but C wants them the first thing
>>>> when you code. That's all
>>>
>>> You could say that "declarations only at the start of block" was a
>>> stupid design ... I'm very happy this got changed, and it should
>>> probably have happened earlier, when 'const' and such things were
>>> introduced.
>>>
>>> Now all that remains is to educate the users.  Most code I read
>>> doesn't even use the C89 "at the start of block" rule. It lumps all
>>> the variables at the start of the function -- even those that are only
>>> used and only make sense inside some loop, two pages down ...
>>
>> But what happens when the code defines a variable two pages into a
>> function,
>> but you happen to be reading some code using that same variable four
>> pages
>> into the function!
>
> Then you (or the original authour) are doing something very very wrong.
>
>> Where do you go to find the definition? At the start of a
>> function is usually a good place! You don't always know that a
>> variable is
>> only used once.
>
> C is the only language I know that had (in the last century) such
> restrictive declaration rules.  You wouldn't see this argument on a
> forum for another language.  If old C's declaration rules were such a
> good idea, why have thy been ignored by most (all?) subsequent languages?
>

Probably because C left a suite of restrictions people targeted. To an 
extent, defining a new language is a bit... odd. We have a bit
of a Tower of Babel problem as it is.

--
Les Cargill

[toc] | [prev] | [next] | [standalone]


#22393

Fromnick_keighley_nospam@hotmail.com
Date2012-06-19 00:19 -0700
Message-ID<37cccca1-2029-448a-84ba-0fdbed135e34@googlegroups.com>
In reply to#22373
On Monday, June 18, 2012 10:37:04 PM UTC+1, Ian Collins wrote:

<snip>

> C is the only language I know that had (in the last century) such 
> restrictive declaration rules. 

[declarations only at the beginning of a block]

 You wouldn't see this argument on a 
> forum for another language.  If old C's declaration rules were such a 
> good idea, why have thy been ignored by most (all?) subsequent languages?

Alogol-60 (hence CORAL-66 and JOVIAL), Pascal

I've never found it a restriction. Though I happily declare stuff mid-block in C++.

[toc] | [prev] | [next] | [standalone]


#22405

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-06-19 12:56 +0100
Message-ID<0.20e3e22406faeaedd57e.20120619125610BST.878vfjseg5.fsf@bsb.me.uk>
In reply to#22393
nick_keighley_nospam@hotmail.com writes:

> On Monday, June 18, 2012 10:37:04 PM UTC+1, Ian Collins wrote:
>
> <snip>
>
>> C is the only language I know that had (in the last century) such 
>> restrictive declaration rules. 
>
> [declarations only at the beginning of a block]
>
>  You wouldn't see this argument on a 
>> forum for another language.  If old C's declaration rules were such a 
>> good idea, why have thy been ignored by most (all?) subsequent languages?
>
> Alogol-60 (hence CORAL-66 and JOVIAL), Pascal

I'm getting confused by all this.  These can't be counter
examples, i.e. subsequent languages that did *not* ignore C's
declaration rules, because they all pre-date C.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#22428

Fromnick_keighley_nospam@hotmail.com
Date2012-06-20 00:26 -0700
Message-ID<0e4878b1-7eaa-4702-b018-a867242e8142@googlegroups.com>
In reply to#22405
On Tuesday, June 19, 2012 12:56:10 PM UTC+1, Ben Bacarisse wrote:
> nick_keighley_nospam@hotmail.com writes:
> > On Monday, June 18, 2012 10:37:04 PM UTC+1, Ian Collins wrote:

> >> C is the only language I know that had (in the last century) such 
> >> restrictive declaration rules. 
> >
> > [declarations only at the beginning of a block]
> >
> >  You wouldn't see this argument on a 
> >> forum for another language.  If old C's declaration rules were such a 
> >> good idea, why have thy been ignored by most (all?) subsequent languages?
> >
> > Alogol-60 (hence CORAL-66 and JOVIAL), Pascal
> 
> I'm getting confused by all this.  These can't be counter
> examples, i.e. subsequent languages that did *not* ignore C's
> declaration rules, because they all pre-date C.

err... I thought the claim was "only C has such restrictive 
declaration rules". I thought C's rules were quite ordinary. 
Perhaps I misunderstood what was being claimed. I was addressing
the claim that appears at the beginnign of this post.

[toc] | [prev] | [next] | [standalone]


#22430

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-06-20 06:31 -0400
Message-ID<jrs8p6$dlp$1@dont-email.me>
In reply to#22428
On 06/20/2012 03:26 AM, nick_keighley_nospam@hotmail.com wrote:
> On Tuesday, June 19, 2012 12:56:10 PM UTC+1, Ben Bacarisse wrote:
>> nick_keighley_nospam@hotmail.com writes:
>>> On Monday, June 18, 2012 10:37:04 PM UTC+1, Ian Collins wrote:
> 
>>>> C is the only language I know that had (in the last century) such 
>>>> restrictive declaration rules. 
>>>
>>> [declarations only at the beginning of a block]
>>>
>>>  You wouldn't see this argument on a 
>>>> forum for another language.  If old C's declaration rules were such a 
>>>> good idea, why have thy been ignored by most (all?) subsequent languages?
>>>
>>> Alogol-60 (hence CORAL-66 and JOVIAL), Pascal
>>
>> I'm getting confused by all this.  These can't be counter
>> examples, i.e. subsequent languages that did *not* ignore C's
>> declaration rules, because they all pre-date C.
> 
> err... I thought the claim was "only C has such restrictive 
> declaration rules". I thought C's rules were quite ordinary. 
> Perhaps I misunderstood what was being claimed. I was addressing
> the claim that appears at the beginnign of this post.

Then you should have put your response immediately after that claim, to
reduce confusion. In the location where you actually put it, it gives
the false appearance of being intended as a response to a question about
"most (all?) subsequent languages".
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#22346

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2012-06-18 00:18 -0600
Message-ID<1bd34xnnx7.fsf@pfeifferfamily.net>
In reply to#22328
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:

> On Thu, 2012-06-14, Varun Tewari wrote:
>> Its simply not stupid, its a simple fact the C++/Java allow
>> decalaration anywhere in the code, but C wants them the first thing
>> when you code. That's all
>
> You could say that "declarations only at the start of block" was a
> stupid design ... I'm very happy this got changed, and it should
> probably have happened earlier, when 'const' and such things were
> introduced.
>
> Now all that remains is to educate the users.  Most code I read
> doesn't even use the C89 "at the start of block" rule. It lumps all
> the variables at the start of the function -- even those that are only
> used and only make sense inside some loop, two pages down ...
>
> /Jorgen

It may be a sign of my age and when I learned C, but I really like
defining all my variables, and then using them.  If defining a variable
at the start of a block other than the start of the function (and not as
the iterator of a for loop) makes sense, it's a really good clue my
function is too long.

If my variables are first used two pages down, the function is almost
certainly too long.  If "two pages down" is even a relevant phrase, my
function is almost certainly too long.

[toc] | [prev] | [next] | [standalone]


#22355

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2012-06-18 09:15 +0000
Message-ID<slrnjttsct.rk7.grahn+nntp@frailea.sa.invalid>
In reply to#22346
On Mon, 2012-06-18, Joe Pfeiffer wrote:
> Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
>
>> On Thu, 2012-06-14, Varun Tewari wrote:
>>> Its simply not stupid, its a simple fact the C++/Java allow
>>> decalaration anywhere in the code, but C wants them the first thing
>>> when you code. That's all
>>
>> You could say that "declarations only at the start of block" was a
>> stupid design ... I'm very happy this got changed, and it should
>> probably have happened earlier, when 'const' and such things were
>> introduced.
>>
>> Now all that remains is to educate the users.  Most code I read
>> doesn't even use the C89 "at the start of block" rule. It lumps all
>> the variables at the start of the function -- even those that are only
>> used and only make sense inside some loop, two pages down ...
>>
>> /Jorgen
>
> It may be a sign of my age and when I learned C, but I really like
> defining all my variables, and then using them.

Might be a generation thing ... I learned C around 1992. But I've also
used C++ heavily in recent years; I guess that's where I learned not
to introduce variables until I need them.

> If defining a variable
> at the start of a block other than the start of the function (and not as
> the iterator of a for loop) makes sense, it's a really good clue my
> function is too long.
>
> If my variables are first used two pages down, the function is almost
> certainly too long.  If "two pages down" is even a relevant phrase, my
> function is almost certainly too long.

Yes, of course. But if you're working in teams, it's not always your
fault the function looks like this, and "right now" may not be the
right time to break it down.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#22273

FromKaz Kylheku <kaz@kylheku.com>
Date2012-06-14 23:21 +0000
Message-ID<20120614162626.479@kylheku.com>
In reply to#22223
On 2012-06-13, zgene <nospam@nospam.com> wrote:
> So, does g want us to declare all variables at the head of a block?  What
> a stupid gcc!

Stupid you for disparaging a tool which translates a family of languages you
haven't studied properly.

[toc] | [prev] | [standalone]


Page 5 of 5 — ← Prev page 1 2 3 4 [5]

Back to top | Article view | comp.lang.c


csiph-web