Re: Larry Wall, on Tcl



On Dec 10, 8:07 pm, Darren New <d...@xxxxxxxxxx> wrote:

Note that there *are* languages where you *can* do that.
EIAS prevents it to a large extent, especially since I can store "file"
and "13" in separate strings, then concatenate them and pass them to
[read] and expect it to work.

The vast majority of strings in Tcl *do not* point to actual file
handles, just like the vast majority of valid looking references in
any other language.

In Tcl, objects (anyone object to me calling things in Tcl objects?)
are disconnected from each other in a sense, but they are all still
connected to the hash arrays which allow these objects to be referred
to. Maybe in some language you could have an object which creates a
child object. When the object dies, but fails to clean up the child,
this object becomes disconnected from the object tree. Then it would
be obvious to a GC routine which has an additional reference to the
object, that no other object can reference this object without trying
to guess where in memory it is located. At this point the GC routine
can also remove the reference and allow the memory to be reused. This
is exactly how you would do garbage collection in Tcl. At some point
in time a routine can look for left over references or temporary
namespaces and remove them. But this is just the result of a decision
that someone made. Anyone who wants or needs garbage collection in Tcl
can have it. This is how you write robust programs...you plan for
failure and make a decision on what needs to be done upon failure.

An open but unused file handle is probably the best example of a
failed programming strategy. How could the file handle be lost without
the environment which created the handle knowing about it? Maybe
something more important than a little bit of memory was lost here.
Being satisfied with cleaning up that is really throwing out the baby
with the bath water.

Donal's example below is a good example of how easy it is to write an
intelligent garbage collection routine. I call it explicit
programming. You make a decision on what defines failure and what to
do in case of failure. The processFile proc is a controller object. It
is more elegant than a 'finally' block used in some languages because
it can be reused and because it provides a new specialized word which
captures a larger concept. A 'finally' block is just an anonymous
script.
.



Relevant Pages

  • Re: Larry Wall, on Tcl
    ... extensions written in something other than Tcl, ... I've been trying to identify a problem with using Tcl that garbage ... the only kind of reference ... TCL allows is a rather flimsy string token. ...
    (comp.lang.tcl)
  • Re: How to clear controls from a form - Help Needed
    ... the black box function that reference is removed helps. ... CallersDR = GetData ... black box routine ) as well? ... There is only one SqlDataReader. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: to dispose or not ?
    ... If I use GC.KeepAlive(obj) where I would have used obj = nothing what is the cost vs the risk of not ... When writing an IDisposable routine or Finalizer routine, you must do a lot of extra checks to avoid the problem of the GC running the Dispose and/or Finalizer routines in seemingly random order. ... setting the reference to nothing reduces the reference count to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How should an exit routine wait for release() callbacks?
    ... module's exit routine has to wait until the releaseroutine for that ... The module has now given up any reference to the device it ... reference to it and its release routine gets passed to the driver core. ... subsystem can't be unloaded without unloading my driver first. ...
    (Linux-Kernel)
  • Tcl-URL! - weekly Tcl news and links (Feb 7)
    ... Tablelist is a library package for Tcl/Tk version 8.0 or higher, ... Fixed a bug related to hidden rows, ... Reference: ... comp.lang.tcl is a crucial resource for Tcl practitioners. ...
    (comp.lang.tcl)