Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(k)widgets} v. 'zle -la'
- X-seq: zsh-users 21741
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: ${(k)widgets} v. 'zle -la'
- Date: Thu, 7 Jul 2016 09:49:21 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=c/tfTgMRnZvurm9Xo7ZForoDMfBWyztvGKa1UYOEKYU=; b=YUP6nzSbUepvgo6OYrWFyhgdfEgyLHvpth8QCvo8fG4+0RtO2v3V8t2aid0UTqCYIS S5RXUB9H/CaZlt1EuNCroFKfLOKzLm9+9Dmr+XUQRfRSHL4tiPS6Si7bO8Mr4HocJi3K FJM6IOIhBq0isg2eAYRczkWDxqgArErX/MC7bQHf5BeOLaYnU7CI9l6dtBKiwew/8WgL joNl2WMFmihwZFk0nqYCDkdMDyqucKQ5zocglOBCWy75RDCBRAsglYzLfxYpFnIfoRV8 UdFIO4ejB0NU4Wu4wdHAF/1sGU/1b12gCY0oKpR/1pIyggoYepFLAWBxBEeI/lgonu1N 63fQ==
- In-reply-to: <20160707020023.GA3859@tarsus.local2>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20160705045758.GA18441@tarsus.local2> <160705140120.ZM17175__36700.8317648017$1467752558$gmane$org@torch.brasslantern.com> <20160707020023.GA3859@tarsus.local2>
On Jul 7, 2:00am, Daniel Shahaf wrote:
}
} Is the following behaviour also intentional? Testing a key's presence
} in the associative array in different ways gives different results:
}
} % bindkey foo bar
} % () { print $(( $argv[(I)bar] > 0 )) } ${(k)widgets}
} 1
} % print ${+widgets[bar]}
} 0
It's intentional in that hash table entries are parameter values and
parameters can exist but be unset, like declaring something local and
then unsetting it; $widgets[bar] returns a "value" that is equivalent
to "unset" when the widget doesn't exist.
It's not intentional in that for normal hash tables there's no way to
create such an entry, so the ramifications on e.g. ${+...} of having
a special hash where a key that is present is only a placeholder, were
not fully thought through.
On the other hand it's the only result that accurately represents the
situation.
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author