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


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

Switching to C#

Started by"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
First post2019-06-12 11:01 -0400
Last post2019-06-18 06:33 -0700
Articles 20 on this page of 68 — 25 participants

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


Contents

  Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-12 11:01 -0400
    Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-12 08:21 -0700
    Re: Switching to C# Szyk Cech <szykcech@spoko.pl> - 2019-06-12 17:32 +0200
      Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-12 12:04 -0400
        Re: Switching to C# Szyk Cech <szykcech@spoko.pl> - 2019-06-13 05:50 +0200
      Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-13 15:43 -0700
    Re: Switching to C# gazelle@shell.xmission.com (Kenny McCormack) - 2019-06-12 16:30 +0000
      Re: Switching to C# My nuts hurt <cdalten@gmail.com> - 2019-06-13 09:54 -0700
      Re: Switching to C# Jens Stuckelberger <Jens_Stuckelberger@nowhere.net> - 2019-06-14 15:28 +0000
        Re: Switching to C# gazelle@shell.xmission.com (Kenny McCormack) - 2019-06-14 15:55 +0000
          Re: Switching to C# rick.c.hodgin@gmail.com - 2019-06-14 10:25 -0700
            Re: Switching to C# scott@slp53.sl.home (Scott Lurndal) - 2019-06-14 17:56 +0000
              Whatever will we do without Rick??? (Was: Switching to C#) gazelle@shell.xmission.com (Kenny McCormack) - 2019-06-14 18:02 +0000
                Re: Whatever will we do without Rick??? (Was: Switching to C#) rick.c.hodgin@gmail.com - 2019-06-14 12:24 -0700
              Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-14 14:24 -0400
        Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-14 12:57 -0400
          Re: Switching to C# Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-06-15 01:29 +0100
    Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-12 17:17 -0700
      Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-12 23:41 -0700
    Re: Switching to C# Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-06-13 03:30 +0100
      Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-14 08:43 -0400
        Re: Switching to C# nobody@example.org (Scott) - 2019-06-14 15:21 +0000
          Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-14 12:55 -0400
            Re: Switching to C# Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2019-06-15 01:28 +0100
          Re: Switching to C# Bart <bc@freeuk.com> - 2019-06-14 18:07 +0100
            Re: Switching to C# David Brown <david.brown@hesbynett.no> - 2019-06-15 09:44 +0200
            Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-15 01:24 -0700
              Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-15 02:04 -0700
                Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-15 03:24 -0700
                  Re: Switching to C# fir <profesor.fir@gmail.com> - 2019-06-15 03:41 -0700
                Re: Switching to C# Anton Shepelev <anton.txt@gmail.com> - 2019-06-16 15:16 +0300
          Re: Switching to C# Bonita Montero <Bonita.Montero@gmail.com> - 2019-06-15 18:49 +0200
            Re: Switching to C# Bart <bc@freeuk.com> - 2019-06-15 17:58 +0100
              Re: Switching to C# Bonita Montero <Bonita.Montero@gmail.com> - 2019-06-16 07:28 +0200
            Re: Switching to C# nobody@example.org (Scott) - 2019-06-16 01:58 +0000
              Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-15 19:31 -0700
                Re: Switching to C# nobody@example.org (Scott) - 2019-06-16 08:20 +0000
                  Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-16 02:24 -0700
                    Re: Switching to C# nobody@example.org (Scott) - 2019-06-16 17:03 +0000
                      Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-16 14:24 -0700
                        Re: Switching to C# nobody@example.org (Scott) - 2019-06-17 03:02 +0000
              Re: Switching to C# Bonita Montero <Bonita.Montero@gmail.com> - 2019-06-16 10:54 +0200
                Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-16 02:26 -0700
                  Re: Switching to C# Bonita Montero <Bonita.Montero@gmail.com> - 2019-06-16 12:43 +0200
                    Re: Switching to C# nobody@example.org (Scott) - 2019-06-16 17:05 +0000
                    Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-16 14:26 -0700
                      Re: Switching to C# Bonita Montero <Bonita.Montero@gmail.com> - 2019-06-17 06:31 +0200
              Re: Switching to C# David Brown <david.brown@hesbynett.no> - 2019-06-16 12:23 +0200
                Re: Switching to C# Manfred <noname@invalid.add> - 2019-06-16 23:06 +0200
                Re: Switching to C# Keith Thompson <kst-u@mib.org> - 2019-06-16 14:27 -0700
                  Re: Switching to C# David Brown <david.brown@hesbynett.no> - 2019-06-16 23:33 +0200
              Re: Switching to C# James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-06-17 08:30 -0400
    Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-13 00:06 -0700
      Re: Switching to C# "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-06-14 08:49 -0400
        Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-17 23:30 -0700
          Re: Switching to C# rick.c.hodgin@gmail.com - 2019-06-18 02:58 -0700
          Re: Switching to C# Mel <mel@zzzzz.com> - 2019-06-18 22:46 +0200
            Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-18 14:00 -0700
              Re: Switching to C# Melzzzzz <Melzzzzz@zzzzz.com> - 2019-06-18 21:11 +0000
                Re: Switching to C# "Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com> - 2019-06-18 15:36 -0700
                  Re: Switching to C# rick.c.hodgin@gmail.com - 2019-06-18 15:42 -0700
                  Re: Switching to C# Melzzzzz <Melzzzzz@zzzzz.com> - 2019-06-19 04:26 +0000
    Switching to C# Thiago Adams <thiago.adams@gmail.com> - 2019-06-13 03:05 -0700
      Re: Switching to C# Real Troll <real.troll@trolls.com> - 2019-06-13 12:30 -0400
    Re: Switching to C# My nuts hurt <cdalten@gmail.com> - 2019-06-13 09:51 -0700
      Re: Switching to C# luser droog <luser.droog@gmail.com> - 2019-06-13 09:56 -0700
        Re: Switching to C# Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-06-13 22:24 +0000
          Re: Switching to C# Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-06-18 06:33 -0700

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


#144839

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2019-06-14 08:43 -0400
Message-ID<qe04ln$a3u$1@dont-email.me>
In reply to#144788
On 6/12/2019 10:30 PM, Mr Flibble wrote:
> C# is a bag of .. BTW.

I find that to be an inaccurate assessment.  C# is proving to be quite
a powerhouse language.  It also uses keywords which make it clear in
source code what you're doing, such as "ref" and "out" to indicate which
parameters passed to a function are by reference, are output, etc.

It has a nice delegate syntax.  You don't have to declare everything
before you use it.  It's got an excellent debugger interface.  Nice
built-in exception handling.

I wouldn't use it for high-speed apps, but for all business apps, all
GUI-based apps that aren't games, all general purpose apps... it looks
very nice.  It's also VM-based, so it works across platforms without
changing a single line of C# code.

Not too shabby.

-- 
Rick C. Hodgin

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


#144845

Fromnobody@example.org (Scott)
Date2019-06-14 15:21 +0000
Message-ID<5d03bb38.3305609877@core>
In reply to#144839
On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
<rick.c.hodgin@gmail.com> wrote:

>You don't have to declare everything before you use it.

Many people, including myself, consider that to be a bad thing.

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


#144849

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2019-06-14 12:55 -0400
Message-ID<qe0jdk$3ih$1@dont-email.me>
In reply to#144845
On 6/14/2019 11:21 AM, Scott wrote:
> On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
> <rick.c.hodgin@gmail.com> wrote:
>> You don't have to declare everything before you use it.
> Many people, including myself, consider that to be a bad thing.

Many other people, including myself (and the authors of Go, including
Ken Thompson demonstrating his evolutionary view of the necessity of
forward declarations given modern CPU performance in compilation),
consider it to be a wonderful thing.

-- 
Rick C. Hodgin

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


#144868

FromMr Flibble <flibbleREMOVETHISBIT@i42.co.uk>
Date2019-06-15 01:28 +0100
Message-ID<PYWME.374$Fp7.359@fx20.fr7>
In reply to#144849
On 14/06/2019 17:55, Rick C. Hodgin wrote:
> On 6/14/2019 11:21 AM, Scott wrote:
>> On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
>> <rick.c.hodgin@gmail.com> wrote:
>>> You don't have to declare everything before you use it.
>> Many people, including myself, consider that to be a bad thing.
> 
> Many other people, including myself (and the authors of Go, including
> Ken Thompson demonstrating his evolutionary view of the necessity of
> forward declarations given modern CPU performance in compilation),
> consider it to be a wonderful thing.

And Satan invented fossils, yes?

/Flibble

-- 
"Snakes didn't evolve, instead talking snakes with legs changed into 
snakes." - Rick C. Hodgin

“You won’t burn in hell. But be nice anyway.” – Ricky Gervais

“I see Atheists are fighting and killing each other again, over who 
doesn’t believe in any God the most. Oh, no..wait.. that never happens.” – 
Ricky Gervais

"Suppose it's all true, and you walk up to the pearly gates, and are 
confronted by God," Bryne asked on his show The Meaning of Life. "What 
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery 
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a 
world that is so full of injustice and pain. That's what I would say."

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


#144851

FromBart <bc@freeuk.com>
Date2019-06-14 18:07 +0100
Message-ID<AvQME.109262$ng1.88606@fx36.am4>
In reply to#144845
On 14/06/2019 16:21, Scott wrote:
> On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
> <rick.c.hodgin@gmail.com> wrote:
> 
>> You don't have to declare everything before you use it.
> 
> Many people, including myself, consider that to be a bad thing.
> 

You mean not declaring things at all, or not declaring them before first 
use?

I find lack of out-of-order declarations in C, to be a considerable 
pain. Although I think this mainly applies to functions.

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


#144877

FromDavid Brown <david.brown@hesbynett.no>
Date2019-06-15 09:44 +0200
Message-ID<qe27li$rdj$1@dont-email.me>
In reply to#144851
On 14/06/2019 19:07, Bart wrote:
> On 14/06/2019 16:21, Scott wrote:
>> On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
>> <rick.c.hodgin@gmail.com> wrote:
>>
>>> You don't have to declare everything before you use it.
>>
>> Many people, including myself, consider that to be a bad thing.
>>
> 
> You mean not declaring things at all, or not declaring them before first 
> use?
> 
> I find lack of out-of-order declarations in C, to be a considerable 
> pain. Although I think this mainly applies to functions.

As a Python user, I find being able to use things without declaring them 
to be a major source of errors, so I would not like that to be possible. 
  As far as I can tell about C# (having read a small amount, but never 
used it), you need to declare variables before using them.

Maybe functions can be used without declaring them first (as long as 
they are declared later).  That does not seem unreasonable to me.  I am 
not personally bothered that you need to declare functions before using 
them in C, but I understand that it is an inconvenience to some people. 
And I would rather that the language allowed calling functions before 
they are declared than the mess some people write with long reams of 
forward function declarations at the start of C files.

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


#144878

Fromfir <profesor.fir@gmail.com>
Date2019-06-15 01:24 -0700
Message-ID<93e50f6c-7442-46a2-9a5d-0afc82608631@googlegroups.com>
In reply to#144851
W dniu piątek, 14 czerwca 2019 19:07:55 UTC+2 użytkownik Bart napisał:
> On 14/06/2019 16:21, Scott wrote:
> > On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
> > <rick.c.hodgin@gmail.com> wrote:
> > 
> >> You don't have to declare everything before you use it.
> > 
> > Many people, including myself, consider that to be a bad thing.
> > 
> 
> You mean not declaring things at all, or not declaring them before first 
> use?
> 
> I find lack of out-of-order declarations in C, to be a considerable 
> pain. Although I think this mainly applies to functions.


thats true
1) declarations visible upa nad down >> (FAR BETTER) than declarations visible down

2) no declarations at all >> (FAR BETTER) than need of them

(both of those things are serious pains/mistakes in c) and the accent in thoise up statemants are on the meaning of "far better"


c besides has some other practicall annoyances, one that was bothering me in recent times were (already mentioned back them)

foo(float a,b,c) {} //lack of that syntax

//float3 a,b;
float3 x = a+5*b; //lack of basic (and strightforward) vector arithmetic like that

on semantic level lack of "static variable" that is tied to a place of calling of function is also anoyin 

void foo()
{
   static r = rand()%1100;
}

void boo()
{
    foo();
    foo();
    foo();
    foo(); //each one of that 
          // four generates separate 
         // inside static r variable (not
         // just one common for them)

}

this last one was not strightforward to observe but is really needed if someone wants to write good c

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


#144879

Fromfir <profesor.fir@gmail.com>
Date2019-06-15 02:04 -0700
Message-ID<397ba01a-6845-482d-a20c-12b191aae135@googlegroups.com>
In reply to#144878
W dniu sobota, 15 czerwca 2019 10:25:05 UTC+2 użytkownik fir napisał:
> W dniu piątek, 14 czerwca 2019 19:07:55 UTC+2 użytkownik Bart napisał:
> > On 14/06/2019 16:21, Scott wrote:
> > > On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
> > > <rick.c.hodgin@gmail.com> wrote:
> > > 
> > >> You don't have to declare everything before you use it.
> > > 
> > > Many people, including myself, consider that to be a bad thing.
> > > 
> > 
> > You mean not declaring things at all, or not declaring them before first 
> > use?
> > 
> > I find lack of out-of-order declarations in C, to be a considerable 
> > pain. Although I think this mainly applies to functions.
> 
> 
> thats true
> 1) declarations visible upa nad down >> (FAR BETTER) than declarations visible down
> 
> 2) no declarations at all >> (FAR BETTER) than need of them
> 
> (both of those things are serious pains/mistakes in c) and the accent in thoise up statemants are on the meaning of "far better"
> 
> 
> c besides has some other practicall annoyances, one that was bothering me in recent times were (already mentioned back them)
> 
> foo(float a,b,c) {} //lack of that syntax
> 
> //float3 a,b;
> float3 x = a+5*b; //lack of basic (and strightforward) vector arithmetic like that
> 
> on semantic level lack of "static variable" that is tied to a place of calling of function is also anoyin 
> 
> void foo()
> {
>    static r = rand()%1100;
> }
> 
> void boo()
> {
>     foo();
>     foo();
>     foo();
>     foo(); //each one of that 
>           // four generates separate 
>          // inside static r variable (not
>          // just one common for them)
> 
> }
> 
> this last one was not strightforward to observe but is really needed if someone wants to write good c

other practically annoying things is
lack of possiblity to compile

int t = 10;
printf("%d",t);
int t = 20;
printf("%d",t);

would be handy for test when you re tired of commenting/uncoomentin and then you forgot to insert ior remove that int
typename

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


#144881

Fromfir <profesor.fir@gmail.com>
Date2019-06-15 03:24 -0700
Message-ID<e6626c62-35af-48db-ac85-0fe96fb5d40b@googlegroups.com>
In reply to#144879
W dniu sobota, 15 czerwca 2019 11:04:40 UTC+2 użytkownik fir napisał:
> W dniu sobota, 15 czerwca 2019 10:25:05 UTC+2 użytkownik fir napisał:
> > W dniu piątek, 14 czerwca 2019 19:07:55 UTC+2 użytkownik Bart napisał:
> > > On 14/06/2019 16:21, Scott wrote:
> > > > On Fri, 14 Jun 2019 08:43:49 -0400, "Rick C. Hodgin"
> > > > <rick.c.hodgin@gmail.com> wrote:
> > > > 
> > > >> You don't have to declare everything before you use it.
> > > > 
> > > > Many people, including myself, consider that to be a bad thing.
> > > > 
> > > 
> > > You mean not declaring things at all, or not declaring them before first 
> > > use?
> > > 
> > > I find lack of out-of-order declarations in C, to be a considerable 
> > > pain. Although I think this mainly applies to functions.
> > 
> > 
> > thats true
> > 1) declarations visible upa nad down >> (FAR BETTER) than declarations visible down
> > 
> > 2) no declarations at all >> (FAR BETTER) than need of them
> > 
> > (both of those things are serious pains/mistakes in c) and the accent in thoise up statemants are on the meaning of "far better"
> > 
> > 
> > c besides has some other practicall annoyances, one that was bothering me in recent times were (already mentioned back them)
> > 
> > foo(float a,b,c) {} //lack of that syntax
> > 
> > //float3 a,b;
> > float3 x = a+5*b; //lack of basic (and strightforward) vector arithmetic like that
> > 
> > on semantic level lack of "static variable" that is tied to a place of calling of function is also anoyin 
> > 
> > void foo()
> > {
> >    static r = rand()%1100;
> > }
> > 
> > void boo()
> > {
> >     foo();
> >     foo();
> >     foo();
> >     foo(); //each one of that 
> >           // four generates separate 
> >          // inside static r variable (not
> >          // just one common for them)
> > 
> > }
> > 
> > this last one was not strightforward to observe but is really needed if someone wants to write good c
> 
> other practically annoying things is
> lack of possiblity to compile
> 
> int t = 10;
> printf("%d",t);
> int t = 20;
> printf("%d",t);
> 
> would be handy for test when you re tired of commenting/uncoomentin and then you forgot to insert ior remove that int
> typename

as to side c ideas: [not related to thsi aboe as thsoe above was like annoying things in present c who could be corrected, some other ideas are bigger changing of the languege]

i recently thought if c should or shouldnt 'glue' calls also by names, i mean if some have say function 

void foo(char* txt)

or 

void boo(float x, float y, float z)

if ith shouldnt work thsi way that you can pass some structures that hae such fields named thsi way and if this 'gluing' shouldnt be done automatically without explicite writing

some cold say 1) its not a big gain, 2) makes kode not be explicite (and this is kinda arguments) but im like closer to oopinion it could be done

(explaining why i think so is hoevver to wearing as my present hangoer/poisoning/
weak health state

maybe to note some args slightly
1) imo thsi si somewhat a matter of 'variability' of gluing things together in code (the more of such variability te batter)
2) thsi fact that arguments have names is liek not much used in c, it could be used/explored more

( 3) i agree its not explicite but still its a bit shorter, and in oldschol spirit way, the little shorter is still better)
*the being explicite rule is important but im not sure if in c rule that you need better to know definitions not beats it.if you know that definjitions its still explicite..this is hovever somewhat open topic)

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


#144882

Fromfir <profesor.fir@gmail.com>
Date2019-06-15 03:41 -0700
Message-ID<07309dc3-4eba-4bdd-a02c-b918b9a73369@googlegroups.com>
In reply to#144881
(this 'variability' probably has more role in case of methods (of modules, where modules (or its fields)are arguments) than in case of functions, and in fact i got this more in mind when thinking on it - but more on this another time)

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


#144920

FromAnton Shepelev <anton.txt@gmail.com>
Date2019-06-16 15:16 +0300
Message-ID<20190616151648.55225c616711350d0a62cd99@gmail.com>
In reply to#144879
fir:

> other practically annoying things is lack of possiblity to
> compile
>
> int t = 10;
> printf("%d",t);
> int t = 20;
> printf("%d",t);
>
> would be handy for test when you re tired of comment-
> ing/uncoomentin and then you forgot to insert ior remove
> that int typename

Declare `t' at the top of function.

-- 
()  ascii ribbon campaign -- against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

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


#144892

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-06-15 18:49 +0200
Message-ID<qe37jf$tie$1@news.albasani.net>
In reply to#144845
>> You don't have to declare everything before you use it.

> Many people, including myself, consider that to be a bad thing.

With todays IDEs it's not a pain when there aren't any forward
-declarations. Just right-click at the symbol and click the
option to guide to the definition.
I like C++ but I don't think forward-declarations are an adantage.

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


#144893

FromBart <bc@freeuk.com>
Date2019-06-15 17:58 +0100
Message-ID<Qs9NE.73765$w82.44148@fx33.am4>
In reply to#144892
On 15/06/2019 17:49, Bonita Montero wrote:
>>> You don't have to declare everything before you use it.
> 
>> Many people, including myself, consider that to be a bad thing.
> 
> With todays IDEs it's not a pain when there aren't any forward
> -declarations. Just right-click at the symbol and click the
> option to guide to the definition.

What good does that do? This is not about finding the definition. It is 
having to ensure that when writing this (or copying it, moving it, 
pasting it):

    fn(a,b,c);

that either a definition or declaration of fn has been encountered prior 
to this point.

  > I like C++ but I don't think forward-declarations are an adantage.

It's a language issue. If the IDE does take care of it, it means it's 
generating the necessary code, and also means you aren't strictly 
writing in C or C++, but a version of it doesn't need you to explicitly 
take care of such things.

If further means there there /is/ a need to deal with that nuisance.

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


#144910

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-06-16 07:28 +0200
Message-ID<qe4k24$rli$1@news.albasani.net>
In reply to#144893
> What good does that do? This is not about finding the definition. It
> is  having to ensure that when writing this (or copying it, moving it, 
> pasting it):
>     fn(a,b,c);
> that either a definition or declaration of fn has been encountered
> prior to this point.

There aren't any declarations with .net / Java so there isn't such a
problem.

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


#144907

Fromnobody@example.org (Scott)
Date2019-06-16 01:58 +0000
Message-ID<5d059fdf.3429680737@core>
In reply to#144892
On Sat, 15 Jun 2019 18:49:52 +0200, Bonita Montero
<Bonita.Montero@gmail.com> wrote:

>>> You don't have to declare everything before you use it.
>
>> Many people, including myself, consider that to be a bad thing.
>
>With todays IDEs it's not a pain when there aren't any forward
>-declarations. Just right-click at the symbol and click the
>option to guide to the definition.
>I like C++ but I don't think forward-declarations are an adantage.

There are ways. Long ago I wrote an assembler that avoided forward
declarations by making two passes over the source. C doesn't do that,
for reasons.

C does allow implicit declarations. You can call a previously
undeclared function, and C will trust that the types you're passing
are the types the function's expecting. I think it's a bad idea, and
it usually yields warnings suggesting that it's a bad idea. I think
any form of implicit typing is a bad idea.

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


#144909

FromKeith Thompson <kst-u@mib.org>
Date2019-06-15 19:31 -0700
Message-ID<lnlfy2ntvy.fsf@kst-u.example.com>
In reply to#144907
nobody@example.org (Scott) writes:
[...]
> C does allow implicit declarations. You can call a previously
> undeclared function, and C will trust that the types you're passing
> are the types the function's expecting. I think it's a bad idea, and
> it usually yields warnings suggesting that it's a bad idea. I think
> any form of implicit typing is a bad idea.

No, it doesn't.  Calling an undeclared function has been a constraint
violation since C99 dropped the "implicit int" rule.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

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


#144912

Fromnobody@example.org (Scott)
Date2019-06-16 08:20 +0000
Message-ID<5d05fa0f.3452768783@core>
In reply to#144909
On Sat, 15 Jun 2019 19:31:13 -0700, Keith Thompson <kst-u@mib.org>
wrote:

>nobody@example.org (Scott) writes:
>[...]
>> C does allow implicit declarations. You can call a previously
>> undeclared function, and C will trust that the types you're passing
>> are the types the function's expecting. I think it's a bad idea, and
>> it usually yields warnings suggesting that it's a bad idea. I think
>> any form of implicit typing is a bad idea.
>
>No, it doesn't.  Calling an undeclared function has been a constraint
>violation since C99 dropped the "implicit int" rule.

Apparently not a fatal one. gcc 7.4 with -std=c99 warns, but builds it
anyway.

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


#144916

FromKeith Thompson <kst-u@mib.org>
Date2019-06-16 02:24 -0700
Message-ID<lnh88popbq.fsf@kst-u.example.com>
In reply to#144912
nobody@example.org (Scott) writes:
> On Sat, 15 Jun 2019 19:31:13 -0700, Keith Thompson <kst-u@mib.org>
> wrote:
>>nobody@example.org (Scott) writes:
>>[...]
>>> C does allow implicit declarations. You can call a previously
>>> undeclared function, and C will trust that the types you're passing
>>> are the types the function's expecting. I think it's a bad idea, and
>>> it usually yields warnings suggesting that it's a bad idea. I think
>>> any form of implicit typing is a bad idea.
>>
>>No, it doesn't.  Calling an undeclared function has been a constraint
>>violation since C99 dropped the "implicit int" rule.
>
> Apparently not a fatal one. gcc 7.4 with -std=c99 warns, but builds it
> anyway.

As I said, it's a constraint violation.  That means that a conforming
compiler must issue a diagnostic message.  It's not required to be
fatal.  In fact the only construct that required a fatal error is the
"#error" directive.  (I personally wish gcc were more strict, but that's
a whole 'nother kettle of fish.)

The lesson is that warnings from C compilers should be taken *very*
seriously.

"gcc -std=c99 -pedantic" results in a fatal error.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

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


#144923

Fromnobody@example.org (Scott)
Date2019-06-16 17:03 +0000
Message-ID<5d067312.3483747362@core>
In reply to#144916
On Sun, 16 Jun 2019 02:24:25 -0700, Keith Thompson <kst-u@mib.org>
wrote:

>nobody@example.org (Scott) writes:
>> On Sat, 15 Jun 2019 19:31:13 -0700, Keith Thompson <kst-u@mib.org>
>> wrote:
>>>nobody@example.org (Scott) writes:
>> Apparently not a fatal one. gcc 7.4 with -std=c99 warns, but builds it
>> anyway.
>
>As I said, it's a constraint violation.  That means that a conforming
>compiler must issue a diagnostic message.  It's not required to be
>fatal.  In fact the only construct that required a fatal error is the
>"#error" directive.  (I personally wish gcc were more strict, but that's
>a whole 'nother kettle of fish.)
>
>The lesson is that warnings from C compilers should be taken *very*
>seriously.
>
>"gcc -std=c99 -pedantic" results in a fatal error.

Hmm. Which gcc are you using? Mine (7.4.0) still gives a warning with
those flags. -pedantic-errors does give an error as I expected. I'm
not saying you're wrong, I'm just curious why we're seeing different
results with the same experiment.

The source snippet I used is this:

int main(void) { return 45 != foo("Hello", 2.5, 45); }
int foo(char *x, double y, int z) { return z; }

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


#144930

FromKeith Thompson <kst-u@mib.org>
Date2019-06-16 14:24 -0700
Message-ID<ln8su1ns08.fsf@kst-u.example.com>
In reply to#144923
nobody@example.org (Scott) writes:
> On Sun, 16 Jun 2019 02:24:25 -0700, Keith Thompson <kst-u@mib.org>
> wrote:
>>nobody@example.org (Scott) writes:
>>> On Sat, 15 Jun 2019 19:31:13 -0700, Keith Thompson <kst-u@mib.org>
>>> wrote:
>>>>nobody@example.org (Scott) writes:
>>> Apparently not a fatal one. gcc 7.4 with -std=c99 warns, but builds it
>>> anyway.
>>
>>As I said, it's a constraint violation.  That means that a conforming
>>compiler must issue a diagnostic message.  It's not required to be
>>fatal.  In fact the only construct that required a fatal error is the
>>"#error" directive.  (I personally wish gcc were more strict, but that's
>>a whole 'nother kettle of fish.)
>>
>>The lesson is that warnings from C compilers should be taken *very*
>>seriously.
>>
>>"gcc -std=c99 -pedantic" results in a fatal error.
>
> Hmm. Which gcc are you using? Mine (7.4.0) still gives a warning with
> those flags. -pedantic-errors does give an error as I expected. I'm
> not saying you're wrong, I'm just curious why we're seeing different
> results with the same experiment.
>
> The source snippet I used is this:
>
> int main(void) { return 45 != foo("Hello", 2.5, 45); }
> int foo(char *x, double y, int z) { return z; }

Sorry, I messed that up.

"gcc -std=c99" should correctly compile all correct C99 programs.

"gcc -std=c99 -pedantic" should do the same and issue all required
diagnostics.  In this mode, it should be a conforming C99 compiler.

"gcc -std=c99 -pedantic-errors" turns all required diagnostics into
fatal errors.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

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


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

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


csiph-web