* [9fans] A Plan 9 C request....
@ 2006-03-01 17:56 Dan Cross
2006-03-01 18:09 ` Skip Tavakkolian
0 siblings, 1 reply; 21+ messages in thread
From: Dan Cross @ 2006-03-01 17:56 UTC (permalink / raw)
To: 9fans
Here's a request for my favorite C feature from C99, which isn't yet in
Plan 9 C. I'd really like it if one could write statements of the form,
for (int i = 0; i < 10; i++);
or
for (char *p = s; *p != '\0'; p++);
That is, declare variables in the first part of a for loop. That would
be nice. Anyone care to add it to the compiler? I'd try it myself, but
I'm just too busy right now....
- Dan C.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 17:56 [9fans] A Plan 9 C request Dan Cross
@ 2006-03-01 18:09 ` Skip Tavakkolian
2006-03-01 18:15 ` Brantley Coile
` (3 more replies)
0 siblings, 4 replies; 21+ messages in thread
From: Skip Tavakkolian @ 2006-03-01 18:09 UTC (permalink / raw)
To: 9fans
when it was added to C++, i "felt" that the scope
of 'i' wasn't natural; it goes beyond 'for's closure.
i like a behavior like this:
{ int i; for (i = 0, ...) ...; }
> Here's a request for my favorite C feature from C99, which isn't yet in
> Plan 9 C. I'd really like it if one could write statements of the form,
>
> for (int i = 0; i < 10; i++);
>
> or
>
> for (char *p = s; *p != '\0'; p++);
>
> That is, declare variables in the first part of a for loop. That would
> be nice. Anyone care to add it to the compiler? I'd try it myself, but
> I'm just too busy right now....
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:09 ` Skip Tavakkolian
@ 2006-03-01 18:15 ` Brantley Coile
2006-03-01 18:17 ` rog
` (2 subsequent siblings)
3 siblings, 0 replies; 21+ messages in thread
From: Brantley Coile @ 2006-03-01 18:15 UTC (permalink / raw)
To: 9fans
> when it was added to C++, i "felt" that the scope
> of 'i' wasn't natural; it goes beyond 'for's closure.
> i like a behavior like this:
I think the scope shouldn't extend past the first semicolon. :)
/* Boyd Roberts Memorial Obnoxious Comment Society member */
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:09 ` Skip Tavakkolian
2006-03-01 18:15 ` Brantley Coile
@ 2006-03-01 18:17 ` rog
2006-03-01 18:20 ` Russ Cox
2006-03-01 18:22 ` Richard Bilson
3 siblings, 0 replies; 21+ messages in thread
From: rog @ 2006-03-01 18:17 UTC (permalink / raw)
To: 9fans
> when it was added to C++, i "felt" that the scope
> of 'i' wasn't natural; it goes beyond 'for's closure.
> i like a behavior like this:
>
> { int i; for (i = 0, ...) ...; }
when i first started to use Limbo, which has a similar looking
idiom, i thought the same.
for(i := 0; i < 10; i++) {
}
but actually, having the variable
available outside the scope is so often useful,
e.g.
for(i := 0; i < end; i++)
if(sometest())
break;
if(i == end)
fall_through_condition();
that i now think the non-scoping behaviour is the right thing.
i'm not sure that it's worth adding to plan 9 C though.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:09 ` Skip Tavakkolian
2006-03-01 18:15 ` Brantley Coile
2006-03-01 18:17 ` rog
@ 2006-03-01 18:20 ` Russ Cox
2006-03-01 18:23 ` Brantley Coile
2006-03-01 18:31 ` Skip Tavakkolian
2006-03-01 18:22 ` Richard Bilson
3 siblings, 2 replies; 21+ messages in thread
From: Russ Cox @ 2006-03-01 18:20 UTC (permalink / raw)
To: 9fans
> when it was added to C++, i "felt" that the scope
> of 'i' wasn't natural; it goes beyond 'for's closure.
> i like a behavior like this:
>
> { int i; for (i = 0, ...) ...; }
so did the c++ standards committee and the c99 committee.
both have declared that
for (int i = 0; i < 10; i++);
now means
{ int i; for(i=0; i<10; i++); }
russ
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:20 ` Russ Cox
@ 2006-03-01 18:23 ` Brantley Coile
2006-03-01 18:32 ` Russ Cox
` (2 more replies)
2006-03-01 18:31 ` Skip Tavakkolian
1 sibling, 3 replies; 21+ messages in thread
From: Brantley Coile @ 2006-03-01 18:23 UTC (permalink / raw)
To: 9fans
> now means
>
> { int i; for(i=0; i<10; i++); }
Does that mean the following will compile?
void
f(void)
{
i = 3;
put(i);
for (int i = 0; i < 3; i++)
put(i);
if (i == 4) put(4);
}
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:23 ` Brantley Coile
@ 2006-03-01 18:32 ` Russ Cox
2006-03-01 18:32 ` jmk
2006-03-01 19:59 ` Ronald G Minnich
2 siblings, 0 replies; 21+ messages in thread
From: Russ Cox @ 2006-03-01 18:32 UTC (permalink / raw)
To: 9fans
> Does that mean the following will compile?
>
> 1 void
> 2 f(void)
> 3 {
> 4 i = 3;
> 5 put(i);
> 6 for (int i = 0; i < 3; i++)
> 7 put(i);
> 8 if (i == 4) put(4);
> 9 }
No, because i is undeclared at line 4.
It's still not a good example. Here's a better one:
void
main(void)
{
int i = 100;
for (int i = 0; i < 3; i++)
printf("%d\n", i);
printf("%d\n", i);
}
It prints 0 1 2 100.
Russ
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:23 ` Brantley Coile
2006-03-01 18:32 ` Russ Cox
@ 2006-03-01 18:32 ` jmk
2006-03-01 19:59 ` Ronald G Minnich
2 siblings, 0 replies; 21+ messages in thread
From: jmk @ 2006-03-01 18:32 UTC (permalink / raw)
To: 9fans
The C Rationale (6.8.5.3) says:
int i = 42;
for (int i = 5, j = 15; i < 10; i++, j--)
printf("Loop %d %d\n",, i, j);
printf("I = %d\n", i); // there is no j in scope
will output
Loop 5 15
Loop 6 14
Loop 7 13
Loop 8 12
Loop 9 11
I = 42
On Wed Mar 1 13:26:33 EST 2006, brantley@coraid.com wrote:
> > now means
> >
> > { int i; for(i=0; i<10; i++); }
>
> Does that mean the following will compile?
>
> void
> f(void)
> {
> i = 3;
> put(i);
> for (int i = 0; i < 3; i++)
> put(i);
> if (i == 4) put(4);
> }
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:23 ` Brantley Coile
2006-03-01 18:32 ` Russ Cox
2006-03-01 18:32 ` jmk
@ 2006-03-01 19:59 ` Ronald G Minnich
2006-03-02 4:52 ` Devon H. O'Dell
2 siblings, 1 reply; 21+ messages in thread
From: Ronald G Minnich @ 2006-03-01 19:59 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Brantley Coile wrote:
>>now means
>>
>> { int i; for(i=0; i<10; i++); }
>
>
> Does that mean the following will compile?
>
> void
> f(void)
> {
> i = 3;
> put(i);
> for (int i = 0; i < 3; i++)
> put(i);
> if (i == 4) put(4);
> }
>
cat > t.c
void
f(void)
{
i = 3;
put(i);
for (int i = 0; i < 3; i++)
put(i);
if (i == 4) put(4);
}
[rminnich@q tmp]$ cc t.c
t.c: In function ‘f’:
t.c:4: error: ‘i’ undeclared (first use in this function)
t.c:4: error: (Each undeclared identifier is reported only once
t.c:4: error: for each function it appears in.)
t.c:6: error: ‘for’ loop initial declaration used outside C99 mode
[rminnich@q tmp]$
ron
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 19:59 ` Ronald G Minnich
@ 2006-03-02 4:52 ` Devon H. O'Dell
0 siblings, 0 replies; 21+ messages in thread
From: Devon H. O'Dell @ 2006-03-02 4:52 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
2006/3/1, Ronald G Minnich <rminnich@lanl.gov>:
> Brantley Coile wrote:
> >>now means
> >>
> >> { int i; for(i=0; i<10; i++); }
> >
> >
> > Does that mean the following will compile?
> >
> > void
> > f(void)
> > {
> > i = 3;
> > put(i);
> > for (int i = 0; i < 3; i++)
> > put(i);
> > if (i == 4) put(4);
> > }
> >
>
> cat > t.c
> void
> f(void)
> {
> i = 3;
> put(i);
> for (int i = 0; i < 3; i++)
> put(i);
> if (i == 4) put(4);
> }
> [rminnich@q tmp]$ cc t.c
> t.c: In function 'f':
> t.c:4: error: 'i' undeclared (first use in this function)
> t.c:4: error: (Each undeclared identifier is reported only once
> t.c:4: error: for each function it appears in.)
> t.c:6: error: 'for' loop initial declaration used outside C99 mode
> [rminnich@q tmp]$
>
>
> ron
And the reason it doesn't is because in this code snippet, the
variable i is undeclared. I assume since the i is not declared, the
compiler steps out of C99 mode and refuses to allow the C99 construct
of for (int i...)
--Devon
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:20 ` Russ Cox
2006-03-01 18:23 ` Brantley Coile
@ 2006-03-01 18:31 ` Skip Tavakkolian
2006-03-02 4:27 ` David Leimbach
1 sibling, 1 reply; 21+ messages in thread
From: Skip Tavakkolian @ 2006-03-01 18:31 UTC (permalink / raw)
To: 9fans
>> when it was added to C++, i "felt" that the scope
>> of 'i' wasn't natural; it goes beyond 'for's closure.
>> i like a behavior like this:
>>
>> { int i; for (i = 0, ...) ...; }
>
> so did the c++ standards committee and the c99 committee.
> both have declared that
>
> for (int i = 0; i < 10; i++);
>
> now means
>
> { int i; for(i=0; i<10; i++); }
i didn't know. wow?!
my vc6 is officially an antique.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:31 ` Skip Tavakkolian
@ 2006-03-02 4:27 ` David Leimbach
2006-03-02 4:37 ` Andrew R. Reiter
0 siblings, 1 reply; 21+ messages in thread
From: David Leimbach @ 2006-03-02 4:27 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On 3/1/06, Skip Tavakkolian <9nut@9netics.com> wrote:
> >> when it was added to C++, i "felt" that the scope
> >> of 'i' wasn't natural; it goes beyond 'for's closure.
> >> i like a behavior like this:
> >>
> >> { int i; for (i = 0, ...) ...; }
> >
> > so did the c++ standards committee and the c99 committee.
> > both have declared that
> >
> > for (int i = 0; i < 10; i++);
> >
> > now means
> >
> > { int i; for(i=0; i<10; i++); }
>
> i didn't know. wow?!
> my vc6 is officially an antique.
>
>
VC *anything* should not be seen as an implementation of any standards :).
I've heard the .NET stuff is better but they've added a ton of
extensions to "managed C++" that really isn't C++ anymore.
In fact I was told they were lobbying to get that stuff into the
standard but Bjarne isn't favorable to language changes that he thinks
could be solved in libraries.
Dave
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 4:27 ` David Leimbach
@ 2006-03-02 4:37 ` Andrew R. Reiter
2006-03-02 11:44 ` Brantley Coile
0 siblings, 1 reply; 21+ messages in thread
From: Andrew R. Reiter @ 2006-03-02 4:37 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Wed, 1 Mar 2006, David Leimbach wrote:
:On 3/1/06, Skip Tavakkolian <9nut@9netics.com> wrote:
:> >> when it was added to C++, i "felt" that the scope
:> >> of 'i' wasn't natural; it goes beyond 'for's closure.
:> >> i like a behavior like this:
:> >>
:> >> { int i; for (i = 0, ...) ...; }
:> >
:> > so did the c++ standards committee and the c99 committee.
:> > both have declared that
:> >
:> > for (int i = 0; i < 10; i++);
:> >
:> > now means
:> >
:> > { int i; for(i=0; i<10; i++); }
:>
:> i didn't know. wow?!
:> my vc6 is officially an antique.
:>
:>
:
:
:VC *anything* should not be seen as an implementation of any standards :).
:
As a person who's done porting of embedded systems between compilers and
just working with VC, gcc, icc, et al, in general, I couldn't agree more!
$0.02
Andrew
--
arr@watson.org
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 4:37 ` Andrew R. Reiter
@ 2006-03-02 11:44 ` Brantley Coile
0 siblings, 0 replies; 21+ messages in thread
From: Brantley Coile @ 2006-03-02 11:44 UTC (permalink / raw)
To: 9fans
> As a person who's done porting of embedded systems between compilers and
> just working with VC, gcc, icc, et al, in general, I couldn't agree more!
>
> $0.02
> Andrew
After Ken's compiler, lcc is my favorite C compiler. Ah, for the days
when C and I were young, and all the compilers were Steve' pcc. I
never got a chance to use Dennis' compiler in the heat of battle, but
it's code is a wonder to behold. It's evolution from NB to C is the
best example I've seen of entropy in reverse.
Brantley
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-01 18:09 ` Skip Tavakkolian
` (2 preceding siblings ...)
2006-03-01 18:20 ` Russ Cox
@ 2006-03-01 18:22 ` Richard Bilson
3 siblings, 0 replies; 21+ messages in thread
From: Richard Bilson @ 2006-03-01 18:22 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On 3/1/06, Skip Tavakkolian <9nut@9netics.com> wrote:
> when it was added to C++, i "felt" that the scope
> of 'i' wasn't natural; it goes beyond 'for's closure.
> i like a behavior like this:
>
> { int i; for (i = 0, ...) ...; }
This (the way you like it) is the way it was eventually standardized
in C++. Any modern compiler that I have used does it this way.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
@ 2006-03-02 12:07 Fco. J. Ballesteros
2006-03-02 12:14 ` Richard Miller
0 siblings, 1 reply; 21+ messages in thread
From: Fco. J. Ballesteros @ 2006-03-02 12:07 UTC (permalink / raw)
To: 9fans
: After Ken's compiler, lcc is my favorite C compiler. Ah, for the days
: when C and I were young, and all the compilers were Steve' pcc. I
: never got a chance to use Dennis' compiler in the heat of battle, but
: it's code is a wonder to behold. It's evolution from NB to C is the
: best example I've seen of entropy in reverse.
Could we see the code?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 12:07 Fco. J. Ballesteros
@ 2006-03-02 12:14 ` Richard Miller
2006-03-02 12:25 ` Anthony Sorace
2006-03-02 12:26 ` Brantley Coile
0 siblings, 2 replies; 21+ messages in thread
From: Richard Miller @ 2006-03-02 12:14 UTC (permalink / raw)
To: 9fans
> : never got a chance to use Dennis' compiler in the heat of battle, but
> : it's code is a wonder to behold. It's evolution from NB to C is the
> : best example I've seen of entropy in reverse.
>
> Could we see the code?
http://www.tuhs.org/Archive/PDP-11/Distributions/research/Dennis_v6/v6src.tar.gz
Look in directory 'c'.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 12:14 ` Richard Miller
@ 2006-03-02 12:25 ` Anthony Sorace
2006-03-02 12:26 ` Brantley Coile
1 sibling, 0 replies; 21+ messages in thread
From: Anthony Sorace @ 2006-03-02 12:25 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
also interesting, in terms of evolution:
http://www.cs.bell-labs.com/who/dmr/primevalC.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 12:14 ` Richard Miller
2006-03-02 12:25 ` Anthony Sorace
@ 2006-03-02 12:26 ` Brantley Coile
2006-03-03 15:07 ` erik quanstrom
1 sibling, 1 reply; 21+ messages in thread
From: Brantley Coile @ 2006-03-02 12:26 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 105 bytes --]
http://plan9.bell-labs.com/cm/cs/who/dmr/primevalC.html
See the above for the evolution of the code.
[-- Attachment #2: Type: message/rfc822, Size: 2440 bytes --]
From: Richard Miller <9fans@hamnavoe.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] A Plan 9 C request....
Date: Thu, 2 Mar 2006 12:14:31 +0000
Message-ID: <aa5409a26b13f8535c296cfdb9dedc2f@hamnavoe.com>
> : never got a chance to use Dennis' compiler in the heat of battle, but
> : it's code is a wonder to behold. It's evolution from NB to C is the
> : best example I've seen of entropy in reverse.
>
> Could we see the code?
http://www.tuhs.org/Archive/PDP-11/Distributions/research/Dennis_v6/v6src.tar.gz
Look in directory 'c'.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [9fans] A Plan 9 C request....
2006-03-02 12:26 ` Brantley Coile
@ 2006-03-03 15:07 ` erik quanstrom
2006-03-04 10:00 ` Richard Miller
0 siblings, 1 reply; 21+ messages in thread
From: erik quanstrom @ 2006-03-03 15:07 UTC (permalink / raw)
To: 9fans, Brantley Coile
in the section after the /* storage */ comment in c00.c
regtab 0;
efftab 1;
[etc.]
should this be read as
int regtab = 0;
int efftab = 1;
?
- erik
Brantley Coile <brantley@coraid.com> writes
|
| --upas-sxzcqiogirovolmsuexgarfigy
|
| http://plan9.bell-labs.com/cm/cs/who/dmr/primevalC.html
|
| See the above for the evolution of the code.
|
| --upas-sxzcqiogirovolmsuexgarfigy
| To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>,
| 9fans@cse.psu.edu,
| Richard Miller <9fans@hamnavoe.com>
| References: <aa5409a26b13f8535c296cfdb9dedc2f@hamnavoe.com>
| In-Reply-To: <aa5409a26b13f8535c296cfdb9dedc2f@hamnavoe.com>
| Subject: Re: [9fans] A Plan 9 C request....
|
| > : never got a chance to use Dennis' compiler in the heat of battle, but
| > : it's code is a wonder to behold. It's evolution from NB to C is the
| > : best example I've seen of entropy in reverse.
| >
| > Could we see the code?
|
| http://www.tuhs.org/Archive/PDP-11/Distributions/research/Dennis_v6/v6src.tar.gz
|
| Look in directory 'c'.
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2006-03-04 10:00 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-01 17:56 [9fans] A Plan 9 C request Dan Cross
2006-03-01 18:09 ` Skip Tavakkolian
2006-03-01 18:15 ` Brantley Coile
2006-03-01 18:17 ` rog
2006-03-01 18:20 ` Russ Cox
2006-03-01 18:23 ` Brantley Coile
2006-03-01 18:32 ` Russ Cox
2006-03-01 18:32 ` jmk
2006-03-01 19:59 ` Ronald G Minnich
2006-03-02 4:52 ` Devon H. O'Dell
2006-03-01 18:31 ` Skip Tavakkolian
2006-03-02 4:27 ` David Leimbach
2006-03-02 4:37 ` Andrew R. Reiter
2006-03-02 11:44 ` Brantley Coile
2006-03-01 18:22 ` Richard Bilson
2006-03-02 12:07 Fco. J. Ballesteros
2006-03-02 12:14 ` Richard Miller
2006-03-02 12:25 ` Anthony Sorace
2006-03-02 12:26 ` Brantley Coile
2006-03-03 15:07 ` erik quanstrom
2006-03-04 10:00 ` Richard Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).