Tcl Source Code

View Ticket
Login
Ticket UUID: 776614
Title: Incremental evaluation of scripts
Type: RFE Created on: 2003-07-24 00:25:07
Submitter: ysutjandra Assigned to: dgp
Subsystem: 37. File System Severity: Minor
Priority: 5 Medium Last modified: 2016-07-02 19:03:11
Status: Closed Closed by: dgp
Resolution: Rejected Closed on: 2016-07-02 19:03:11
Version: None
Description:
Hi,

Currently, when I source a file, TCL creates a buffer 
whose size is equivalent to the size of the file.  Then 
evaluate the buffer altogether.

I'm asking for a utility whereby I can specify the size of 
buffer I want Tcl_SourceObjCmd to work with.  And as 
much as possible, TCL does not grow this buffer size, 
unless if needed.  

A possible example where growing the buffer size is 
needed is if you encounter a flow-control commands 
such as while, for, etc, or any other commands that 
require a open-curly-brace and close-curly-brace.

This kind of feature will be very useful when most of the 
time you source a script that is really-really-really huge.

A good testcase maybe a 100,000-line script where 
each line is doing the same thing.

   for { set i 0 } { $i < 10 } { incr i } { }
   for { set i 0 } { $i < 10 } { incr i } { }
   for { set i 0 } { $i < 10 } { incr i } { }
   ...

-- Yohan
User Comments:
dgp added on 2003-07-24 09:43:00:
Logged In: YES 
user_id=80530


Tcl provides the commands
[read], [eval], [info complete],
and [info script $filename], so
it's very simple to construct 
your own [proc] to do what you
want.

Given that, I see little need to
augment [source] in the manner
you suggest.

ysutjandra added on 2003-07-24 11:15:42:
Logged In: YES 
user_id=799156

I've already tried using the Tcl commands that you 
suggested.  But the runtime turned out to be very slow on a 
huge script.

-- Yohan

dkf added on 2003-07-24 17:02:43:
Logged In: YES 
user_id=79902

There's no particular reason why we couldn't redesign
Tcl_FSEvalFile() to work incrementally once the file size
has gone over some threshold.  It wouldn't even be an
externally visible alteration AIUI (unless the channel used
to read the file is visible during processing...  Hmm...)