By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,184 Members | 1,429 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,184 IT Pros & Developers. It's quick & easy.

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

P: n/a
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/SystemIDResolver.class
org/apache/xpath/functions/FuncSystemProperty.class
org/apache/xmlrpc/SystemHandler.class
org/apache/xindice/core/MetaSystemCollection.class
org/apache/xindice/core/SystemCollection.class

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

org/apache/xml/utils/SystemIDResolver.class
Compiled from "SystemIDResolver.java"
public class org.apache.xml.utils.SystemIDResolver extends java.lang.Object{
****public*org.apache.xml.utils.SystemIDResolver() ;
****public*static*java.lang.String*getAbsoluteURI( java.lang.String);
*******throws*javax/xml/transform/TransformerException
****public*static*java.lang.String
getAbsoluteURIFromRelative(java.lang.String);
****public*static*java.lang.String
getAbsoluteURI(java.lang.String,java.lang.String);
*******throws*javax/xml/transform/TransformerException
}

org/apache/xpath/functions/FuncSystemProperty.class
Compiled from "FuncSystemProperty.java"
//...
}

org/apache/xmlrpc/SystemHandler.class
Compiled from "SystemHandler.java"
public class org.apache.xmlrpc.SystemHandler extends java.lang.Object
implements org.apache.xmlrpc.ContextXmlR
//..
execute(java.lang.String,java.util.Vector,org.apac he.xmlrpc.XmlRpcContext);
*******throws*java/lang/Exception
}

org/apache/xindice/core/MetaSystemCollection.class
Compiled from "MetaSystemCollection.java"
public final class org.apache.xindice.core.MetaSystemCollection 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
Jul 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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. 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
Jul 22 '05 #2

P: n/a
Victor Bazarov wrote:

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.


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)
Jul 22 '05 #3

P: n/a
On Fri, 04 Jun 2004 12:41:08 -0400 in comp.lang.c++, Pete Becker
<pe********@acm.org> wrote,
Victor Bazarov wrote:

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.


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


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

Jul 22 '05 #4

P: n/a
Victor Bazarov wrote:
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. 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


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/SystemIDResolver.class
org/apache/xpath/functions/FuncSystemProperty.class
org/apache/xmlrpc/SystemHandler.class
org/apache/xindice/core/MetaSystemCollection.class
org/apache/xindice/core/SystemCollection.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/SystemIDResolver.class

could be written as:

org.apache.xml.utils.SystemIDResolver

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::xml::utils::SystemIDResolver

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

import org.apache.xml.utils.SystemIDResolver;

in a way comperable to a combination of:

#includ <systemid.h>

and

using org::apache::xml::utils::SystemIDResolver;

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/SystemIDResolver.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/SystemIDResolver.class
Compiled from "SystemIDResolver.java"
public class org.apache.xml.utils.SystemIDResolver extends java.lang.Object{
****public*org.apache.xml.utils.SystemIDResolver() ;
****public*static*java.lang.String*getAbsoluteURI( java.lang.String);
*******throws*javax/xml/transform/TransformerException
****public*static*java.lang.String
getAbsoluteURIFromRelative(java.lang.String);
****public*static*java.lang.String
getAbsoluteURI(java.lang.String,java.lang.String);
*******throws*javax/xml/transform/TransformerException
}

</original>

would convert to:

#include <SystemIDResolver.h>

using org::apache::xml::utils::SystemIDResolver::class

class org::apache::xml::utils::SystemIDResolver extends java::lang::Object{
public:
org::apache::xml::utils::SystemIDResolver();
static java::lang::String getAbsoluteURI(java::lang::String)
throw (javax::xml::transform::TransformerException);
static java::lang::String getAbsoluteURIFromRelative(java::lang::String);
static java::lang::String
getAbsoluteURI(java::lang::String,java::lang::Stri ng)
throw (javax::xml::transform::TransformerException);
}
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
Jul 22 '05 #5

P: n/a
David Harmon wrote:
On Fri, 04 Jun 2004 12:41:08 -0400 in comp.lang.c++, Pete Becker
<pe********@acm.org> wrote,
Victor Bazarov wrote:

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.


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


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


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_uninitialized.h>
#include <bits/stl_vector.h>
#include <bits/stl_bvector.h>

#ifdef _GLIBCPP_NO_TEMPLATE_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
Jul 22 '05 #6

P: n/a
Steven T. Hatton wrote:
<snip>

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.


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
Jul 22 '05 #7

P: n/a
Petec wrote:
Steven T. Hatton wrote:
<snip>
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.
That's what header files are for.


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.
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.


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
Jul 22 '05 #8

P: n/a
Steven T. Hatton wrote:
[...]
Here's an incomplete list of functionality I'm thinking of.
[...]


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 "maintaining incompatibility". That
"incompatibility between platforms" is simply the side effect of trying
to keep things real, backwards compatible, and efficient (all that at the
same time).
Jul 22 '05 #9

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


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.
I think you're missing the point of having the complexity
and flexibility of C++ in the first place.
Some of the complexity in C++ adds nothing but inconvenience.
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.
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?

http://area51specialprojects.com/ima...k/Launcher.jpg
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 "maintaining incompatibility".
Is that why Microsoft settled with sun Microsystems for a measly
$1,600,000,000 US?
That
"incompatibility between platforms" is simply the side effect of trying
to keep things real, backwards compatible, and efficient (all that at the
same time).


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
Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.