Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NOP in TCL

603 views
Skip to first unread message

Joe Fritz

unread,
Aug 1, 1994, 4:42:13 PM8/1/94
to
In article <peba-29079...@nachos.nixu.fi>,
Petri Aukia <pe...@nixu.fi> wrote:
>
>I have an entry field with a definition for "bind Text <Any-KeyPress>". I'd like to disable the Return and Tab keys in the field. The obvious "bind Text <Return> {}" removes any binding associated with the keypress, leaving it at the mercy of the Any-Key.
>
>Now it seems I'd need a command as small as possible with no side-effects. This would in fact be an equivelant to the NOP -command in assembly language.
>--
>Petri Aukia <pe...@nixu.fi>


How about :
proc nop {args} {}

I've used this in several places, and it works fine.
--

-joe (jfr...@rdrc.rpi.edu)

Petri Aukia

unread,
Jul 29, 1994, 11:02:38 AM7/29/94
to

Tom Tromey

unread,
Aug 1, 1994, 6:34:47 PM8/1/94
to
>>>>> "glv" == glv <g...@oblivion.utdallas.edu> writes:

glv> Petri Aukia writes:
>> > Now it seems I'd need a command as small as possible with no
>> side-effects. This would in fact be an equivelant to the NOP -command
>> in assembly language.

glv> This makes a nice no-op:
glv> while 0 {}

glv> You can also define one that's a little more self-documenting:
glv> proc nop {} { return "" }

glv> Both have the same effect: they do nothing and return an empty string.
glv> The first one is just a tiny bit faster.

Why not use ";"?

bind $win <whatever> {;}

Tom

--
tro...@cns.caltech.edu
"In a riddle whose answer is chess, what is the only prohibited word?"
I thought a moment and replied, "The word chess".
-- Jorge Luis Borges

g...@oblivion.utdallas.edu

unread,
Aug 1, 1994, 5:27:01 PM8/1/94
to Petri Aukia
Petri Aukia writes:
>
> Now it seems I'd need a command as small as possible with no
> side-effects. This would in fact be an equivelant to the NOP -command
> in assembly language.

This makes a nice no-op:
while 0 {}

You can also define one that's a little more self-documenting:

proc nop {} { return "" }

Both have the same effect: they do nothing and return an empty string.

The first one is just a tiny bit faster.

---glv

Jay Sekora

unread,
Aug 2, 1994, 11:42:44 AM8/2/94
to
Semicolon and space are good no-ops that don't have much overhead.
Using a space is the standard way of making a window binding that
doesn't do anything, but that prevents the window class bindings from
being invoked:

bind $window <key> { }

rather than

bind $window <key> {}

--
Jay Sekora j...@it.bu.edu
BU Information Technology (MIME ok)
111 Cummington Street
Boston, MA 02115 +1 617 353 2780

0 new messages