From: SourceForge.net <no...@so...> - 2003-10-28 21:45:37
|
Patches item #827119, was opened at 2003-10-20 16:31 Message generated for change (Comment added) made by dgp You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=310894&aid=827119&group_id=10894 Category: 44. Parsing and Eval Group: TIP Implementation Status: Open Resolution: None Priority: 5 Submitted By: Don Porter (dgp) Assigned to: miguel sofer (msofer) Summary: TIP 157 implementation Initial Comment: Here's a first draft implementation of TIP 157 as a patch to the HEAD. Note changes to the public interface. Besides the script level {expand} expansion, a new Tcl_Token type #define TCL_TOKEN_EXPAND_WORD 256 is in tcl.h and a new bytecode opcode #define INST_LCONCAT1 100 is in tclCompile.h Patch does not yet include documentation or test updates. Contributions for both are welcome, as well as mucho banging on it in search of bugs. There are alternative implementation ideas out there too, I'm sure, particularly on better ways to handle bytecode compiling of the {expand} operation. Feel free to treat this as the straw man. ---------------------------------------------------------------------- >Comment By: Don Porter (dgp) Date: 2003-10-28 16:45 Message: Logged In: YES user_id=80530 Latest patch defines and uses a new opcode INST_LIST_VERIFY to verify list validity before expansion with less cost than before. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-27 16:59 Message: Logged In: YES user_id=80530 New patch removes some objv shifting in Tcl_EvalEx. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-27 08:46 Message: Logged In: YES user_id=80530 dkf's outline has many similarities to what is done in the patch to support argument expansion during direct string evaluation. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2003-10-26 07:32 Message: Logged In: YES user_id=148712 Doc proposal exposed in the wiki: http://mini.net/tcl/Dodekalogue ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2003-10-25 19:21 Message: Logged In: YES user_id=148712 Attached my first attempt at Tcl.n revision for this Tip; RFC ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2003-10-25 17:18 Message: Logged In: YES user_id=148712 Having trouble with the endekalogue: all my attempts to document {expand} seem to require to incoporate the concept of 'list' to Tcl.n, a concept which was not necessary up to now. Does anybody have a simple proposal? I guess I deserve this ... ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2003-10-24 18:27 Message: Logged In: YES user_id=79902 I suspect that we could use a better compilation strategy than purely list concatenation, as that does a lot of object-churn. My idea goes something like this: Two new opcodes (though one might be simulatable using existing opcodes - I don't know for sure): INST_VERIFY_LIST and INST_EXPAND_STK (might want it in 1/4 forms). INST_VERIFY_LIST checks that the object on the top of the stack is a list; it *doesn't* pop anything off the stack, but it throws an error if it isn't a list at the stack top. INST_EXPAND_STK has one immediate value which is the number of words to evaluate (much as in INST_INVOKE_STK) but it also reads an additional object off the top of the stack (not counted?) which is a *sorted* list of integer indices to expand. Compilation proceeds as follows: Generate words for command execution as normal. If any of the words are expanded, add a trailing INST_VERIFY_LIST (required for correct functioning of basic-48.19.*) and append the index of the word within the whole command invokation to a list you are building. If at the end of the command you've got a non-empty list, push the list (which is guaranteed to be sorted ints) and use INST_EXPAND_STK instead of INST_INVOKE_STK. This simplifies the compiler *and* allows for a more efficient strategy for use of temporary space when building the actual list of argument objects. I proposed such a strategy for expansion compilation back in the discussions for TIP#144 on tcl-core ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-24 10:57 Message: Logged In: YES user_id=80530 New patch updates the [eval]'s found in the script library and test suite that were only for word expansion to use the {expand} syntax, and those [eval]'s that were used only to force direct string evaluation to [testevalex]. No updates done to the bundled pacakges, which may want to consider the timing of when they [package require Tcl 8.5]. Upon further reflection, it seems that the failing test basic-48.17.0 really is a bug, as performance/object safety was one of the motivators for TIP 157. Fixing it will require another bytecode, and perhaps opens an opportunity for the more ambitious bytecoders to look for the best solutions. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-23 13:52 Message: Logged In: YES user_id=80530 latest patch adds more tests in compile.test, simplifies the code in tclCompile.c a bit. Note the knownBug tests that highlight a potential ability to overflow objc . ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-23 10:52 Message: Logged In: YES user_id=80530 Updated patch adds more tests, moves those from cmdAH.test into basic.test, fixes a few bugs, and add docs for the parser changes. Three tests fail, revealing not exactly bugs, but inconsistencies between compiled operation and direct string evaluation. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-21 16:58 Message: Logged In: YES user_id=80530 Updated patch adds several tests to parse.test (and updates it to tcltest 2) ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-21 10:56 Message: Logged In: YES user_id=80530 Updated patch corrects all known flaws. Includes several tests from Peter Spjuth. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-21 02:28 Message: Logged In: YES user_id=80530 Looks like an "off-by-one" in the in-place objv array expansion shift. Will look again tomorrow. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-21 01:25 Message: Logged In: YES user_id=80530 Crash: % set l1 [list a {b c} d] a {b c} d % list {expand}$l1 a {b c} d % !! list {expand}$l1 a {b c} d % !! list {expand}$l1 Segmentation fault Note that the use of "!!" apparently matters. ---------------------------------------------------------------------- Comment By: miguel sofer (msofer) Date: 2003-10-20 18:05 Message: Logged In: YES user_id=148712 The new INST was missing in the tclInstructionTable (tclCompile.c); patch updated. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2003-10-20 16:45 Message: Logged In: YES user_id=80530 Probably worthwhile to note that the controversial syntax choice between TIPs 157 and 144 are completely determined by line 337 of the patched tclParse.c. Change static char expPfx[] = "expand"; to static char expPfx[] = ""; and this patch becomes an implementation of TIP 144. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=310894&aid=827119&group_id=10894 |