print "foo" without using ;

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Bos

    #31
    Re: print "foo&qu ot; without using ;

    Denis Kasak <denis.kasak@gm ail.com> wrote:
    [color=blue]
    > Fao, Sean wrote:[color=green]
    > >
    > > Mostly off-topic, but perhaps surprising is the fact that Microsoft
    > > actually accepts void as a valid return type.
    > >
    > > http://msdn.microsoft.com./library/d...n_function.asp[/color]
    >
    > Sometimes I wonder if they're deliberately trying to break things.[/color]

    ....and then you wake up and realise that they've been known to do so,
    and deliberately, for decades?

    Richard

    Comment

    • Denis Kasak

      #32
      Re: print &quot;foo&qu ot; without using ;

      Richard Bos wrote:[color=blue]
      >
      > ....and then you wake up and realise that they've been known to do so,
      > and deliberately, for decades?[/color]

      I guess I'm still living in my little fantasy world where Microsoft
      doesn't do so much damage to everything.

      -- Denis

      Comment

      • Mark McIntyre

        #33
        Re: print &quot;foo&qu ot; without using ;

        On Fri, 26 Aug 2005 07:46:42 GMT, in comp.lang.c ,
        rlb@hoekstra-uitgeverij.nl (Richard Bos) wrote:
        [color=blue]
        >Denis Kasak <denis.kasak@gm ail.com> wrote:
        >[color=green]
        >> Fao, Sean wrote:[color=darkred]
        >> >
        >> > Mostly off-topic, but perhaps surprising is the fact that Microsoft
        >> > actually accepts void as a valid return type.
        >> >
        >> > http://msdn.microsoft.com./library/d...n_function.asp[/color]
        >>
        >> Sometimes I wonder if they're deliberately trying to break things.[/color]
        >
        >...and then you wake up and realise that they've been known to do so,
        >and deliberately, for decades?[/color]

        Actually, that entry in the MSDN has been updated in the last year or
        so. For a very long time, it said that main must return an int, and
        immediately followed it by an example showing main returning void. Go
        figure...

        I also find the bit about exit() remarkable.
        --
        Mark McIntyre
        CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
        CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

        ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
        http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
        ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

        Comment

        • Mark McIntyre

          #34
          Re: print &quot;foo&qu ot; without using ;

          On Thu, 25 Aug 2005 18:53:22 GMT, in comp.lang.c , Keith Thompson
          <kst-u@mib.org> wrote:
          [color=blue]
          >"Fao, Sean" <enceladus311@y ahoo.comI-WANT-NO-SPAM> writes:
          >[...][color=green]
          >> Mostly off-topic, but perhaps surprising is the fact that Microsoft
          >> actually accepts void as a valid return type.
          >>
          >> http://msdn.microsoft.com./library/d...n_function.asp[/color]
          >
          >That web page refers to C++, not C.[/color]

          Which is even more ridiculous of course.

          --
          Mark McIntyre
          CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
          CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

          ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
          http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
          ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

          Comment

          • Thad Smith

            #35
            Re: print &quot;foo&qu ot; without using ;

            Fao, Sean wrote:
            [color=blue]
            > Mostly off-topic, but perhaps surprising is the fact that Microsoft
            > actually accepts void as a valid return type.
            >
            > http://msdn.microsoft.com./library/d...n_function.asp[/color]

            Not surprising here. The main reason that an OS (or other calling
            environment) wouldn't accept a void function, rather than an function
            returning int is that the calling convention is incompatible. Since C
            evolved from K&R, which didn't have void types, and therefore used
            default int type functions. When ANSI C was being developed and a void
            type added, implementors wisely did not make calling void functions
            incompatible with calling an int function. Of course, such calling
            compatibility isn't guaranteed, but happens most of the time. What
            implementations are you familiar with in which the calling convention
            for a void function and an int function are different? I am not aware
            of any.

            Thad

            Comment

            • Michael Wojcik

              #36
              Re: print &quot;foo&qu ot; without using ;


              In article <430fc460$0$827 13$892e0abb@aut h.newsreader.oc tanews.com>, Thad Smith <ThadSmith@acm. org> writes:[color=blue]
              > Fao, Sean wrote:
              >[color=green]
              > > Mostly off-topic, but perhaps surprising is the fact that Microsoft
              > > actually accepts void as a valid return type.[/color]
              >
              > Not surprising here. The main reason that an OS (or other calling
              > environment) wouldn't accept a void function, rather than an function
              > returning int is that the calling convention is incompatible.[/color]

              It's not a matter for the OS, but one for the implementation. An
              implementation which runs on top of an OS might disallow "void main"
              as an alternative, non-standard form because of some issue with that
              OS, but there are certainly other possibilities. For example, an
              implementation might disallow it because its authors wish to enforce
              explicitly returning a valid status.

              I'm curious to know how you determined that "calling convention"
              (which is not covered by the standard) is the "main reason" for
              disallowing alternative forms of main.
              [color=blue]
              > When ANSI C was being developed and a void
              > type added, implementors wisely did not make calling void functions
              > incompatible with calling an int function.[/color]

              In what sense? The standard certainly makes calling a function
              incorrectly - ie, with an incorrect prototype in scope, or without
              a prototype in scope if the function is not declared in a manner
              compatible with a non-prototyped function - an error, which sounds
              like "incompatib le" to me.
              [color=blue]
              > Of course, such calling compatibility isn't guaranteed,[/color]

              If the standard doesn't guarantee compatibility, then it makes it
              incompatible. There is no middle. "Happens to work" is a possible
              result of undefined behavior; it doesn't demonstrate anything about
              either the intentions or requirements of the standard.
              [color=blue]
              > What
              > implementations are you familiar with in which the calling convention
              > for a void function and an int function are different?[/color]

              EPM C for the AS/400, for one.
              [color=blue]
              > I am not aware of any.[/color]

              Anecdotal evidence, as always, demonstrates nothing about the C
              language.

              --
              Michael Wojcik michael.wojcik@ microfocus.com

              When [Columbus] landed on America it was more like an evasion than a
              discovery. -- Matt Walsh

              Comment

              • Joe Wright

                #37
                Re: print &quot;foo&qu ot; without using ;

                Thad Smith wrote:[color=blue]
                > Fao, Sean wrote:
                >[color=green]
                >> Mostly off-topic, but perhaps surprising is the fact that Microsoft
                >> actually accepts void as a valid return type.
                >>
                >> http://msdn.microsoft.com./library/d...n_function.asp[/color]
                >
                >
                >
                > Not surprising here. The main reason that an OS (or other calling
                > environment) wouldn't accept a void function, rather than an function
                > returning int is that the calling convention is incompatible. Since C
                > evolved from K&R, which didn't have void types, and therefore used
                > default int type functions. When ANSI C was being developed and a void
                > type added, implementors wisely did not make calling void functions
                > incompatible with calling an int function. Of course, such calling
                > compatibility isn't guaranteed, but happens most of the time. What
                > implementations are you familiar with in which the calling convention
                > for a void function and an int function are different? I am not aware
                > of any.
                >
                > Thad
                >[/color]
                Utter nonsense. How can you possibly offer such trash in the group where
                you know the masters live.

                1. There is no term 'calling environment' in common parlance.
                2. The term 'calling convention' is commonly used but you obviously
                don't know what it means (look it up).
                3. As of C89 we are allowed to declare and define generic functions of
                type void. Nothing to do with calling convention.

                The function main() is NOT a generic. It is the real name of your C
                program. It is called by the command shell and has a 'value' of type
                int. Not void, int! This was decided among Ken Thompson and Dennis
                Ritchie circa 1972, three years before Bill, 19 years old in 1975
                started Microsoft.

                K&R (1978), C89 and C99 all define main() with type int.

                --
                Joe Wright
                "Everything should be made as simple as possible, but not simpler."
                --- Albert Einstein ---

                Comment

                • Keith Thompson

                  #38
                  Re: print &quot;foo&qu ot; without using ;

                  Joe Wright <jwright@comcas t.net> writes:[color=blue]
                  > Thad Smith wrote:[color=green]
                  >> Fao, Sean wrote:
                  >>[color=darkred]
                  >>> Mostly off-topic, but perhaps surprising is the fact that Microsoft
                  >>> actually accepts void as a valid return type.
                  >>>
                  >>> http://msdn.microsoft.com./library/d...n_function.asp[/color]
                  >> Not surprising here. The main reason that an OS (or other calling
                  >> environment) wouldn't accept a void function, rather than an
                  >> function returning int is that the calling convention is
                  >> incompatible. Since C evolved from K&R, which didn't have void
                  >> types, and therefore used default int type functions. When ANSI C
                  >> was being developed and a void type added, implementors wisely did
                  >> not make calling void functions incompatible with calling an int
                  >> function. Of course, such calling compatibility isn't guaranteed,
                  >> but happens most of the time. What implementations are you familiar
                  >> with in which the calling convention for a void function and an int
                  >> function are different? I am not aware of any.
                  >> Thad
                  >>[/color]
                  > Utter nonsense. How can you possibly offer such trash in the group
                  > where you know the masters live.[/color]

                  Actually, I think he's basically correct.
                  [color=blue]
                  > 1. There is no term 'calling environment' in common parlance.[/color]

                  The term occurs in the standard, though in a slightly different
                  context, and the meaning seems clear enough.
                  [color=blue]
                  > 2. The term 'calling convention' is commonly used but you obviously
                  > don't know what it means (look it up).
                  > 3. As of C89 we are allowed to declare and define generic functions of
                  > type void. Nothing to do with calling convention.
                  >
                  > The function main() is NOT a generic. It is the real name of your C
                  > program. It is called by the command shell and has a 'value' of type
                  > int. Not void, int! This was decided among Ken Thompson and Dennis
                  > Ritchie circa 1972, three years before Bill, 19 years old in 1975
                  > started Microsoft.
                  >
                  > K&R (1978), C89 and C99 all define main() with type int.[/color]

                  The reasons for making void functions and int functions de facto
                  compatible aren't related to main(), since main() has always returned
                  int. It has to do with other functions.

                  For example, in pre-ANSI C, a function that was not intended to return
                  a value might be have been written as:

                  do_something()
                  {
                  ...
                  }

                  The function implicitly returns int, but it doesn't execute a return
                  statement and the callers don't attempt to use the result.

                  In ANSI C, it might be written as:

                  void do_something(vo id)
                  {
                  ...
                  }

                  In the transition to ANSI C, many implementers presumably used
                  compatible calling sequences for these two cases to avoid breaking
                  existing code, or to allow pre-ANSI code to call ANSI code and vice
                  versa, or to allow C code to call assembly code, etc.

                  The fact that such implementations might make void main() compatible
                  with int main() is just a side effect (an unfortunate one, IMHO).

                  --
                  Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                  San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                  We must do something. This is something. Therefore, we must do this.

                  Comment

                  Working...