Tcl Source Code

View Ticket
Login
Ticket UUID: 451441
Title: tcl::nop - No-op and minimal bytecode
Type: RFE Version: None
Submitter: dgp Created on: 2001-08-16 03:51:55
Subsystem: - New Builtin Commands Assigned To: msofer
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-09-11 00:21:22
Resolution: Accepted Closed By: msofer
    Closed on: 2001-09-10 17:21:21
Description:
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.
User Comments: msofer added on 2001-09-11 00:21:22:

File Added - 10605: noopProc.patch.final

msofer added on 2001-09-11 00:21:21:
Logged In: YES 
user_id=148712

noopProc.patch.final committed - diff to previous is just in
comments and formatting.

msofer added on 2001-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 added on 2001-08-17 06:20:35:

File Added - 9618: nop4.patch

msofer added on 2001-08-17 06:20:34:
Logged In: YES 
user_id=148712

New nop4.patch: standard argument substitution, always
byte-compiled, fastest execution.

msofer added on 2001-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

dgp added on 2001-08-16 23:16:04:

File Deleted - 9586:

msofer added on 2001-08-16 18:48:06:

File Added - 9600: nop2.patch

msofer added on 2001-08-16 18:48:05:
Logged In: YES 
user_id=148712

Fixing a bug (maxStackDepth should be 1, not 0). Sorry ...

dgp added on 2001-08-16 10:51:55:

File Added - 9586: nop.patch

Attachments: