Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-09-12
03:13 • Closed ticket [2314561fff]: TODO: NRE-enable subst plus 7 other changes artifact: 73b2ba74d8 user: dgp
03:13 • Ticket [2314561fff]: 4 changes artifact: 688c087d38 user: dgp
2009-09-07
21:22 • Ticket [2314561fff]: 4 changes artifact: ea0f513804 user: dgp
16:44 • Ticket [2314561fff]: 5 changes artifact: 68828b53c9 user: dkf
2009-09-05
06:19 • Ticket [2314561fff]: 4 changes artifact: a805c720db user: dgp
00:33 • Ticket [2314561fff]: 4 changes artifact: 33f87d72ea user: dgp
00:22 • Ticket [2314561fff]: 4 changes artifact: dd950dfb08 user: dgp
00:21 • Add attachment 2314561.patch to ticket [2314561fff] artifact: 6280fd7722 user: dgp
00:21 • Ticket [2314561fff] TODO: NRE-enable subst status still Open with 4 other ... artifact: 7dab47aadb user: dgp
00:21 • Ticket [2314561fff]: 4 changes artifact: 9118ba4b26 user: dgp
00:21 • Ticket [2314561fff]: 4 changes artifact: 862aa3c183 user: dgp
2009-09-02
01:16 • Ticket [2314561fff]: 4 changes artifact: 13cd8844ae user: dgp
01:16 • Ticket [2314561fff]: 4 changes artifact: 949fb8047e user: dgp
01:15 • Ticket [2314561fff]: 4 changes artifact: f336144a1a user: dgp
2009-08-12
20:50 • Ticket [2314561fff]: 4 changes artifact: df14fb87a8 user: dgp
05:12 • Ticket [2314561fff]: 4 changes artifact: d2c133ee0f user: andreas_kupries
05:12 • Ticket [2314561fff]: 4 changes artifact: a00a38b038 user: andreas_kupries
04:37 • Ticket [2314561fff]: 4 changes artifact: 2193f831ea user: dgp
04:35 • Ticket [2314561fff]: 4 changes artifact: 96335b0f82 user: dgp
2009-07-20
22:52 • Ticket [2314561fff]: 4 changes artifact: 950f41d21e user: dgp
22:47 • Ticket [2314561fff]: 4 changes artifact: b3798fbebc user: andreas_kupries
2009-07-18
20:58 • Ticket [2314561fff]: 4 changes artifact: c1d5cbd21e user: dkf
2009-07-14
17:27 • Ticket [2314561fff]: 4 changes artifact: 8e945092b6 user: dkf
17:26 • Ticket [2314561fff]: 1 change artifact: 1155874d90 user: dkf
17:25 • Ticket [2314561fff]: 4 changes artifact: 745d651acc user: dkf
2009-01-05
04:40 • Ticket [2314561fff]: 4 changes artifact: e9afcb8a32 user: dkf
03:48 • Ticket [2314561fff]: 4 changes artifact: c0b77a4a58 user: dgp
2009-01-03
04:03 • Ticket [2314561fff]: 4 changes artifact: b1c55fdf72 user: dkf
2008-12-07
02:36 • Ticket [2314561fff]: 6 changes artifact: 4b22dd0d1c user: dkf
2008-11-19
10:50 • New ticket [2314561fff]. artifact: 7e3f5db0b5 user: dkf

TODO: NRE-enable [subst]

Closed / Fixed2314561fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 17 years ago
Descriptionplain2008-11-19 10:50:15
want to enable the rewriting of tclhttpd's templating system using coroutines, but this in turn requires [subst] to be NRE-enabled
dkfplain2008-12-07 02:36:20
Argh! Tcl_SubstObj is now rather more complex than it used to be (well, on the surface anyway) so it isn't clear how to restructure it to be NRE enabled. Hence it's a job for either the master of parsing or the master of NRE...
dkfplain2009-01-03 04:03:29
At a higher level, what I want is to be able to [yield] inside the processing of a command-substitution of a [subst] (assuming the outer code is in a coroutine). That would allow templates to suspend their processing to allow other events to be processed without having problems with reentrancy (classically, tclhttpd templates just use [vwait]!).

One way to tackle this would be to take the parsed token sequence and to issue bytecode for it, just as if it was a "quote"-delimited word. Another would be to make some kind of NRE-enabled "accumulate the substitutions for these tokens" function (no, I don't know which).
dgpplain2009-01-05 03:48:51
ok, I've been confused.

NRE-enabling [subst] seems feasible.

Doing so while having it continue
to call Tcl_SubstObj() is, of course,
impossible.
dkfplain2009-01-05 04:40:20
I've found that with many other things you have to add a parallel internal NRE-enabled version of a function. Doing so for Tcl_SubstObj is not surprising.
dkfplain2009-07-14 17:25:59
Colin's been hitting this; upping the prio...
dkf Ticket [2314561fff]: 1 change [History diff]2009-07-14 17:26:00
dkfplain2009-07-14 17:27:17
Also noting that I'm specifically talking about doing [subst], and not Tcl_SubstObj
dkfplain2009-07-18 20:58:55
A bit deeper explanation about why this matters.

Tclhttpd is used a fair bit to handle custom application-on-the-www scenarios, and the most common way of using it that way is to write the pages in TMML, which involves the use of [subst]. Something that's often desired is a way to stop the processing of a page for a while until some other processing (e.g., running a subprocess) is finished; right now, with tclhttpd they're doing this by using [vwait] recursively (inside another procedure call). If we could [yield] during [subst]-processing, then it would be possible to change the template processing library so that tclhttpd/tmml doesn't have this nasty recursive-vwait case without having to rewrite lots of existing pages that are already in production.

I've thought a bit about what it would take to make [subst] more efficient in the past. Possibilities included directly bytecoding it, but almost all substantive (and interesting) cases use a non-constant template. Hence it's probably good enough to convert the template to something with an internal rep that has three sub-components: ordinary string, variable substitution, command substitution (all modulo the options). It would then be possible to just concatenate these bits appropriately (and quickly) to make the result, and doing so in an NRE-aware way would be straight-forward too (only affects command substitutions as var traces aren't NRE-aware).

The parser is sufficiently complex that the conversion to the above-mentioned sequence form is beyond what I can do in a small amount of effort, hence dropping it on your lap, Don. :-)
andreas_kupriesplain2009-07-20 22:47:41
This does sound a bit like the template could be compiled to bytecode. Just a sequence of
  push literal
  push variable value
  run a command
and a 'concat' of all the pieces. Either a big one at the end, or incrementally, i.e. interspersed with all the push ops.

I.e. instead of bytecoding [subst] in itself have the subst implementation use the compiler to process the template (if needed), then just run it.
dgpplain2009-07-20 22:52:50
Yes, that's along the lines of what I am thinking.

That's why I'm working on 2823282 first which
has a similar nature.
dgpplain2009-08-12 04:35:19
File Added - 338799: 2314561.patch
dgpplain2009-08-12 04:37:26
Attached patch implements a bytecode compiler
for [subst], which solves this problem for the
cases covered by it since bytecode execution
is already NR-enabled.  This is a partial solution.
andreas_kupriesplain2009-08-12 05:12:17
File Added - 338805: notes_2314561.patch.txt
andreas_kupriesplain2009-08-12 05:12:47
Attached some notes on the patch.
dgpplain2009-08-12 20:50:37
Thanks for the tips on TIP 280 matters. Will
look into them.

If the additional instructions are a large problem,
[subst] bytecode can be achieved using the existing
INST_JUMP_TABLE instruction, I believe, but
not nearly as well.  I also expect the new
INST_RETURN_CODE_BRANCH instruction
will be useful creating bytecode for the [try]
command.
dgpplain2009-09-02 01:15:32
File Deleted - 338799:
dgpplain2009-09-02 01:16:12
File Added - 341382: 2314561.patch
dgpplain2009-09-02 01:16:29
ebased patch to the HEAD.
dgpplain2009-09-05 00:21:09
File Deleted - 341382:
dgpplain2009-09-05 00:21:10
File Deleted - 338805:
dgpplain2009-09-05 00:21:39
File Added - 341785: 2314561.patch
dgpplain2009-09-05 00:22:07
New patch for HEAD includes tests and fixes
for all the TIP 280 issues I could find.
dgpplain2009-09-05 00:33:28
Patch committed.  Ticket still open since the patch
is only a partial solution.
dgpplain2009-09-05 06:19:06
committed a few additional fixes to the HEAD.
Thanks to aku for the rapid testing.
dkfplain2009-09-07 16:44:58
Appears to work in informal testing; added a (very simple) test to coroutine.test but leaving open for more tests. Dropping prio, as we appear now to have enough to support the key templating use-case.
dgpplain2009-09-07 21:22:13
Still in the pipeline is an NR-enabled version
of Tcl_SubstObj().  Will TIP when ready.
dgpplain2009-09-12 03:13:32
Fixed in the HEAD.

There are still internals cleanup,
and new interface exposure tasks
to do, but in terms of the bug reported,
it is now fixed.
dgpplain2009-09-12 03:13:36
allow_comments - 1
Log in (anonymous is fine) to add a comment.

Attachments: