To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 21660
21659  |  21661
Subject: 
Re: Are there GOTO statements in NQC?
Newsgroups: 
lugnet.robotics
Date: 
Fri, 21 Nov 2003 00:39:22 GMT
Original-From: 
T. Alexander Popiel <popiel@wolfskeep.&StopSpammers&com>
Viewed: 
1191 times
  
In message:  <3FBD54CB.1080501@airmail.net>
             Steve Baker <sjbaker1@airmail.net> writes:
T. Alexander Popiel wrote:

This exact same argument can be applied to high-level languages
where you dynamically allocate memory or other resources that need
to be released before leaving the function.

Which is why we have C++.

*snicker*

I'm surprised you used C as one of your example languages, then.

Anyway, not all of us are so lucky as to be able to choose a language
where you can hide all your cleanup code like that.  As a personal issue,
I find such cleanup hiding hard to follow, too.

With memory constructors and destructors, quite complex resources can be
automatically and cleanly free'd up on exit from a function.

I've seen this bite people (not just me), too, particularly when there's
a subtle bug in the destructor and they can't find where it's getting
called.  I generally dislike complex programmer-specified logic getting
magically invoked at inobvious times.

Out of curiosity, is a destructor for an object supposed to be called
when the variable goes out of scope, or when the function that it's
allocated in ends?  This can be different if the variable is declared
in a nested block, instead of at the top of the function.  I think I've
seen both in C++ implementations...  The many ways this could have
significant effect on the result are left as an exercise to the reader.

- Alex



Message has 1 Reply:
  Re: Are there GOTO statements in NQC?
 
Don't know about C/C++, but IIRC in Java the garbage collector destroys objects not when they are out of scope, nor when their creator function exits. It destroys them when the object is no longer referenced by any threads. That is to say, if (...) (21 years ago, 21-Nov-03, to lugnet.robotics)

Message is in Reply To:
  Re: Are there GOTO statements in NQC?
 
(...) Which is why we have C++. With memory constructors and destructors, quite complex resources can be automatically and cleanly free'd up on exit from a function. ---...--- Steve Baker ---...--- HomeEmail: <sjbaker1@airmail.net> WorkEmail: (...) (21 years ago, 20-Nov-03, to lugnet.robotics)

19 Messages in This Thread:









Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR