This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Tcl misconceptions


Bruce Stephens writes:
> > A Tcl program cannot itself manipulate much of anything but strings.
> > It is given primitives which allow it to deal with other data types,
> > but that's somewhat incidental to the core language.
> 
> "Core language"?!  lindex and so on *are* the core language.  I can
> see what you mean, though.  

I'd just think about it analogously in Scheme, that the special forms
are the core and cons-pairs and symbols are the core data structures.
Sure, R4/5RS defines vectors and other things, but you can still have
something called "Scheme" without them.

Similarly, the core method of manipulation (often implicit) is the
string in tcl.  lappend is "just" a primitive.  

  set x "$x new_member"

is a simple way of imitating it.  And, incidentally, that form *must*
work.  Hence, strings are still at the core of tcl.  For efficiency's
sake you can add true lists, but you still have to be able to do the
strings if the program calls for it.  It's another level of complexity
to do support both ways -- a level of complexity that may be worth it
in the future, but for now I'll stick to strings (at least
internally).

> I'm just suggesting that regarding Tcl as all strings, and then
> deriving subtle ways of working out what all the strings are and
> reducing them to integers/lists and so on is probably overly complex.

To do the way you suggest means supporting *both* ways of looking at
an object.  Again, maybe it will be helpful to do so, but it won't be
less complex.

> It might well be better just to mirror the object representation and
> the byte compiler structure of the Tcl interpreter.  Obviously, you
> decide!

I don't think the bytecode structure would map very well onto Scheme.
At least, it seem like it would be something that would effectively be
an interpreter ontop of Scheme, which can't have great efficiency.

It does seem like a virtual machine could be a better way to support
language-neutral scripting, though.  Not to imply JVM or something,
but a simple (non-optimized) virtual machine designed for untyped
dynamically-bound languages (which describes scripting languages
fairly well).  Is anyone still trying to allow RScheme to be
interchanged with Guile (as it has underlying bytecodes)?

> (As a less important issue.  I'm not entirely sure, but I think Tcl's
> lists are actually closer to vectors.  i.e., when I'm writing Tcl, I
> assume that lappend, lindex and things are constant in time.  I don't
> think that's guaranteed, but it's certainly the case that far more
> code uses lappend than uses lreplace (to add items to the beginning of
> a list).)

string-append is constant time, isn't it?  But I doubt timing issues,
in general, will survive the translation well at all.

lindex done with strings will be linear time, though.  This is
probably much worse than having a linear time lappend.


<------------------------------------------------------------------->
< Ian Bicking                 |  bickiia@earlham.edu                >
< drawer #419 Earlham College |  http://www.cs.earlham.edu/~bickiia >
< Richmond, IN 47374          |  (765) 973-2824                     >
<------------------------------------------------------------------->