Newsgroups: gnu.misc.discuss,comp.lang.tcl,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!godot.cc.duq.edu!news.duke.edu!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!vixen.cso.uiuc.edu!milo.mcs.anl.gov!karrels
From: karrels@mcs.anl.gov (Edward L. Karrels)
Subject: Re: Why you should not use Tcl
In-Reply-To: fdrake@csgrad.cs.vt.edu's message of 26 Sep 1994 02:13:22 GMT
Message-ID: <KARRELS.94Sep30135948@ptera.mcs.anl.gov>
Sender: usenet@mcs.anl.gov
Organization: Math & Computer Science Divison, ANL
References: <9409232314.AA29957@mole.gnu.ai.mit.edu> <361irr$jij@news1.shell>
	<SCHWARTZ.94Sep24164719@groucho.cse.psu.edu>
	<365ao2$o35@server.cs.vt.edu>
Date: Fri, 30 Sep 1994 18:59:48 GMT
Lines: 67
Xref: glinda.oz.cs.cmu.edu gnu.misc.discuss:18649 comp.lang.tcl:19803 comp.lang.scheme:10195

In article <365ao2$o35@server.cs.vt.edu> fdrake@csgrad.cs.vt.edu (Fred L Drake Jr) writes:

   In article <SCHWARTZ.94Sep24164719@groucho.cse.psu.edu>,
   Scott Schwartz <schwartz@groucho.cse.psu.edu> wrote:
   >They are not first class objects: you can't assign one to another, pass
   >or return them from functions.  Contorted "call by name" semantics are

So, how about C?

Given:
  int a[20], b[20];

What does your C compiler do when you do:

  a = b;

?

You can, however do:
  int a[20], *b;
  b = a;

but in Tcl you can do:
  set a(this) hi
  set a(that) ho
  upvar 0 a b
  puts "$b(this) $b(that)"
or, more usefully, just upvar or global.  In fact, the simple (as opposed
to upvar <n>, which I think could be evil for n<-1) upvar syntax
makes it obvious to someone reading the code that the variable you
are using is in fact changing the value of a variable 'above' this level.

     I agree with you on this one, but:

   >   3) Tcl has no pointers, and shares this property with most LISP like
   >   languages.  Deeply nested list structures can be created, though, which
   >   provide much of the functionality of linked lists.
   >

To that I say this:

  proc varref {reference_this as} {
     # create a reference so that $as references $reference_this
     uplevel upvar 0 "{$reference_this}" "{$as}"
  }
  
  # creating a structure of two elements:
  #   struct {
  #      char *value;
  #      char *next;
  #   };

  set x [list "This is the value of x" y]
  set y [list "This is the value of y" z]
  set z [list "This is the value of z" ""]
  
  varref x node
  while {[info exists node]} {
     puts [lindex $node 0]
     varref [lindex $node 1] node
  }

--
Ed Karrels
karrels@mcs.anl.gov

What's the height of optimism?  A trombonist with a beeper.
