Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #15496

Re: Is this ok to do?

From jt@toerring.de (Jens Thoms Toerring)
Newsgroups comp.lang.c++
Subject Re: Is this ok to do?
Date 2012-04-20 17:00 +0000
Organization Freie Universitaet Berlin
Message-ID <9vdj14F6ajU1@mid.uni-berlin.de> (permalink)
References <9vb7llFfqbU1@mid.uni-berlin.de> <4f906f1c$0$6564$9b4e6d93@newsspool4.arcor-online.net> <9vbadiFfqbU2@mid.uni-berlin.de> <4f90ff92$0$2783$7b1e8fa0@news.nbl.fi>

Show all headers | View raw


Juha Nieminen <nospam@thanks.invalid> wrote:
> Jens Thoms Toerring <jt@toerring.de> wrote:
> >> Seek for "delete this", which is basically the same.
> > 
> >> E.g.
> >> http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.15
> > 
> > Thank you, that's reassuring, as far as I can see all the points
> > mentioned there seem to be satisfied.

>   Personally, I would still try to avoid that kind of situation and try
> to think of a better design. Even if it works, it makes understanding the
> inter-class dependencies and the program flow more complicated. When
> reading code, one doesn't expect that the underlying object pointed by
> 'this' will suddenly disappear. (Adding a comment saying so in each line
> where this (might) happen is only slightly alleviating the problem, and
> prone to be skipped.)

I agree, but in this case there are a lot of additional con-
straints (it's in a library that must also be usable from
Python via a wrapper and Python has no notion of const-ness
etc.) that I can't see any way to avoid that - the object
that basically commit suicide (in a some- what round-about
manner) is an "accessor" object for an internal object the
user of the library shouldn't have direct access to. And to
remove that interal object the accessor object must induce
it to vanish which in turn the deletes the accessor since it
then, of course, is invalid.
                               Best regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Is this ok to do? jt@toerring.de (Jens Thoms Toerring) - 2012-04-19 19:34 +0000
  Re: Is this ok to do? Marcel Müller <news.5.maazl@spamgourmet.com> - 2012-04-19 22:01 +0200
    Re: Is this ok to do? jt@toerring.de (Jens Thoms Toerring) - 2012-04-19 20:21 +0000
      Re: Is this ok to do? Juha Nieminen <nospam@thanks.invalid> - 2012-04-20 06:17 +0000
        Re: Is this ok to do? Marcel Müller <news.5.maazl@spamgourmet.com> - 2012-04-20 13:20 +0200
        Re: Is this ok to do? jt@toerring.de (Jens Thoms Toerring) - 2012-04-20 17:00 +0000

csiph-web