Could this be done on every ISO/IEC 14882:2003 implementation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven T. Hatton

    Could this be done on every ISO/IEC 14882:2003 implementation?

    This was written for the gnu.g++.help list. It rather clearly spells out the
    most important feature of Java that I believe C++ lacks. I really don't
    believe the C++ Standard sepcifies enough for a generic mechanism to
    accomplish the comperable tasks demonstrated for Java below. I've already
    proposed on comp.std.c++ that the next version of the standard specify a
    similar functionality for a C++ implementation.

    I know it can be unpopular to compare Java to C++, but there are certain
    features of Java which C++ lacks, and which give the programmer significant
    leverage to exploit available libraries.

    I wrote the following bash for the sake of writing this [gnu.g++.help]
    response:

     #!/bin/bash

    function jarlist() {
        for j in ${CLASSPATH//:/' '}; do 
            echo $j;
        done 
    }

    function classlist() {
        for j in ${CLASSPATH//:/' '}; do
            jar -tf $j;
        done 
    }

    function jpgrep() {
        for j in ${CLASSPATH//:/' '}; do
            h="";
            h=$(jar -tf $j | grep .class$ | grep $1)
            for c in $h;do
                 echo $c;
            done
        done 
    }

    function jif() {
        for j in ${CLASSPATH//:/' '}; do
            h="";
            h=$(jar -tf $j | grep .class$ | grep $1)
            for c in $h;do
                test -n "$c" && echo $c && javap ${c%%.class}
            done
        done 
    }
    ############### ###### EOF ############### ############### #####

    If there is a Java class I wish to use in my code, I can put the code listed
    above in a file called ~/bin/jq. Source it:
    Fri Jun 04 11:45:51:> . jq

    If I know the class contains the substring 'System' I type:
    Fri Jun 04 11:45:51:> jpgrep System
    org/apache/xml/utils/SystemIDResolve r.class
    org/apache/xpath/functions/FuncSystemPrope rty.class
    org/apache/xmlrpc/SystemHandler.c lass
    org/apache/xindice/core/MetaSystemColle ction.class
    org/apache/xindice/core/SystemCollectio n.class

    If I want to see the interfaces for each of these, I enter:

    org/apache/xml/utils/SystemIDResolve r.class
    Compiled from "SystemIDResolv er.java"
    public class org.apache.xml. utils.SystemIDR esolver extends java.lang.Objec t{
        public org.apache.xml. utils.SystemIDR esolver();
        public static java.lang.Strin g getAbsoluteURI( java.lang.Strin g);
           throws javax/xml/transform/TransformerExce ption
        public static java.lang.Strin g
    getAbsoluteURIF romRelative(jav a.lang.String);
        public static java.lang.Strin g
    getAbsoluteURI( java.lang.Strin g,java.lang.Str ing);
           throws javax/xml/transform/TransformerExce ption
    }

    org/apache/xpath/functions/FuncSystemPrope rty.class
    Compiled from "FuncSystemProp erty.java"
    //...
    }

    org/apache/xmlrpc/SystemHandler.c lass
    Compiled from "SystemHandler. java"
    public class org.apache.xmlr pc.SystemHandle r extends java.lang.Objec t
    implements org.apache.xmlr pc.ContextXmlR
    //..
    execute(java.la ng.String,java. util.Vector,org .apache.xmlrpc. XmlRpcContext);
           throws java/lang/Exception
    }

    org/apache/xindice/core/MetaSystemColle ction.class
    Compiled from "MetaSystemColl ection.java"
    public final class org.apache.xind ice.core.MetaSy stemCollection extends
    //...

    Those results contain everything I need in order to have the class imported
    into my current file and to get a pop-up menu of accessible method
    invocations and fields, including a parameterlist.
    --
    STH
    Hatton's Law: "There is only One inviolable Law"
    KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
    Mozilla: http://www.mozilla.org
  • Victor Bazarov

    #2
    Re: Could this be done on every ISO/IEC 14882:2003 implementation?

    Steven T. Hatton wrote:[color=blue]
    > This was written for the gnu.g++.help list. It rather clearly spells out [..][/color]

    I must be riding my stupid horse today. Could you for my benefit
    clearly spell out what is it you're proposing C++ has? I cannot
    figure it out from the non-C++ code you posted. Thanks.

    V

    Comment

    • Pete Becker

      #3
      Re: Could this be done on every ISO/IEC 14882:2003 implementation?

      Victor Bazarov wrote:[color=blue]
      >
      > Steven T. Hatton wrote:[color=green]
      > > This was written for the gnu.g++.help list. It rather clearly spells out [..][/color]
      >
      > I must be riding my stupid horse today.[/color]

      Nope. I couldn't figure it out, either. A sentence or two describing
      what's desired would be helpful.

      --

      Pete Becker
      Dinkumware, Ltd. (http://www.dinkumware.com)

      Comment

      • David Harmon

        #4
        Re: Could this be done on every ISO/IEC 14882:2003 implementation?

        On Fri, 04 Jun 2004 12:41:08 -0400 in comp.lang.c++, Pete Becker
        <petebecker@acm .org> wrote,[color=blue]
        >Victor Bazarov wrote:[color=green]
        >>
        >> Steven T. Hatton wrote:[color=darkred]
        >> > This was written for the gnu.g++.help list. It rather clearly spells out [..][/color]
        >>
        >> I must be riding my stupid horse today.[/color]
        >
        >Nope. I couldn't figure it out, either. A sentence or two describing
        >what's desired would be helpful.[/color]

        He wants to generate library user documentation from the object code.

        Comment

        • Steven T. Hatton

          #5
          Re: Could this be done on every ISO/IEC 14882:2003 implementation?

          Victor Bazarov wrote:
          [color=blue]
          > Steven T. Hatton wrote:[color=green]
          >> This was written for the gnu.g++.help list. It rather clearly spells out
          >> [..][/color]
          >
          > I must be riding my stupid horse today. Could you for my benefit
          > clearly spell out what is it you're proposing C++ has? I cannot
          > figure it out from the non-C++ code you posted. Thanks.
          >
          > V[/color]

          The bash code was presented to show the implementation of the commands
          demonstratedin the following

          <original>
          If there is a Java class I wish to use in my code, I can put the code listed
          above in a file called ~/bin/jq. Source it:
          Fri Jun 04 11:45:51:> . jq
          </original>

          Substitute Java class with C++ class, template, and, since C++ supports
          namespace local functions, they too can be considered, as can variables and
          constants which are namespace local.

          Sourcing a file is a way to introduce symbols and associated values into the
          current environment.

          <original>
          If I know the class contains the substring 'System' I type:
          Fri Jun 04 11:45:51:> jpgrep System
          org/apache/xml/utils/SystemIDResolve r.class
          org/apache/xpath/functions/FuncSystemPrope rty.class
          org/apache/xmlrpc/SystemHandler.c lass
          org/apache/xindice/core/MetaSystemColle ction.class
          org/apache/xindice/core/SystemCollectio n.class
          </original>

          I should have written 'class name containst a substring'. Class names in
          Java are used in a virtually identical way as they are in C++, with the
          exception that there are some requirements that the file containing the
          source for most classes have a base name identical to that of the
          classname. The part before the basename of the class is the package name
          expressed using '/' as a separator. Within the body of the source the
          following:

          org/apache/xml/utils/SystemIDResolve r.class

          could be written as:

          org.apache.xml. utils.SystemIDR esolver

          A package is vaugly comperable to a namespace in C++. So the C++
          counterpart to the fully qualified class name above would be something
          like:

          org::apache::xm l::utils::Syste mIDResolver

          There is a mechanism similar to the #include mechanism of the C++
          preprocessor which enables me to write:

          import org.apache.xml. utils.SystemIDR esolver;

          in a way comperable to a combination of:

          #includ <systemid.h>

          and

          using org::apache::xm l::utils::Syste mIDResolver;

          in C++.

          Since Java's file naming rules require the class to appear in a file with
          the same qualified name (relative to some parent directory name) as the
          classname, the import serves the same purpose as both the C++ using
          declaration, and the #import directive. Java classes are usually contained
          in compressed file called jar (Java archive) files, and have a .jar
          extension. Therefore org/apache/xml/utils/SystemIDResolve r.class is the
          name of the file relative to the virtual root of the jar file.

          <original>
          If I want to see the interfaces for each of these, I enter:
          </original>

          The concept of interface I intended is that explained in TC++PL(SE). Using
          the above explanations, substitute the appropriate symbols to convert the
          following output to it's C++ counterpart. For example:

          <original>

          org/apache/xml/utils/SystemIDResolve r.class
          Compiled from "SystemIDResolv er.java"
          public class org.apache.xml. utils.SystemIDR esolver extends java.lang.Objec t{
              public org.apache.xml. utils.SystemIDR esolver();
              public static java.lang.Strin g getAbsoluteURI( java.lang.Strin g);
                 throws javax/xml/transform/TransformerExce ption
              public static java.lang.Strin g
          getAbsoluteURIF romRelative(jav a.lang.String);
              public static java.lang.Strin g
          getAbsoluteURI( java.lang.Strin g,java.lang.Str ing);
                 throws javax/xml/transform/TransformerExce ption
          }

          </original>

          would convert to:

          #include <SystemIDResolv er.h>

          using org::apache::xm l::utils::Syste mIDResolver::cl ass

          class org::apache::xm l::utils::Syste mIDResolver extends java::lang::Obj ect{
          public:
          org::apache::xm l::utils::Syste mIDResolver();
          static java::lang::Str ing getAbsoluteURI( java::lang::Str ing)
          throw (javax::xml::tr ansform::Transf ormerException) ;
          static java::lang::Str ing getAbsoluteURIF romRelative(jav a::lang::String );
          static java::lang::Str ing
          getAbsoluteURI( java::lang::Str ing,java::lang: :String)
          throw (javax::xml::tr ansform::Transf ormerException) ;
          }


          Those results contain everything I need in order to have the class imported
          into my current file and to get a pop-up menu of accessible method
          invocations and fields, including a parameterlist.
          --
          STH
          Hatton's Law: "There is only One inviolable Law"
          KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
          Mozilla: http://www.mozilla.org

          Comment

          • Steven T. Hatton

            #6
            Re: Could this be done on every ISO/IEC 14882:2003 implementation?

            David Harmon wrote:
            [color=blue]
            > On Fri, 04 Jun 2004 12:41:08 -0400 in comp.lang.c++, Pete Becker
            > <petebecker@acm .org> wrote,[color=green]
            >>Victor Bazarov wrote:[color=darkred]
            >>>
            >>> Steven T. Hatton wrote:
            >>> > This was written for the gnu.g++.help list. It rather clearly spells
            >>> > out [..]
            >>>
            >>> I must be riding my stupid horse today.[/color]
            >>
            >>Nope. I couldn't figure it out, either. A sentence or two describing
            >>what's desired would be helpful.[/color]
            >
            > He wants to generate library user documentation from the object code.[/color]

            Actually, that's not quite what I want, but close. First off, if I just had
            the freakin' headers formatted to reflect the interface (what a concept),
            that would be a huge part of the battle. The following is quite common in
            C++ headers. It is the <vector> header from gnu. Yes, in this rare
            instance I am saying nasty things about gnu.


            /** @file vector
            * This is a Standard C++ Library header. You should @c #include this
            header
            * in your programs, rather than any of the "st[dl]_*.h" implementation
            files.
            */

            #ifndef _CPP_VECTOR
            #define _CPP_VECTOR 1

            #pragma GCC system_header

            #include <bits/functexcept.h>
            #include <bits/stl_algobase.h>
            #include <bits/stl_alloc.h>
            #include <bits/stl_construct.h >
            #include <bits/stl_uninitializ ed.h>
            #include <bits/stl_vector.h>
            #include <bits/stl_bvector.h>

            #ifdef _GLIBCPP_NO_TEM PLATE_EXPORT
            # include <bits/vector.tcc>
            #endif

            #endif /* _CPP_VECTOR */


            There is a tool, freely available, which creates very nice C++ api
            documentation. http://www.doxygen.org

            In a typical Java IDE it is very easy to add libraries, and to have the IDE
            query them to find all the symbols available, or potentially available to
            the current scope. This means the IDE can do a great deal of the drudge
            work of locating symbols within the available libraries, and providing the
            necessary code in order to use the symbol. It also makes it possible for
            the IDE to verify the code contains valid identifiers, and can mark invalid
            code wish some kind of error indicator. The power of such tools is hard to
            fully communicate without the audience having experience using them.
            --
            STH
            Hatton's Law: "There is only One inviolable Law"
            KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
            Mozilla: http://www.mozilla.org

            Comment

            • Petec

              #7
              Re: Could this be done on every ISO/IEC 14882:2003 implementation?

              Steven T. Hatton wrote:
              <snip>[color=blue]
              >
              > In a typical Java IDE it is very easy to add libraries, and to have
              > the IDE query them to find all the symbols available, or potentially
              > available to the current scope. This means the IDE can do a great
              > deal of the drudge work of locating symbols within the available
              > libraries, and providing the necessary code in order to use the
              > symbol. It also makes it possible for the IDE to verify the code
              > contains valid identifiers, and can mark invalid code wish some kind
              > of error indicator. The power of such tools is hard to fully
              > communicate without the audience having experience using them.[/color]

              That's what header files are for. VC++ 2003 has a nice "Class View" pane and
              Intellisense that does what you want, I believe. It does not immediatly mark
              invalid identifiers, but that's easily told by either compiler diagnostics
              or hovering the pointer over the identifier.

              - Pete


              Comment

              • Steven T. Hatton

                #8
                Re: Could this be done on every ISO/IEC 14882:2003 implementation?

                Petec wrote:
                [color=blue]
                > Steven T. Hatton wrote:
                > <snip>[color=green]
                >> It also makes it possible for the IDE to verify the code
                >> contains valid identifiers, and can mark invalid code wish some kind
                >> of error indicator. The power of such tools is hard to fully
                >> communicate without the audience having experience using them.[/color]
                >
                > That's what header files are for.[/color]

                Or so the standard literature would have us believe. The problem I'm seeing
                from the Linux end of things is the practice, on the part of the GCC team,
                of using macro magic to use the same set of headers, unaltered, for all
                platforms. It would be fine if in addition they provided a means to
                extract the 'correct' form of the headers. But this is is a better topic
                for the GCC list.
                [color=blue]
                > VC++ 2003 has a nice "Class View" pane
                > and Intellisense that does what you want, I believe. It does not
                > immediatly mark invalid identifiers, but that's easily told by either
                > compiler diagnostics or hovering the pointer over the identifier.[/color]

                I know there is, and has been for many years, some level of this kind of
                support in both Borland and Microsoft's IDEs. (And if you stand on your
                head and play a guitar with your toes, you can get it to work with Emacs.)
                I'd have to see what VC++ is doing in order to determine if it's the same
                kind of thing I'm seeking. I have VC++ 6.0, but I have not been inclined to
                spend much time booted into Chi-Rho.
                Here's an incomplete list of functionality I'm thinking of.

                Will the IDE add the required headers and using declarations to your source
                automatically?

                Will it give an indication of the exceptions thrown by a function call?

                Will it display all the overloaded function signture with an indication of
                the type of parameter it takes?

                Does it filter according to context? That is, does it only show the
                identifiers visible in the current scope when it provides code completion
                (unless you ask for more)?

                When it shows error indicators in the edit buffer, is that a result of
                compiler output, or is the code evaluated as you input it?

                Can you add virtually any SDK such as the Xerces C++ to the available
                resources and have the code completion and checking work at the same level
                as it does for the Standard Libraray and the implementation' s API(s)?

                If the answer to all the above is yes, then they are doing much of what I
                would like to see in an IDE. I don't want to go too deeply into the
                details of any particular IDE on this news group. My purpose is to
                understand what limitations, if any, exist to prevent the functionality
                from being implemented for C++.

                I'm sure it can be done for limited proprietary configurations, but I'm
                looking for something that is generally portable, and applicable to all
                (development) libraries. It should be a default feature of normal
                operation, not requiring any significant effort on the part of the user.

                With Java, the way the class files are designed makes the counterpart of
                what is found in C++ header files available with all distributions of a
                program. I am pretty sure that is not the case with C++. I don't know if
                it's even desirable. But a uniform standard specifying how development
                libraries can support this kind of functionality would be nice.

                My experience with Java verses C++ using such resources as the Xerces C++
                code base, KDevelop, Qt, KDE, etc., is that the C++ setup is usually
                harder. The separation of compiled output from the headers leads to more
                problems as does the way libraries and include files are typically located.
                By the compiler and runtime environments.

                Something tells me the big players will resist any kind of standardization
                of library mechanism for C++. I could be wrong, but, one or two particular
                companies might try to retain what they perceive as an advantage by
                maintaining incompatability between platforms.

                --
                STH
                Hatton's Law: "There is only One inviolable Law"
                KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
                Mozilla: http://www.mozilla.org

                Comment

                • Victor Bazarov

                  #9
                  Re: Could this be done on every ISO/IEC 14882:2003 implementation?

                  Steven T. Hatton wrote:[color=blue]
                  > [...]
                  > Here's an incomplete list of functionality I'm thinking of.
                  > [...][/color]

                  You're thinking of adding training wheels and tooltips onto a military
                  aircraft. I think you're missing the point of having the complexity
                  and flexibility of C++ in the first place. If you need Java or Pascal,
                  you should keep using Java or Pascal. Those are the Jumbo Jet and the
                  Cessna of the programming world. Please step off the ladder to the F-18
                  cockpit, it's dangerous, you can fall off and hurt your head.

                  Some things you wrote about are available. Some things are too damn
                  restrictive to be useful. Only paranoid and weak mind can consider that
                  somebody might be interested in "maintainin g incompatibility ". That
                  "incompatibilit y between platforms" is simply the side effect of trying
                  to keep things real, backwards compatible, and efficient (all that at the
                  same time).

                  Comment

                  • Steven T. Hatton

                    #10
                    Re: Could this be done on every ISO/IEC 14882:2003 implementation?

                    Victor Bazarov wrote:
                    [color=blue]
                    > Steven T. Hatton wrote:[color=green]
                    >> [...]
                    >> Here's an incomplete list of functionality I'm thinking of.
                    >> [...][/color]
                    >
                    > You're thinking of adding training wheels and tooltips onto a military
                    > aircraft.[/color]

                    How many years of professional experience do you have with high tech
                    military equipment? How many custom designed systems have you built for use
                    by the Joint Chiefs? MarForPac? Joint forces commanders? I suspect you
                    really don't understand the importance of being able to gain information
                    quickely and efficiently in a combat situation.
                    [color=blue]
                    > I think you're missing the point of having the complexity
                    > and flexibility of C++ in the first place.[/color]

                    Some of the complexity in C++ adds nothing but inconvenience.
                    [color=blue]
                    > If you need Java or Pascal,
                    > you should keep using Java or Pascal. Those are the Jumbo Jet and the
                    > Cessna of the programming world. Please step off the ladder to the F-18
                    > cockpit, it's dangerous, you can fall off and hurt your head.[/color]

                    Have you every worked with a system that generates 36000 volts? I mean
                    reaching in the cabinet where that potential is generated, and replacing
                    the components that generate the voltage. Have you ever taken one of these
                    on a camping trip?


                    [color=blue]
                    > Some things you wrote about are available. Some things are too damn
                    > restrictive to be useful. Only paranoid and weak mind can consider that
                    > somebody might be interested in "maintainin g incompatibility ".[/color]

                    Is that why Microsoft settled with sun Microsystems for a measly
                    $1,600,000,000 US?
                    [color=blue]
                    > That
                    > "incompatibilit y between platforms" is simply the side effect of trying
                    > to keep things real, backwards compatible, and efficient (all that at the
                    > same time).[/color]

                    I started working with Netscape SuiteSpot 1.0 when it was in early Beta. You
                    proabably don't appreciate the signifigance of that statement. But trust
                    me, there is irony here.

                    --
                    STH
                    Hatton's Law: "There is only One inviolable Law"
                    KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
                    Mozilla: http://www.mozilla.org

                    Comment

                    Working...