what is an escaping variable

V

Victor Bazarov

C said:
what is an escaping variable?

A variable the control over whom you're losing?

I don't know of "escaping variable", but there is "escape sequence"
in formatted output...

V
 
K

Kira Yamato

An example of 'escaping' variables or RAII?

Escaping variable. I just want to see what that code would like.

And perhaps if someone has time, show me what this RAII is and how it
avoids escape variables. But I sense that would be asking for too much.
 
R

Roland Pibinger

Escaping variable. I just want to see what that code would like.

And perhaps if someone has time, show me what this RAII is and how it
avoids escape variables. But I sense that would be asking for too much.

From Wikipedia:
"If a subroutine allocates an object and returns a pointer to it, the
object can be accessed from undetermined places in the program — the
pointer has 'escaped'."

MyClass* foo() {
return new MyClass;
}

Escaping has 2 consequences in C++
1. The caller must clean-up (delete) the resource which is impractical
for larger applications.
2. The caller becomes (probably) dependent on MyClass an all types
MyClass depends on (and so forth).

RAII is described here: http://en.wikipedia.org/wiki/RAII .
When you make the desctuctor of the managing object private (as shown
in the RAII example) the managed objects cannot escape from the
enclosing scope.
 
R

Roland Pibinger

When you make the desctuctor of the managing object private (as shown
in the RAII example) the managed objects cannot escape from the
enclosing scope.

Should have been: "When you make the copy constructor of the managing
object private ...". Sorry.
 
M

Mike Schilling

Razii said:
From now on, all my posts would bee cross posted to comp.lang.c.
What
are you going to do about it?

As suggested in your post's headers, I'm going to forward this to
(e-mail address removed) . I encourage the rest of you to join me.
 
R

Razi

As suggested in your post's headers, I'm going to forward this to
(e-mail address removed) . I encourage the rest of you to join me.

And now I am using aioe.org .. their email is probably,
(e-mail address removed) , in case you need help.

I can continue with next server in the next post if you want me to,
for at least two dozen servers continuously. After that, there is all
too reliable google.

Good luck in your email adventure anyway. There is nothing abusive
about posting benchmarks related to Java, C and C++ on a USENET
newsgroup.
 
C

cr88192

Chris Thomasson said:
Raz said:
On Wed, 30 Apr 2008 21:54:37 GMT, Erik Wikströ


As I said, I will find the link again. His knowledge of C++ is just
fine.

http://www.builderau.com.au/video/soa/Rusty-s-message-to-C-programmers/0,2000064338,22432924p,00.htm

http://www.builderau.com.au/video/soa/Why-C-remains-relevant/0,2000064338,22432921p,00.htm

So here is an expert of who believes that you don't need C++ to
program low level. C++ brings extra complexity that is not needed.

[...]

You are not forced to use "all" the features of C++. One could most
certainly use C++ in a kernel. However, I personally would avoid
exceptions and global ctor/dtors like the plague. I also would not use the
STL, oh well...

one has to give up many of the features, and is still faced with many of the
other technical issues, that IMO one is better off just using C...
 
M

Mike Schilling

Razi said:
And now I am using aioe.org .. their email is probably,
(e-mail address removed) , in case you need help.

I can continue with next server in the next post if you want me to,
for at least two dozen servers continuously. After that, there is
all
too reliable google.

Why do you need to switch servers so often, if you're not a spammer?
 
I

Ian Collins

Chris said:
cr88192 said:
Chris Thomasson said:
On Wed, 30 Apr 2008 21:54:37 GMT, Erik Wikströ

Obviously his knowledge of C++ is not as good as it should be.

As I said, I will find the link again. His knowledge of C++ is just
fine.

http://www.builderau.com.au/video/soa/Rusty-s-message-to-C-programmers/0,2000064338,22432924p,00.htm


http://www.builderau.com.au/video/soa/Why-C-remains-relevant/0,2000064338,22432921p,00.htm


So here is an expert of who believes that you don't need C++ to
program low level. C++ brings extra complexity that is not needed.

[...]

You are not forced to use "all" the features of C++. One could most
certainly use C++ in a kernel. However, I personally would avoid
exceptions and global ctor/dtors like the plague. I also would not
use the STL, oh well...

one has to give up many of the features, and is still faced with many
of the other technical issues, that IMO one is better off just using C...

Use all POD's, no ctor/dtor/"AUTO-vtable":
Why omit constructors and destructors?
 
K

Keith Thompson

Razii said:
I switched servers to make a point.
[snip]

Ok, you've made your point. You can post anything you like to
unmoderated newsgroups, and nobody can stop you.

We already knew that.
 
S

santosh

Keith said:
Razii said:
I switched servers to make a point.
[snip]

Ok, you've made your point. You can post anything you like to
unmoderated newsgroups, and nobody can stop you.

We already knew that.

Well, the news servers *can* stop him. A tiny little filter is all that
it takes, to be updated whenever he switches identity. But frankly,
end-user killfilling is better for small-time annoyances like him.
 
D

dizzy

cr88192 said:
one has to give up many of the features, and is still faced with many of
the other technical issues, that IMO one is better off just using C...

I completely agree. Once you start dropping features from C++ (templates,
exceptions, RAII, references, function and operator overloading) then you
get an incomplete language, some sort of "C with classes" (the horror!) so
you should better use C then.

I feel so lucky that I don't have to drop any C++ feature...
 
I

Ian Collins

dizzy said:
I completely agree. Once you start dropping features from C++ (templates,
exceptions, RAII, references, function and operator overloading) then you
get an incomplete language, some sort of "C with classes" (the horror!) so
you should better use C then.
Why would you have to drop templates, RAII, references, function and
operator overloading in driver code? Exceptions typically require some
form of run time support, but none of the other language features you
mention do.
 
J

Joe Greer

Why would you have to drop templates, RAII, references, function and
operator overloading in driver code? Exceptions typically require
some form of run time support, but none of the other language features
you mention do.

I don't know that you would have to drop them as a matter of course,
because you can actually get better performance with templates than
without. The problem comes when you want secure code. Templates have this
problem with doing different things depending upon the arguments and
parameters they are instantiated with. This makes them hard to reason
about and know exactly what is going to be generated. In secure contexts
this is enough of a problem that they are often banned entirely. I would
be interested in hearing if there are other arguments against templates.
Personally, I would think that your more algarithmic templates would be ok,
but as soon as you start doing metaprogramming with specializations etc,
then I would be more hesitant.

joe
 
J

Joe Greer

Why omit constructors and destructors?

I would be interested in the answer to this myself. I know that in real
time systems they don't want the somewhat uncontrolled flurry of activity
that usually accompanies a method exit, however most OS's aren't real time
and I wouldn't think that it would matter in the main. Of course, you
can't really have dynamically allocated objects. You end up with a chicken
an egg problem there. That is, you can't use the memory subsystem to
implement the memory subsystem and all that. However, I personally create
a whole lot more stack objects than heap objects and that wouldn't be a
reason to ban objects entirely.


joe
 

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

No members online now.

Forum statistics

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

Latest Threads

Top