From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7376 invoked by alias); 18 Oct 2015 00:40:02 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20785 Received: (qmail 6596 invoked from network); 18 Oct 2015 00:40:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1445128152; bh=mVepNFxFQEJmewMEWO8g6mzxDUpo5+8NDzVVmpCfLE0=; h=From:To:In-Reply-To:References:Subject:Date; b=jCKHe0Fi9YClXPGD8tWueOrKUbIB/OQjGmnc4dtsWNYgr3T3mq5THQnPNB0Jbma9v yk7ItK5QHYbfo1S72NzayA+h8AboI0zPnEcCPb95DnMF1nVCq+xCxWtpON1YtLYg5U 9mUZOiIEpudmFovsvFrfL15bh0CSSnjK25VCYWvA= From: ZyX To: Ray Andrews , Zsh Users In-Reply-To: <5622DC5B.20103@eastlink.ca> References: <5622DC5B.20103@eastlink.ca> Subject: Re: following a variable's value. MIME-Version: 1.0 Message-Id: <2507441445128151@web27o.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 18 Oct 2015 03:29:11 +0300 Content-Transfer-Encoding: 7bit Content-Type: text/plain 18.10.2015, 03:11, "Ray Andrews" : > Gentlemen, > > I discovered by accident the useful 'warncreateglobal' and it has me in > mind to ask if there's some way of tracing the value of variable. I > know about 'set -x' of course, but some way of following the fortunes of > a single variable would be very nice. I personally know only one way: create a C module which will create a special variable which will run some method each time variable is assigned. Partially you can do it with my https://bitbucket.org/ZyX_I/zpython, but this is rather limited: 1. You are bound to a single variable type. Type can be any: integer, float, string, array, associative array, but only one. Type may only be changed by unsetting the variable and creating a new one. 2. Variable name must start with a $zpython_. 3. Setting non-hash variables is using rather strange convention: zpython_string=foo will call `{bound_object}.__call__('foo')` (essentially the same thing as `{bound_object}('foo')`). This is because normally such types are immutable (hashes can be mutated in-place and zpython uses corresponding methods in place of `__call__`). Do not remember why I choosed not to use standard sequence protocol for editing arrays in addition to hashes, some of which may also be mutated (like list() type). Also I am not really sure whether calling zsh code from parameter handlers is a safe operation, as well as querying any specific operation. If you write C module specifically for your needs you may overcome these limitations.