tcl::nop - No-op and minimal bytecode
Closed / Accepted451441ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-08-16 03:51:55
In the discussions about TIP 53
http://purl.org/tcl/tip/53.html
Miguel Sofer counter-proposed an approach
where Tcl would add a single special
built-in command [tcl::nop], and then the
[assert] functionality (and more!) could
be defined in terms of [tcl::nop] as a
separate package.
Here is a patch Miguel and I have produced
that implements tcl::nop. Try it!
The result of [tcl::nop] is always an empty string.
When bytcode compiled, [tcl::nop] does nothing and its
arguments are not substituted. When not byte-code
compiled (very unusual), [tcl::nop] behaves exactly
like
proc tcl::nop args {}
so its arguments are substituted, but it still does
nothing.
dgpplain2001-08-16 10:51:55
File Added - 9586: nop.patch
msoferplain2001-08-16 18:48:05
Logged In: YES user_id=148712 Fixing a bug (maxStackDepth should be 1, not 0). Sorry ...
msoferplain2001-08-16 18:48:06
File Added - 9600: nop2.patch
dgpplain2001-08-16 23:16:04
File Deleted - 9586:
msoferplain2001-08-17 00:43:33
File Added - 9609: nop3.patch
Logged In: YES
user_id=148712
nop3.patch is a new version that takes a different approach
to argument substitutions:
- if no argument to tcl::nop would require substitutions, it
byte-compiles
- otherwise, it calls the command
This does not break the standard Tcl syntax; tcl::nop does
not work as a comment any longer:
tcl::nop [incr foo]
does cause an increment in foo (and isn“t bcc'ed), whereas
tcl::nop {[incr foo]}
is bcc'ed and doesn't change foo
msoferplain2001-08-17 06:20:34
Logged In: YES user_id=148712 New nop4.patch: standard argument substitution, always byte-compiled, fastest execution.
msoferplain2001-08-17 06:20:35
File Added - 9618: nop4.patch
msoferplain2001-08-18 06:23:32
File Added - 9657: noopProc.patch
Logged In: YES
user_id=148712
Following Brent Welch's excellent suggestion: giving [proc]
the smarts to bytecompile a [noop], instead of defining a
new command -->noopProc.patch
Currently only will be bytecompiled to noop procs of the
form
proc a xxxx yyyy
where the arglist xxxx's string rep contains just spaces and
the word 'args', and the body yyyy's string rep contains
just spaces, tabs or newlines.
I.e,
proc a { args } { }
will be bytecompiled, but
proc b { args } #
will not.
Maybe this ticket should move from "Feature Request" to
"Patch"?
msofer Ticket [451441ffff]: 1 change
[History diff]2001-09-06 02:21:14
msoferplain2001-09-11 00:21:21
Logged In: YES user_id=148712 noopProc.patch.final committed - diff to previous is just in comments and formatting.
msoferplain2001-09-11 00:21:22
File Added - 10605: noopProc.patch.final
Log in (anonymous is fine) to add a comment.
Attachments:
- noopProc.patch.final [download] added by msofer on 2001-09-11 00:21:21. [details]
- noopProc.patch [download] added by msofer on 2001-08-18 06:23:32. [details]
- nop4.patch [download] added by msofer on 2001-08-17 06:20:35. [details]
- nop3.patch [download] added by msofer on 2001-08-17 00:43:33. [details]
- nop2.patch [download] added by msofer on 2001-08-16 18:48:06. [details]