Deutsch   English   Français   Italiano  
<ygamsmo2ili.fsf@akutech.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Ralf Fassel <ralfixx@gmx.de>
Newsgroups: comp.lang.tcl
Subject: Re: How to pass an object from inside its own method to a helper function
Date: Thu, 11 Jul 2024 14:55:53 +0200
Lines: 31
Message-ID: <ygamsmo2ili.fsf@akutech.de>
References: <mwSdnbvrgID6NBL7nZ2dnZfqnPednZ2d@brightview.co.uk>
	<mwSdnbrrgIByMBL7nZ2dnZfqnPcAAAAA@brightview.co.uk>
	<nnd$51f688df$79eeaed5@f984d21cd0a14d8f>
	<1C6dnZup-smxWBL7nZ2dnZfqnPudnZ2d@brightview.co.uk>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 2q2zQunZ69nwrlgM/EmneAdMLbotZ+RNiPUHdLpSNV/AIIhH0=
Cancel-Lock: sha1:0D+F3XKm8tgGC4Lr6CNcn/BNOns= sha1:LAUIbj/h81K5VtWGFSN0+bmBkGg= sha256:lyd80+owSASgUOGL6sr1k56jhZpChQrKuz4kqomPVZs=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Bytes: 1726

* Mark Summerfield <mark@qtrac.eu>
| On Thu, 11 Jul 2024 13:12:52 +0200, Schelte wrote:
| > proc make_file_menu {app} {
| >      .menu.file add command -command [list $app on_quit] \
| >         -label Quit -underline 0 -accelerator Ctrl+Q
| > }
| > 
| > Originally you had $app inside curly braces, which prevented it from
| > being substituted at definition time. At execution time, the app
| > variable was out of scope.
>
| Thank you, that works great.

To save you trouble on your TCL-road ahead, make sure you understand the
difference between

  -command {$app on_quit}

which you had originally in your code and

  -command [list $app on_quit]

which is the correct way of doing things and

  -command "$app on_quit"

which also most probably would "work" right now,
until some day it won't :-)... 

HTH
R'