Re: Larry Wall, on Tcl
- From: "tom.rmadilo" <tom.rmadilo@xxxxxxxxx>
- Date: Tue, 11 Dec 2007 08:25:14 -0800 (PST)
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.
.
- Follow-Ups:
- Re: Larry Wall, on Tcl
- From: Donal K. Fellows
- Re: Larry Wall, on Tcl
- From: Darren New
- Re: Larry Wall, on Tcl
- References:
- Larry Wall, on Tcl
- From: Bryan Oakley
- Re: Larry Wall, on Tcl
- From: tom.rmadilo
- Re: Larry Wall, on Tcl
- From: Bryan Oakley
- Re: Larry Wall, on Tcl
- From: tom.rmadilo
- Re: Larry Wall, on Tcl
- From: Cameron Laird
- Re: Larry Wall, on Tcl
- From: Darren New
- Re: Larry Wall, on Tcl
- From: Alan Anderson
- Re: Larry Wall, on Tcl
- From: Darren New
- Re: Larry Wall, on Tcl
- From: tom.rmadilo
- Re: Larry Wall, on Tcl
- From: Darren New
- Larry Wall, on Tcl
- Prev by Date: Re: ttk::notebook: order of panes
- Next by Date: Re: Speeding up recursive directory traversal
- Previous by thread: Re: Larry Wall, on Tcl
- Next by thread: Re: Larry Wall, on Tcl
- Index(es):
Relevant Pages
|