Subject: Request Tcl 8.1 concat support for list objects - DN [1]


scripticsBugForm@auto.genned.post - 19 May 1999 - comp.lang.tcl

 Tcl 8.1 Request:  Generated by Scriptics' bug entry form at
     http://www.scriptics.com/support/bugForm.html
 Responses to this post are encouraged.
 ------

 Submitted by:  Jeffrey Hobbs
 CVS:  May 17, tclUtil.c $Id: tclUtil.c,v 1.11 1999/05/06 19:21:11 stanton Exp $
 OperatingSystem:  Sun Solaris
 OperatingSystemVersion:  2.5.1
 CustomShell:  mod core? not me...
 Synopsis:  concat support for list objects

 DesiredBehavior:
     As pointed out on c.l.tcl, concat actually converts everything to
     strings
     and returns a string, as opposed to what the docs say.  This features
     enhancement involves situations where concat was passed only objects of
     the list type.  In this case, it concats them together into one list,
     and returns an object of type list.

 Patch:
 The following needs to be inserted as the first code in Tcl_ConcatObj
 in tclUtil.c:

     for (i = 0;  i < objc;  i++) {
     if (objv[i]->typePtr != &tclListType) {
         break;
     }
     }
     if (i == objc) {
     Tcl_Obj **listv;
     int listc;
     /*
      * All the items are of list type, concat them together
      * as lists, and return as a list obj
      */
     objPtr = Tcl_NewListObj(0, NULL);
     for (i = 0;  i < objc;  i++) {
         /*
          * No check is made on the result code, as we checked
          * above that they are all of list type...
          */
         Tcl_ListObjGetElements(NULL, objv[i], &listc, &listv);
         Tcl_ListObjReplace(NULL, objPtr, INT_MAX, 0, listc, listv);
     }
     return objPtr;
     }

 PatchFiles:
     generic/tclUtil.c

 Comments:
     In tests on larger lists, this actually takes a bit more time to return
     to assemble and return the object than the regular bytes concat mode.
     However, when the returned object is next used as a list (like with
     foreach), there is a notable time savings.

     Again, this only affects calls to concat where all args passed are
     already recgonized list objects.  This passes all tests, and doesn't
     break any syntax logic.

Last modified
1999-09-27

(195.108.246.50)

Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated