outline

A

Agent Mulder

I feel the need for an outline specifier to
facilitate java-style programming.
 
V

Victor Bazarov

Agent Mulder said:
I feel the need for an outline specifier to
facilitate java-style programming.

There is no need in the language to do anything to emulate
any other language. What problem, otherwise unsolvable,
will 'outline' solve? If you can answer this question, post
your suggestion, with the justification, to comp.std.c++.

Victor
 
A

Andrey Tarasevich

Agent said:
I feel the need for an outline specifier to
facilitate java-style programming.
...

Don't you think that C++ already suffered enough from "java-style
programming"? And that without even trying to facilitate it explicitly.
 
A

Agent Mulder

AM> I feel the need for an outline specifier to
AM> facilitate java-style programming.

VB> There is no need in the language to do anything to emulate
VB> any other language. What problem, otherwise unsolvable,
VB> will 'outline' solve? If you can answer this question, post
VB> your suggestion, with the justification, to comp.std.c++.

With java-style programming I mean that you
do away with the .cpp .h - pair of files. All
function definitions go directly in the class
declaration. The compiler honors this attempt
and generates very fast, yet big applications.
In order to slow my program down, I need some
functions to be expanded 'outline'


class Music
{
public:void init()
{
//1400 lines of initialization code (skipped)
for(;;); //this forces my compiler to *NOT* inline this function
}};


This leaves me with a warning message:
Warning W8027: Functions containing for are not expanded inline
I wave my hat and shout back "Never Mind!". But why not write
it like this:



class Music
{
public:eek:utline void init()
{
//1400 lines of initialization code (skipped)
}};


to make sure the compiler takes it out of the class
definition while leaving the structure of the class intact.

-X
 
P

Peter van Merkerk

Agent Mulder said:
I feel the need for an outline specifier to
facilitate java-style programming.

Many compilers allow you to disable inlining of functions completely.
There is a discussion going on in comp.lang.c++.moderated (turn off
inlining using extern "C") exactly about the same subject, you might
want to join in there. I doubt that facilitating java-style programming
will convince many, however.

Just to satisfy my curiosity (not intended as criticism); if you prefer
Java style programming, why you don't just use Java? I think one of the
most important problems of Java programmers struggling to learn C++, is
realizing that C++ is really a different programming language with
different semantics and idioms, even though much of the syntax may seem
quite familiar at first. Encouraging to make C++ look more like Java
doesn't really help in this respect in my opinion
 
A

Agent Mulder

VB>I don't want to continue this discussion.


Why not? I only want you to notice
that I posted my suggestion for
'outline' on July 29, 2003 and the
suggestion for !inline by Francis
Glassborrow is from July 31, 2003.
Today! Only 2 hours ago, the e-ink
has not yet dried...

-X

go expand a macro, or backtrace something...
 
K

Karl Heinz Buchegger

Agent said:
VB>I don't want to continue this discussion.

Why not?

I think Victor has the same feeling on this 'feature'
as I have:
It's pointless.
If I don't want a function to be inlined, well, then
simply don't write the function body in the class
decleration. Plain and simple. No special keyword
needed for that.
 
A

Agent Mulder

KHB> I think Victor has the same feeling on this 'feature'
KHB> as I have:
KHB> It's pointless.
KHB> If I don't want a function to be inlined, well, then
KHB> simply don't write the function body in the class
KHB> decleration. Plain and simple. No special keyword
KHB> needed for that.

Modern compilers and linkers are smart enough
that they will inline everything they see fit, defined
inside or out of the class body. You can't trust on
that.

-X
 
K

Karl Heinz Buchegger

Agent said:
KHB> I think Victor has the same feeling on this 'feature'
KHB> as I have:
KHB> It's pointless.
KHB> If I don't want a function to be inlined, well, then
KHB> simply don't write the function body in the class
KHB> decleration. Plain and simple. No special keyword
KHB> needed for that.

Modern compilers and linkers are smart enough
that they will inline everything they see fit, defined
inside or out of the class body. You can't trust on
that.

If the compiler deosn't see the source code,
it cannot inline it, simple.

But for the linker:
Do you know of any linker that does this?
I would be very surprised and make a deep bow
in front of the guys who managed to do that.
 
A

Agent Mulder

AM > I feel the need for an outline specifier [...]

KHB> If I don't want a function to be inlined, well, then
KHB> simply don't write the function body in the class
KHB> decleration. Plain and simple. No special keyword
KHB> needed for that.

AM> Modern compilers and linkers are smart enough
AM> that they will inline everything they see fit, defined
AM> inside or out of the class body.

KH> If the compiler deosn't see the source code,
KH> it cannot inline it, simple.
KH>
KH> But for the linker:
KH> Do you know of any linker that does this?
KH> I would be very surprised and make a deep bow
KH> in front of the guys who managed to do that.

I copied this reply from from the thread
Re: turn off inlining using extern "C", on
comp.lang.c++.moderated:

Heinz Ozwirk:
If you want to prevent functions from being inlined, put them in separate
.cpp (or whatever) files and only include their prototypes in the code
that calls them. The compiler cannot inline them, if it doesn't know what
to inline.

Francis GlassBorow:
Of course it can and good linkers have been managing that for some time.
In future it will become more common as forms of semi-compiled code
become more common. VC++7 has some quite clever features in this area.

//Agent Mulder again:
The conclusion in that thread is that there is no
portable way to ensure that code gets expanded
outline (not inline). It is viewed as a de-optimization
enforced by the programmer. Your hack of taking
the function body out of the class declaration does
not work. Fix it.

-X
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top