Code segment unload: Difference between revisions

m
syntax highlighting fixup automation
m (omit from assembly)
m (syntax highlighting fixup automation)
Line 8:
=={{header|BASIC}}==
Some versions of basic have the facility to delete lines of code:
<langsyntaxhighlight lang="gwbasic">10 GOSUB 5000: REM call initializer
20 DELETE 5000-9999: REM delete initializer
30 PRINT A: REM show initializer worked
Line 16:
5000 REM this is a dummy initializer
5010 LET A=1
5020 RETURN</langsyntaxhighlight>
 
=={{header|COBOL}}==
The <code>CANCEL</code> statement in COBOL unloads from memory the dynamically-loadable module containing the specified program or entry-point.
<langsyntaxhighlight lang="cobol">CANCEL "foo"</langsyntaxhighlight>
 
=={{header|Furor}}==
The <code>neglect</code> statement in Furor deletes from memory the named function. It is possible because each function is loaded into a dinamycally allocated memory segment.
<syntaxhighlight lang ="Furor">foo neglect</langsyntaxhighlight>
 
=={{header|Go}}==
Line 32:
 
=={{header|Io}}==
<langsyntaxhighlight lang="Io"># Call anonymous block to do the initialization.
 
block(
Line 42:
 
writeln("Doing real work.")
// Code to do the real work here.</langsyntaxhighlight>
 
{{output}}
Line 113:
;Releasing commands
:The memory associated with a particular command can be released back to the general memory pool by deleting the command. This is done by either creating a new command with the same name, or by using <code>rename</code> to change the command's name to the empty string.
:<langsyntaxhighlight lang="tcl">rename exampleCmd ""</langsyntaxhighlight>
;Releasing loaded extensions
:The memory associated with a loaded extension can be released by using <code>unload</code>, provided the extension has registered a handler function (this is relatively uncommon). Once the handler function has run (which gives the extension an opportunity to destroy any commands and other callbacks it has created), the underlying library will be removed from memory with <code>dlclose()</code> (on Unix) or <code>FreeLibrary()</code> (on Windows). This ''completely'' removes the program code concerned, as well as returning the other ancillary memory to the general pool.
:<syntaxhighlight lang ="tcl">unload theLibrary.dll</langsyntaxhighlight>
;Releasing an entire interpreter
:Provided an interpreter is not the ''root'' interpreter in its thread, you can delete it from an ancestor interpreter, which releases all the memory associated with it back into the general memory pool.
:<syntaxhighlight lang ="tcl">interp delete theChildInterpreter</langsyntaxhighlight>
 
=={{header|Wren}}==
10,333

edits