Rooting around in the Forum: destructors

Mark Schonewille m.schonewille at economy-x-talk.com
Sat Jun 3 14:40:59 EDT 2017


Short answer: LiveCode doesn't have destructors because the xTalk family 
of languages doesn't require them. xTalk languages make the life of the 
developer easier by taking such tasks our of their hands.

1a) Yes, under the hood, because LiveCode is written using variants of 
C, which are object oriented. So, LiveCode is creating and deleting 
(destructing) objects continuously, but the LiveCode developer/user 
doesn't need to be bothered with that.

1b) You could make sure to write clean scripts that always delete 
controls (and even cards and stacks) and variables that are no longer 
needed. LiveCode does a good job cleaning up after finishing a handler, 
so it isn't really necessary to do this yourself, but if you are 
creating controls that you need only one time, it is probably a good 
idea to delete them afterwards. When you delete a control, an object 
under the hood is no longer required and will be "destroyed" at some point.

2) It is in the object-oriented language that is used to create 
LiveCode. There is also a delete command in the LiveCode scripting 
language. The delete command isn't a destructor, but it does provide a 
form a cleaning up.

3) Most of the cleaning up is done automatically. Local variables that 
are used by one handler only, are deleted automatically. Moreover, the 
LiveCode scripting language isn't an object-oriented language, even 
though some people may try to make you believe otherwise and some other 
people wish it were. Really, it isn't. Because the language isn't 
object-oriented, it doesn't need a destructor.


Kind regards,

Mark Schonewille
http://economy-x-talk.com
https://www.facebook.com/marksch

Buy the most extensive book on the
LiveCode language:
http://livecodebeginner.economy-x-talk.com

Op 03-Jun-17 om 18:46 schreef Richmond Mathewson via use-livecode:
> http://forums.livecode.com/viewtopic.php?f=8&t=29319
>
> Not having looked at any sort of "serious" programming language since
> about 1989 (I don't think that VB 6 is a serious language),
> I find it hard to understand what a destructor is beyond a way to free
> memory on a system that has constraints in that area.
>
> HOWEVER: as there is no thing in Livecode having "destrucor" written all
> over it in big letters for slow characters
> like myself could some one tell me:
>
> 1. Does Livecode have something(s) that does the job of a destructor?
>
> 2. If so, where is it and so on?
>
> 3. If not, why not?
>
> Richmond.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list