Re: rms from rosettacode

Discussion in 'C Programming' started by Kaz Kylheku, Dec 27, 2011.

  1. Kaz Kylheku

    Kaz Kylheku Guest

    On 2011-12-27, superpollo <> wrote:
    > what gives?


    What gives is that you're not yet competent enough in C to be working on
    Rosetta Code examples. Please find a different hobby.
    Kaz Kylheku, Dec 27, 2011
    #1
    1. Advertising

  2. Kaz Kylheku

    Seebs Guest

    On 2011-12-27, Kaz Kylheku <> wrote:
    > On 2011-12-27, superpollo <> wrote:
    >> what gives?


    > What gives is that you're not yet competent enough in C to be working on
    > Rosetta Code examples. Please find a different hobby.


    I would rather see people be in over their heads on Rosetta Code than on
    medical equipment. :)

    -s
    --
    Copyright 2011, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
    I am not speaking for my employer, although they do rent some of my opinions.
    Seebs, Dec 27, 2011
    #2
    1. Advertising

  3. Kaz Kylheku

    Eric Sosman Guest

    On 12/27/2011 3:31 PM, superpollo wrote:
    > Kaz Kylheku ha scritto:
    >> On 2011-12-27, superpollo <> wrote:
    >>> what gives?

    >>
    >> What gives is that you're not yet competent enough in C to be working on
    >> Rosetta Code examples. Please find a different hobby.

    >
    > thanks for your constructive criticism. a beautiful way to lure
    > newcomers to the language!


    Especially "newcomers" who've participated in this forum since
    at least June 2009. "Newcomers" who've taken thirty or more months
    to fail to find the FAQ.

    Yes, Kaz is being a bit brutal. But I think he's being honest:
    If in two and a half years you have not learned what happens when you
    "pass an array" to a function, you have scant aptitude for this
    particular discipline. Other and worthier disciplines exist; go and
    pursue one of those.

    --
    Eric Sosman
    d
    Eric Sosman, Dec 28, 2011
    #3
  4. On Dec 28, 1:49 am, Eric Sosman <> wrote:
    > On 12/27/2011 3:31 PM, superpollo wrote:
    >
    > > Kaz Kylheku ha scritto:
    > >> On 2011-12-27, superpollo <> wrote:
    > >>> what gives?

    >
    > >> What gives is that you're not yet competent enough in C to be working on
    > >> Rosetta Code examples. Please find a different hobby.

    >
    > > thanks for your constructive criticism. a beautiful way to lure
    > > newcomers to the language!

    >
    >      Especially "newcomers" who've participated in this forum since
    > at least June 2009.  "Newcomers" who've taken thirty or more months
    > to fail to find the FAQ.
    >
    >      Yes, Kaz is being a bit brutal.  But I think he's being honest:
    > If in two and a half years you have not learned what happens when you
    > "pass an array" to a function, you have scant aptitude for this
    > particular discipline.  Other and worthier disciplines exist; go and
    > pursue one of those.


    good grief. So he missed something (something important, admittedly!).
    I'm a fan of virtually anyone learning to program. I think it should
    be part of 21st century literacy.
    Nick Keighley, Dec 28, 2011
    #4
  5. Kaz Kylheku

    James Kuyper Guest

    On 12/27/2011 08:49 PM, Eric Sosman wrote:
    > On 12/27/2011 3:31 PM, superpollo wrote:
    >> Kaz Kylheku ha scritto:
    >>> On 2011-12-27, superpollo <> wrote:
    >>>> what gives?
    >>>
    >>> What gives is that you're not yet competent enough in C to be working on
    >>> Rosetta Code examples. Please find a different hobby.

    >>
    >> thanks for your constructive criticism. a beautiful way to lure
    >> newcomers to the language!

    >
    > Especially "newcomers" who've participated in this forum since
    > at least June 2009. "Newcomers" who've taken thirty or more months
    > to fail to find the FAQ.
    >
    > Yes, Kaz is being a bit brutal. But I think he's being honest:
    > If in two and a half years you have not learned what happens when you
    > "pass an array" to a function, you have scant aptitude for this
    > particular discipline. Other and worthier disciplines exist; go and
    > pursue one of those.


    I think you're both being a bit harsh on him. When I saw his comment
    about being a newcomer, I had the same response - I remembered him being
    a long-term participant. However, when I searched with Google groups, I
    also found out he'd been posting here for only 30 months, and I decided
    not to comment. It's a fairly long time to have made so little progress
    in understanding C. However, if he's learning it on his own time while
    working full time, and not taking any classes in C, it's not completely
    unreasonable that he might still be at this low level, particularly if
    there's any other reason (such as, for example, being a single father)
    that most of the rest of his "spare" time is already accounted for.
    --
    James Kuyper
    James Kuyper, Dec 28, 2011
    #5
  6. Kaz Kylheku

    BartC Guest

    "James Kuyper" <> wrote in message
    news:jdf43c$aph$...
    > On 12/27/2011 08:49 PM, Eric Sosman wrote:


    >> If in two and a half years you have not learned what happens when you
    >> "pass an array" to a function, you have scant aptitude for this
    >> particular discipline. Other and worthier disciplines exist; go and
    >> pursue one of those.

    >
    > I think you're both being a bit harsh on him. When I saw his comment
    > about being a newcomer, I had the same response - I remembered him being
    > a long-term participant. However, when I searched with Google groups, I
    > also found out he'd been posting here for only 30 months, and I decided
    > not to comment.


    I've been posting here a lot longer, but still have problems with some
    things that should be straightforward to a C programmer.

    For example, I had trouble the other night with creating a struct with
    self-referential members. I tried loads of combinations including forward
    declarations and got nowhere. I was about to post here, then came across
    this form in some code that was lying around:

    typedef struct snode{
    int value;
    int opcode;
    struct snode *aref,*bref;
    } node;

    That worked, but how can I turn the 'struct snode*' into a much tidier 'node
    *'? This doesn't work:

    typedef struct {
    int value;
    int opcode;
    node *aref,*bref;
    } node;

    --
    Bartc
    BartC, Dec 28, 2011
    #6
  7. Kaz Kylheku

    Dr Nick Guest

    "BartC" <> writes:

    > "James Kuyper" <> wrote in message
    > news:jdf43c$aph$...
    >> On 12/27/2011 08:49 PM, Eric Sosman wrote:

    >
    >>> If in two and a half years you have not learned what happens when you
    >>> "pass an array" to a function, you have scant aptitude for this
    >>> particular discipline. Other and worthier disciplines exist; go and
    >>> pursue one of those.

    >>
    >> I think you're both being a bit harsh on him. When I saw his comment
    >> about being a newcomer, I had the same response - I remembered him being
    >> a long-term participant. However, when I searched with Google groups, I
    >> also found out he'd been posting here for only 30 months, and I decided
    >> not to comment.

    >
    > I've been posting here a lot longer, but still have problems with some
    > things that should be straightforward to a C programmer.
    >
    > For example, I had trouble the other night with creating a struct with
    > self-referential members. I tried loads of combinations including
    > forward declarations and got nowhere. I was about to post here, then
    > came across this form in some code that was lying around:
    >
    > typedef struct snode{
    > int value;
    > int opcode;
    > struct snode *aref,*bref;
    > } node;
    >
    > That worked, but how can I turn the 'struct snode*' into a much tidier 'node
    > *'? This doesn't work:
    >
    > typedef struct {
    > int value;
    > int opcode;
    > node *aref,*bref;
    > } node;


    IIRC:

    typedef struct snode snode;
    struct snode {
    int value;
    int opcode;
    snode *aref,*bref;
    };

    those empty struct things (I'm keeping well clear of the
    definitions/declarations arguments here) aren't needed very often, but
    when they are, they are very useful.
    --
    Online waterways route planner | http://canalplan.eu
    Plan trips, see photos, check facilities | http://canalplan.org.uk
    Dr Nick, Dec 28, 2011
    #7
  8. Kaz Kylheku

    Kaz Kylheku Guest

    On 2011-12-27, superpollo <> wrote:
    > Kaz Kylheku ha scritto:
    >> On 2011-12-27, superpollo <> wrote:
    >>> what gives?

    >>
    >> What gives is that you're not yet competent enough in C to be working on
    >> Rosetta Code examples. Please find a different hobby.

    >
    > thanks for your constructive criticism. a beautiful way to lure
    > newcomers to the language!


    Sorry, I thought you might have been thinking of actually editing the Rosetta
    Code example to "improve" it. Knee-jerk reaction from having fixed bad C on
    that site.

    I meant "find a hobby other than editing Rosetta Code C examples",
    not "stop learning C programming", of course!

    Speaking of which, Rosetta Code C solutions are a mixed bag of nuts.
    Many are not well-written: poor handling of errors and corner cases, and
    written as if the standard library didn't exist (e.g. reimplementing functions
    like strchr from scratch). I recently fixed a bunch that neglected to
    null terminate strings (nor even allocate space for that).

    You could inadvertently pick up bad ideas by studying these examples.
    Kaz Kylheku, Dec 28, 2011
    #8
  9. Kaz Kylheku

    Kaz Kylheku Guest

    On 2011-12-28, BartC <> wrote:
    > I've been posting here a lot longer, but still have problems with some
    > things that should be straightforward to a C programmer.
    >
    > For example, I had trouble the other night with creating a struct with
    > self-referential members. I tried loads of combinations including forward
    > declarations and got nowhere. I was about to post here, then came across
    > this form in some code that was lying around:
    >
    > typedef struct snode{
    > int value;
    > int opcode;
    > struct snode *aref,*bref;
    > } node;


    There is no need for the tag and typedef name to be different. They
    are in a different namespace disambiguated by the "struct" keyword:

    typedef struct node {
    int value;
    int opcode;
    struct node *aref, *bref;
    } node;

    Maybe the use of two symbols snode and node adds to your perception
    that it is untidy. I mean, if you have N structures, you use 2*N
    identifiers in their naming.

    > That worked, but how can I turn the 'struct snode*' into a much tidier 'node
    > *'? This doesn't work:


    This brings to mind an earlier Eric Sosman posting, where he recounted
    an analogy from a friend: maybe you're trying to clean the beach of bottle caps
    and cigarette butts so that the areas around the rotting whale carcasses are
    nice and clean.

    How tidy will the overall program be when it grows large and complex?

    Big C programs are very hard to keep tidy. Even if the program is developed by
    a single developer in his spare time, who is single-mindedly dedicated to
    tidiness, tidiness will eventually give way here and there to functionality.

    > typedef struct {
    > int value;
    > int opcode;
    > node *aref,*bref;
    > } node;



    Perfectly valid C++, hint hint:

    struct node {
    node *aref;
    };

    In C there is no way around the keyword struct occuring twice, e.g:

    /* A */
    typedef struct node node;
    struct node {
    node *aref, *bref;
    };


    /* B */
    struct node {
    typedef struct node node;
    node *aref, *bref;
    };

    B loses C++ compatibility though. The typedef name is not scoped to
    the struct in C, but in C++ it is in class scope.

    Well, there is always preprocessing:

    #define node struct node

    node { /* oh, boy! */
    node *a, *b;
    }
    Kaz Kylheku, Dec 28, 2011
    #9
  10. "BartC" <> writes:
    [...]
    > For example, I had trouble the other night with creating a struct with
    > self-referential members. I tried loads of combinations including forward
    > declarations and got nowhere. I was about to post here, then came across
    > this form in some code that was lying around:
    >
    > typedef struct snode{
    > int value;
    > int opcode;
    > struct snode *aref,*bref;
    > } node;
    >
    > That worked, but how can I turn the 'struct snode*' into a much tidier 'node
    > *'? This doesn't work:
    >
    > typedef struct {
    > int value;
    > int opcode;
    > node *aref,*bref;
    > } node;


    My suggestion is just to drop the "typedef" altogether, and refer to the
    type as "struct snode":

    struct snode {
    int value;
    int opcode;
    struct snode *aref;
    struct snode *bref;
    };

    If you feel the need to have a one-word name for the type, you can
    typedef the incomplete struct type and then complete it by defining it.
    Note that there's no need to use different names for the struct tag and
    the typedef:

    typedef struct snode snode;
    struct snode {
    int opcode;
    snode *aref;
    snode *bref;
    };

    Another common approach is to combine the typedef and struct
    declarations -- but then the typedef isn't visible until the end
    of the struct declaration:

    typedef struct snode {
    int opcode;
    struct snode *aref;
    struct snode *bref;
    } snode;

    But really, the type already has a perfectly good name, "struct snode".
    Hiding its "structness" behind a typedef doesn't buy you anything.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Will write code for food.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Dec 28, 2011
    #10
  11. Kaz Kylheku

    Phil Carmody Guest

    superpollo <> writes:
    > Eric Sosman ha scritto:
    > > On 12/27/2011 3:31 PM, superpollo wrote:
    > >> Kaz Kylheku ha scritto:
    > >>> On 2011-12-27, superpollo <> wrote:
    > >>>> what gives?
    > >>>
    > >>> What gives is that you're not yet competent enough in C to be working on
    > >>> Rosetta Code examples. Please find a different hobby.
    > >>
    > >> thanks for your constructive criticism. a beautiful way to lure
    > >> newcomers to the language!

    > > Especially "newcomers" who've participated in this forum since
    > > at least June 2009.

    >
    > ps: i did NOT mean I AM a newcomer with that sentence... i am very
    > well aware of the rough edges of this group which i lurk in since way
    > back, and i am well prepared to get bruised from time to time. but
    > NEWCOMERS might be scared by that, and THAT is not a good thing, IMHO.


    Newcomers didn't make the statements you made, you did.
    Stop trying to construct a straw man.

    My reply would have been different from Kaz's. Mine would have been more
    like:
    """
    > i am quite unhappy with having to say to the rms
    > function how big the array is...


    Your state of unhappiness is because you are fighting against ancient
    and immutable features of the language. Either find a language you
    are happier with, or learn and remember these features of C.
    """
    Which has a vastly inferior information density.

    Phil
    --
    Unix is simple. It just takes a genius to understand its simplicity
    -- Dennis Ritchie (1941-2011), Unix Co-Creator
    Phil Carmody, Dec 29, 2011
    #11
  12. Kaz Kylheku

    Phil Carmody Guest

    "BartC" <> writes:
    > "James Kuyper" <> wrote in message
    > news:jdf43c$aph$...
    > > On 12/27/2011 08:49 PM, Eric Sosman wrote:

    >
    > >> If in two and a half years you have not learned what happens when you
    > >> "pass an array" to a function, you have scant aptitude for this
    > >> particular discipline. Other and worthier disciplines exist; go and
    > >> pursue one of those.

    > >
    > > I think you're both being a bit harsh on him. When I saw his comment
    > > about being a newcomer, I had the same response - I remembered him being
    > > a long-term participant. However, when I searched with Google groups, I
    > > also found out he'd been posting here for only 30 months, and I decided
    > > not to comment.

    >
    > I've been posting here a lot longer, but still have problems with some
    > things that should be straightforward to a C programmer.
    >
    > For example, I had trouble the other night with creating a struct with
    > self-referential members. I tried loads of combinations including
    > forward declarations and got nowhere. I was about to post here, then
    > came across this form in some code that was lying around:
    >
    > typedef struct snode{
    > int value;
    > int opcode;
    > struct snode *aref,*bref;
    > } node;
    >
    > That worked, but how can I turn the 'struct snode*' into a much tidier 'node
    > *'? This doesn't work:
    >
    > typedef struct {
    > int value;
    > int opcode;
    > node *aref,*bref;
    > } node;


    "Much" tidier? Removing one single token from your code makes it
    "much" tidier? Get real. You might have an irrational dislike of
    the struct keyword, but that doesn't mean others do. I'm sure there
    are as many who like to avoid typedef as much as you want to avoid
    struct. Your "tidy" would be their "opaque".

    Phil
    --
    Unix is simple. It just takes a genius to understand its simplicity
    -- Dennis Ritchie (1941-2011), Unix Co-Creator
    Phil Carmody, Dec 29, 2011
    #12
  13. Kaz Kylheku

    Eric Sosman Guest

    On 12/28/2011 5:26 AM, Nick Keighley wrote:
    > On Dec 28, 1:49 am, Eric Sosman<> wrote:
    >> On 12/27/2011 3:31 PM, superpollo wrote:
    >>
    >>> Kaz Kylheku ha scritto:
    >>>> On 2011-12-27, superpollo<> wrote:
    >>>>> what gives?

    >>
    >>>> What gives is that you're not yet competent enough in C to be working on
    >>>> Rosetta Code examples. Please find a different hobby.

    >>
    >>> thanks for your constructive criticism. a beautiful way to lure
    >>> newcomers to the language!

    >>
    >> Especially "newcomers" who've participated in this forum since
    >> at least June 2009. "Newcomers" who've taken thirty or more months
    >> to fail to find the FAQ.
    >>
    >> Yes, Kaz is being a bit brutal. But I think he's being honest:
    >> If in two and a half years you have not learned what happens when you
    >> "pass an array" to a function, you have scant aptitude for this
    >> particular discipline. Other and worthier disciplines exist; go and
    >> pursue one of those.

    >
    > good grief. So he missed something (something important, admittedly!).
    > I'm a fan of virtually anyone learning to program. I think it should
    > be part of 21st century literacy.


    He "missed" something rather fundamental, rather basic, rather
    second-week-of-the-first-semester. It's on Page 24 of K&R (classic).
    It's on Page 33 of "C Traps and Pitfalls." Harbison & Steele don't
    mention it until Page 248, but they don't even start talking about
    functions at all until Page 237 (I don't like their book much). The
    FAQ devotes all of Section 6 to explaining pointers vis-a-vis arrays,
    and in fact Question 6.21 is *exactly* the O.P.'s point of confusion.

    And in thirty months he's found none of these.

    It's been suggested that the O.P. may be overburdened by other
    responsibilities, diverting him so drastically from the study of C
    that he makes only (say) three weeks' progress in thirty months. His
    profile in Google Groups indicates, though, that he has a fair amount
    of time on his hands: He's made four thousand two hundred seventy-two
    Usenet posts this year, eleven point eight per day, one every two
    hours, day in and day out. He may be wasting his time, but he's got
    the time.

    --
    Eric Sosman
    d
    Eric Sosman, Dec 29, 2011
    #13
  14. On Dec 28, 10:42 am, superpollo <> wrote:
    > Eric Sosman ha scritto:
    > > On 12/27/2011 3:31 PM, superpollo wrote:
    > >> Kaz Kylheku ha scritto:
    > >>> On 2011-12-27, superpollo <> wrote:


    <snip>

    > >>> What gives is that you're not yet competent enough in C to be workingon
    > >>> Rosetta Code examples. Please find a different hobby.


    <snip>

    > >     Especially "newcomers" who've participated in this forum since
    > > at least June 2009.  "Newcomers" who've taken thirty or more months
    > > to fail to find the FAQ.

    >
    > >     Yes, Kaz is being a bit brutal.  But I think he's being honest:
    > > If in two and a half years you have not learned what happens when you
    > > "pass an array" to a function, you have scant aptitude for this
    > > particular discipline.  Other and worthier disciplines exist; go and
    > > pursue one of those.

    >
    > well, you may be right to some extent. but you have also to concede that
    > trying to learn a hard programming language (which i really want to,
    > believe me) takes time and dedication, and in my case i must regret that
    > i cannot be so dedicated, due to job and family chores.
    >
    > but still, i will not surrender, i will stubbornly pursue my way to
    > learning C, at my pace. if in the meantime i occasionally post some
    > silly questions here at c.l.c., i think i may be excused to do so.


    which is kind of what clc is for...

    > i
    > even bought the king book last week (inspired by another poster) and i
    > will try to study it a bit at a time.
    >
    > in the end, the most important thing is that now i have learnt something
    > that i did not know before, thanks to all of the repliers, even the
    > rudest. i knew(-ish) that "arrays are somewhat pointers what passed as
    > arguments":
    >
    > http://c-faq.com/aryptr/aryptrequiv.htm
    >
    > and i *knew* that the size thing had something to do with that, but the
    > DISCUSSION happens to have given me some key clarification about it. in
    > italy (my country) the equivalent of "newsgroup" is sort of "discussion
    > group", see?


    not really. Discussion groups and newsgroups are two different things
    and are not limited by national boundaries. I have a vague
    recollection there's an italian version of clc. Ah yes it.comp.lang.c
    and there seems to be some activity.

    > you know, we humans are much happier when discussing, maybe even
    > informally, about a given topic, instead of merely sifting thru some
    > heavily annotated and terse reference tome.


    there's a time and a place for both and having a quick look through
    the FAQ can save some time, besides improving your education. see
    http://c-faq.com/

    and I agree the discussion you prompted was interesting
    Nick Keighley, Dec 29, 2011
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rohit

    j2me and RMS

    Rohit, Apr 2, 2004, in forum: Java
    Replies:
    1
    Views:
    968
    Darryl L. Pierce
    Apr 2, 2004
  2. leggolas

    RMS and midlets

    leggolas, Mar 14, 2005, in forum: Java
    Replies:
    4
    Views:
    1,126
    leggolas
    Mar 22, 2005
  3. Spacey Spade
    Replies:
    4
    Views:
    626
    Remon van Vliet
    Jun 15, 2005
  4. James Kuyper

    Re: rms from rosettacode

    James Kuyper, Dec 27, 2011, in forum: C Programming
    Replies:
    4
    Views:
    302
    James Kuyper
    Dec 27, 2011
  5. BartC

    Re: rms from rosettacode

    BartC, Dec 27, 2011, in forum: C Programming
    Replies:
    11
    Views:
    454
    88888 Dihedral
    Dec 28, 2011
Loading...

Share This Page