From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>, Zsh Users <zsh-users@zsh.org>
Subject: Re: following a variable's value.
Date: Sun, 18 Oct 2015 03:29:11 +0300 [thread overview]
Message-ID: <2507441445128151@web27o.yandex.ru> (raw)
In-Reply-To: <5622DC5B.20103@eastlink.ca>
18.10.2015, 03:11, "Ray Andrews" <rayandrews@eastlink.ca>:
> 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.
next prev parent reply other threads:[~2015-10-18 0:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-17 23:40 Ray Andrews
2015-10-18 0:29 ` ZyX [this message]
2015-10-18 4:31 ` Ray Andrews
2015-10-18 11:19 ` ZyX
2015-10-18 17:15 ` Ray Andrews
2015-10-18 17:33 ` Bart Schaefer
2015-10-18 17:46 ` Ray Andrews
2015-10-18 16:54 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2507441445128151@web27o.yandex.ru \
--to=kp-pav@yandex.ru \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).