Re: New C++ Tutorial

Discussion in 'C++' started by Pete Becker, Aug 16, 2003.

  1. Pete Becker

    Pete Becker Guest

    "Alf P. Steinbach" wrote:
    >
    > * You cannot put new things into namespace std, as you do with class
    > UnigramTextClassifier. The compiler may incorrectly allow it, but
    > that does not mean another compiler will.
    >


    The compiler correctly allows it. <g> The behavior of a program that
    adds names to std is undefined, so the standard does not require any
    particular behavior when that's done. In practice this isn't diagnosed,
    because compilers use ordinary files for their headers, and when you do
    that you can't easily tell whether it's the user or the implementation
    that's adding those names.

    So the advice is right: don't do that. Compilers may correctly reject
    it.

    --

    Pete Becker
    Dinkumware, Ltd. (http://www.dinkumware.com)
    Pete Becker, Aug 16, 2003
    #1
    1. Advertising

  2. On Sat, 16 Aug 2003 18:16:56 -0400, Pete Becker <> wrote:

    >"Alf P. Steinbach" wrote:
    >>
    >> * You cannot put new things into namespace std, as you do with class
    >> UnigramTextClassifier. The compiler may incorrectly allow it, but
    >> that does not mean another compiler will.
    >>

    >
    >The compiler correctly allows it. <g>


    I guess I earned that one... ;-)




    > The behavior of a program that
    >adds names to std is undefined, so the standard does not require any
    >particular behavior when that's done. In practice this isn't diagnosed,
    >because compilers use ordinary files for their headers, and when you do
    >that you can't easily tell whether it's the user or the implementation
    >that's adding those names.


    I can. Some (all?) compilers don't. Simplest way would be to have a
    boolean state reflecting the directory of the currently parsed code;
    more sophisticated, to have all standard headers precompiled into some
    kind of database; and so on.

    I think the real reason why there's no diagnostic is that it would add
    no real value to the compiler, while requiring some work to implement.



    >So the advice is right: don't do that. Compilers may correctly reject
    >it.
    Alf P. Steinbach, Aug 16, 2003
    #2
    1. Advertising

  3. Pete Becker

    Pete Becker Guest

    "Alf P. Steinbach" wrote:
    >
    > On Sat, 16 Aug 2003 18:16:56 -0400, Pete Becker <> wrote:
    >
    > > The behavior of a program that
    > >adds names to std is undefined, so the standard does not require any
    > >particular behavior when that's done. In practice this isn't diagnosed,
    > >because compilers use ordinary files for their headers, and when you do
    > >that you can't easily tell whether it's the user or the implementation
    > >that's adding those names.

    >
    > I can. Some (all?) compilers don't. Simplest way would be to have a
    > boolean state reflecting the directory of the currently parsed code;
    > more sophisticated, to have all standard headers precompiled into some
    > kind of database; and so on.


    But if anyone did that they'd get complaints that they were locking in
    their own standard headers.

    >
    > I think the real reason why there's no diagnostic is that it would add
    > no real value to the compiler, while requiring some work to implement.
    >


    Well, "some work" is in the eye of the beholder. It's far from trivial,
    and, as you say, it adds no real value.

    --

    Pete Becker
    Dinkumware, Ltd. (http://www.dinkumware.com)
    Pete Becker, Aug 17, 2003
    #3
  4. Pete Becker

    Pete Becker Guest

    "Alf P. Steinbach" wrote:
    >
    > Directory check would be easy to make configurable, and for any usable
    > compiler would have to be configurable anyway (otherwise the compiler's
    > headers would always have to be installed in the same place); for the
    > idea of precompiled standard headers, simply offer the precompilation
    > tool to the compiler user; and so on.
    >


    Yup. Not easy.

    --

    Pete Becker
    Dinkumware, Ltd. (http://www.dinkumware.com)
    Pete Becker, Aug 17, 2003
    #4
    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. Stylus Studio
    Replies:
    0
    Views:
    361
    Stylus Studio
    Jan 31, 2006
  2. Rensjuh
    Replies:
    7
    Views:
    963
    Mabden
    Sep 2, 2004
  3. W. Watson
    Replies:
    13
    Views:
    1,059
    W. Watson
    Sep 20, 2007
  4. Linuxmank
    Replies:
    36
    Views:
    1,488
    Linuxmank
    Aug 8, 2009
  5. Replies:
    2
    Views:
    448
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page