what is an escaping variable

Discussion in 'C++' started by C C++ C++, Nov 12, 2007.

  1. C C++ C++

    C C++ C++ Guest

    what is an escaping variable?
    C C++ C++, Nov 12, 2007
    #1
    1. Advertising

  2. C C++ C++ wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 12, 2007
    #2
    1. Advertising

  3. On Mon, 12 Nov 2007 15:46:43 -0000, C C++ C++ <m.azmath@...com> wrote:
    >what is an escaping variable?


    A variable that escapes a function?
    http://en.wikipedia.org/wiki/Escape_analysis
    BTW, scope bound resource management using RAII is a panacea for
    avoiding escaping variables.


    --
    Roland Pibinger
    "The best software is simple, elegant, and full of drama" - Grady Booch
    Roland Pibinger, Nov 12, 2007
    #3
  4. C C++ C++

    Kira Yamato Guest

    On 2007-11-12 16:56:49 -0500, (Roland Pibinger) said:

    > On Mon, 12 Nov 2007 15:46:43 -0000, C C++ C++ <m.azmath@...com> wrote:
    >> what is an escaping variable?

    >
    > A variable that escapes a function?
    > http://en.wikipedia.org/wiki/Escape_analysis
    > BTW, scope bound resource management using RAII is a panacea for
    > avoiding escaping variables.


    Can you give an example?

    --

    -kira
    Kira Yamato, Nov 12, 2007
    #4
  5. On Mon, 12 Nov 2007 17:01:35 -0500, Kira Yamato
    <> wrote:

    >On 2007-11-12 16:56:49 -0500, (Roland Pibinger) said:
    >
    >> On Mon, 12 Nov 2007 15:46:43 -0000, C C++ C++ <m.azmath@...com> wrote:
    >>> what is an escaping variable?

    >>
    >> A variable that escapes a function?
    >> http://en.wikipedia.org/wiki/Escape_analysis
    >> BTW, scope bound resource management using RAII is a panacea for
    >> avoiding escaping variables.

    >
    >Can you give an example?


    An example of 'escaping' variables or RAII?
    Roland Pibinger, Nov 12, 2007
    #5
  6. C C++ C++

    Kira Yamato Guest

    On 2007-11-12 17:53:53 -0500, (Roland Pibinger) said:

    > On Mon, 12 Nov 2007 17:01:35 -0500, Kira Yamato
    > <> wrote:
    >
    >> On 2007-11-12 16:56:49 -0500, (Roland Pibinger) said:
    >>
    >>> On Mon, 12 Nov 2007 15:46:43 -0000, C C++ C++ <m.azmath@...com> wrote:
    >>>> what is an escaping variable?
    >>>
    >>> A variable that escapes a function?
    >>> http://en.wikipedia.org/wiki/Escape_analysis
    >>> BTW, scope bound resource management using RAII is a panacea for
    >>> avoiding escaping variables.

    >>
    >> Can you give an example?

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

    --

    -kira
    Kira Yamato, Nov 12, 2007
    #6
  7. On Mon, 12 Nov 2007 18:09:28 -0500, Kira Yamato wrote:
    >On 2007-11-12 17:53:53 -0500, (Roland Pibinger) said:
    >> On Mon, 12 Nov 2007 Kira Yamato wrote:
    >>> Can you give an example?

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


    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.


    --
    Roland Pibinger
    "The best software is simple, elegant, and full of drama" - Grady Booch
    Roland Pibinger, Nov 13, 2007
    #7
  8. On Tue, 13 Nov 2007 00:02:21 GMT, Roland Pibinger wrote:

    >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.
    Roland Pibinger, Nov 13, 2007
    #8
  9. C C++ C++

    Ian Collins Guest

    Re: Rusty's message to C++ programmers (C or C++)

    Raz wrote:

    Please confine your trolling to where it belongs.

    --
    Ian Collins.
    Ian Collins, May 5, 2008
    #9
  10. Re: Rusty's message to C++ programmers (C or C++)

    Razii wrote:
    > On Mon, 05 May 2008 20:19:18 -0400, CBFalconer
    > <>
    > wrote:
    >
    >> Do you realize that you are posting to comp.lang.c, and that your
    >> posts are off-topic there? Simply delete c.l.c from the
    >> distribution.

    >
    > 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
    . I encourage the rest of you to join me.
    Mike Schilling, May 6, 2008
    #10
  11. C C++ C++

    Razi Guest

    Re: Rusty's message to C++ programmers (C or C++)

    On Mon, 5 May 2008 20:51:12 -0700, "Mike Schilling"
    <> wrote:

    >As suggested in your post's headers, I'm going to forward this to
    > . I encourage the rest of you to join me.


    And now I am using aioe.org .. their email is probably,
    , 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.
    Razi, May 6, 2008
    #11
  12. C C++ C++

    cr88192 Guest

    Re: Rusty's message to C++ programmers (C or C++)

    "Chris Thomasson" <> wrote in message
    news:...
    > "Raz" <> wrote in message
    > news:...
    >>
    >> 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...
    cr88192, May 6, 2008
    #12
  13. Re: Rusty's message to C++ programmers (C or C++)

    Razi wrote:
    > On Mon, 5 May 2008 20:51:12 -0700, "Mike Schilling"
    > <> wrote:
    >
    >> As suggested in your post's headers, I'm going to forward this to
    >> . I encourage the rest of you to join me.

    >
    > And now I am using aioe.org .. their email is probably,
    > , 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?
    Mike Schilling, May 6, 2008
    #13
  14. C C++ C++

    Ian Collins Guest

    Re: Rusty's message to C++ programmers (C or C++)

    Chris Thomasson wrote:
    > "cr88192" <> wrote in message
    > news:51475$481ff7ff$ca83b482$...
    >>
    >> "Chris Thomasson" <> wrote in message
    >> news:...
    >>> "Raz" <> wrote in message
    >>> news:...
    >>>>
    >>>> 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?

    --
    Ian Collins.
    Ian Collins, May 6, 2008
    #14
  15. Re: Rusty's message to C++ programmers (C or C++)

    Razii <> writes:
    > On Mon, 5 May 2008 23:37:03 -0700, "Mike Schilling"
    > <> wrote:
    >
    >>Why do you need to switch servers so often, if you're not a spammer?

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

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, May 6, 2008
    #15
  16. C C++ C++

    santosh Guest

    Re: Rusty's message to C++ programmers (C or C++)

    Keith Thompson wrote:

    > Razii <> writes:
    >> On Mon, 5 May 2008 23:37:03 -0700, "Mike Schilling"
    >> <> wrote:
    >>
    >>>Why do you need to switch servers so often, if you're not a spammer?

    >>
    >> 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.
    santosh, May 6, 2008
    #16
  17. C C++ C++

    dizzy Guest

    Re: Rusty's message to C++ programmers (C or C++)

    cr88192 wrote:

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

    --
    Dizzy
    dizzy, May 6, 2008
    #17
  18. C C++ C++

    Ian Collins Guest

    Re: Rusty's message to C++ programmers (C or C++)

    dizzy wrote:
    > cr88192 wrote:
    >
    >> 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.
    >

    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.

    --
    Ian Collins.
    Ian Collins, May 6, 2008
    #18
  19. C C++ C++

    Joe Greer Guest

    Re: Rusty's message to C++ programmers (C or C++)

    Ian Collins <> wrote in
    news::

    > dizzy wrote:
    >> cr88192 wrote:
    >>
    >>> 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.
    >>

    > 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
    Joe Greer, May 6, 2008
    #19
  20. C C++ C++

    Joe Greer Guest

    Re: Rusty's message to C++ programmers (C or C++)

    Ian Collins <> wrote in
    news::

    > 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
    Joe Greer, May 6, 2008
    #20
    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. Ben

    Escaping ' in Javascript ?

    Ben, Nov 7, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    9,250
    mikeb
    Nov 10, 2003
  2. Swanand Mokashi

    Re: Escaping a URL in XSL/T

    Swanand Mokashi, May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    526
    Swanand Mokashi
    May 13, 2004
  3. mfglinux
    Replies:
    11
    Views:
    684
    Roberto Bonvallet
    Sep 12, 2007
  4. Kamil Wasilewski

    Escaping variable names

    Kamil Wasilewski, Mar 5, 2010, in forum: Python
    Replies:
    0
    Views:
    213
    Kamil Wasilewski
    Mar 5, 2010
  5. David Filmer
    Replies:
    19
    Views:
    226
    Kevin Collins
    May 21, 2004
Loading...

Share This Page