Thread: is C appropriate for intro to computers?

  1. #61
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    The statement
    Code:
    bar[i] = foo[i++];
    could be done as (using an extra variable to more clearly show the different steps)
    Code:
    t = foo[i];
    bar[i] = t;
    i++;
    or
    Code:
    t = foo[i];
    i++;
    bar[i] = t;
    Both are reasonable interpretations. One could of course argue which one is "right" but that is moot. The standard decided to not define one as the correct behavior and left it as undefined behavior.

  2. #62
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    It is equally undefined for both C and C++.

  3. #63
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Code:
    bar[i--] = foo[i++]
    Would leave the value of i in doubt in addition to which array element got moved where.

  4. #64
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    That is why changing the value of a variable on both sides of an equation is considered undefined according to the standard. Just as it is undefined to change the same variable across multiple parameters of a function.

    Code:
    printf("%d %d", ++i, i--);

  5. #65
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by robwhit View Post
    Are you adverse to using a compiler switch to fix that problem in C89?
    That is a compiler fix and not a language fix which is what I'm having a grip with.
    It's a flaw that shouldn't have been in the language to begin with.

    Quote Originally Posted by Mario F. View Post
    My apologies.
    I tried to display that undefined behavior behind an implementation only to further the idea C++ (whether through its C roots or not is irrelevant) also has its share of undefined behavior and no compiler warnings, as seems to be Elysia's major gripe with C and her crusade to rid the world of C textbooks.
    I'm well aware of the fact and I did explain it too, that C++ isn't perfect and has its set of flaws.
    Some of them I would see fixed, yes.
    But C is much MORE flawed with things that shouldn't have been allowed in the first place. At least C++ fixes SOME of those things and is better in that regard.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #66
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    >> But C is much MORE flawed with things that shouldn't have been allowed in the first place. At least C++ fixes SOME of those things and is better in that regard.

    Yes. And introduces new things. Until you come with with a number for both cases, and also clearly justify "better" and "worst", I prefer to keep considering your whole arguments a display of your utter ignorance.

    Have a nice day.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #67
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    That is a compiler fix and not a language fix which is what I'm having a grip with.
    It's a flaw that shouldn't have been in the language to begin with.
    That's understandable. However, since there is an easy fix for it with the tools that are used in real life, then it makes C a usable tool again, as long as this fault is concerned. Wouldn't you agree?

  8. #68
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I would agree that it's nice that compiler vendors work around nasty stuff in languages that should never have been introduces. When they do exist, I tend to use them (such as VS's "safe" C functions such as strcpy_s and VS's iterator debugging, etc).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #69
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    So are you saying that you would use this workaround for this problem if you were working on C code?

  10. #70
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Absolutely, I most definitely would.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #71
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I feel like i'm talking to bloody brick wall!

    C99 doesn't have implicit function declarations!
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #72
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Can you think of any situation where this workaround would not be workable?

  13. #73
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Mario F. View Post
    I feel like i'm talking to bloody brick wall!

    C99 doesn't have implicit function declarations!
    I got that already, but I was discussing GENERALLY, not a SPECIFIC something.
    I already acknowledged that C99 has taken steps in the right direction.

    Quote Originally Posted by robwhit View Post
    Can you think of any situation where this workaround would not be workable?
    Other than when I would be forced to use a compiler such as one that does not support said feature, no.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #74
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Given that you would use this workaround in all situations that supported it, and all situations that you know support it (Post #39), wouldn't this detraction from why to use C not apply in real life, since in real life, you need a compiler for C code?

  15. #75
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Elysia View Post
    I got that already, but I was discussing GENERALLY, not a SPECIFIC something.
    I already acknowledged that C99 has taken steps in the right direction.
    So, is it you advocate against C because you GENERALLY think you should, or because you SPECIFICALLY think you should?

    Do you honestly think people should listen to you if you can be coherent in the course of a single thread, if you don't understand the difference between design and implementation, and you don't have the smallest clue of the industry?

    I refrain from commenting on the rest because I see where robwhit is taking it... albeit I fear is as useless as any other attempt so far. You lack humility.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Numeric addresses for computers
    By great in forum C Programming
    Replies: 4
    Last Post: 08-23-2010, 11:53 AM
  2. Computers as authors
    By hk_mp5kpdw in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-22-2004, 08:55 PM
  3. Industrial vs home computers
    By nbo10 in forum Tech Board
    Replies: 10
    Last Post: 09-01-2004, 02:04 AM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  5. Love programming, hate computers
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 12-14-2002, 01:04 PM