From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14982 invoked from network); 12 Feb 2023 19:00:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Feb 2023 19:00:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1676228411; b=fpN8FmVJGnxgwE5lY5OcmpD47BLxaHK0n/VN9xgfDv/Iycb7aRGd6KBPEiTK6Yj0WSU5QWrsC9 CVPKkeVKJg+xCW47JlsalrMmgJD4bhITzT0Fl4Fwp+H810NZm18N1AuVvXVG9YhrCX5wmrPIgH u+8YxW+gozSpYzWtByetyJitTSCTSqtISSO/OxsVLSVooK2g+iTFkhbEWDkPTtGWV4kewvEg31 aP66lYz0WMQoLzIuv4XZWjFxGCX88pfW0p7vCb2pT2oyTtZ9E2fc9nWfumQ1592fTAFXg8GU/x PJhSE2Hnxb+e1PgWGQTwLPDWP2Wm0Qxw5taKQjpniJBn8A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1676228411; bh=12ouZt2t5BS4K5fDQrLSHNg3yUc2qTQddroubxoinR4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=SZ5wj/MlxcluUJmx5DYajDJHjKRjc4gmrXV2Md5Fq/4AqjHRngI8LUJfg/fTwGnTX3sYj7GHqx wjjynYiwfRn3R8+AE1f2gba942Q+eB3azAV5j42jIU9ZgW6H25IzeMR1HaHN4YOQh3r9Pib01x 7j8WGc8b7sL8jNWigrdkzTsvVHyS4MYPAxRUAy2S5kM+7bYJMY9X469HG9h7+6+KYyZxhmOifi 4ZQW3rcqAizYvspWFBx8OA6dEnKFuxBpXLO854zZaN6NCxXNu9THySMWaB44/u4x6vBnTpB6QZ /WO8K9DOOYRPt3JFSTtUU/wyZw6J49T60AAalI8/3uxJ4g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=4PWF1HqhHDPYTroGO5So8q5kbZmQQje4GOVNO+dFCHE=; b=Gtt7z8nEN/K35y3b3b/CwdxSr5 QeI20hJTMGaVi7NZSyOom/CL25spuzPxCrPfykQQqbJuSYPP41TmVUGX9i8I3tdOyI3pjkskos4wC J6h4hA7y1f48GFORzgTh0yhkhgs/vztLV5++Cr+OeH2j0L3F+dqldN/3ZlPKVAOmQZU0MLknnu0OB YZ1YgozNftT6RV/NEDdYR+Uy9FfQwknJET1Lbs5byGlhJgCc2mhUQ3qsLea3qhN/2I0LmAaeZxFZW IhJnCbxt5UrxeJmXqUDBXjSYgAz79TIM8fKjTwP8OgSJHR4FGtYYe/x4MJtO1a1f0emS8AATJL8uk Jnqketfg==; Received: by zero.zsh.org with local id 1pRHa6-000Lgz-FJ; Sun, 12 Feb 2023 19:00:10 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f42.google.com ([209.85.208.42]:34463) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pRHZW-000LKp-H2; Sun, 12 Feb 2023 18:59:35 +0000 Received: by mail-ed1-f42.google.com with SMTP id fj20so10306064edb.1 for ; Sun, 12 Feb 2023 10:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=4PWF1HqhHDPYTroGO5So8q5kbZmQQje4GOVNO+dFCHE=; b=e3Hw4t5ECQeYqp/ITHTZJaFqF9qwodlim85zFY0Lqv3Q3Pv6tQw7E+vj2OIm/MAmoG wzq2YLnzGx8iFCf+h61939BrxpiYpzQByq+T1qH/z7PU+3XWuChMRDYZ/5merFUiTTDX DNVyMwsDey8GqdoipQinYQwghcIYBwynkRvqE/CJ0PdJeGK3W/6MpOqpbIZVuRpi62pz 8hRzJNFtrkOB4/cz/ej1YI+7KuacuOUpQEaLlSoc6ZhmxusCD0iIAUf7LWujDu0QrO8M AHvVuRcJ/7xK+Pt3iR1GDASMFuenLZRGVV9GJNBktX9VowH3LTVDlYYlekz/eYG/iyBh NR0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4PWF1HqhHDPYTroGO5So8q5kbZmQQje4GOVNO+dFCHE=; b=4uQmg6p0Qxrl25ulVDs/kZO7eUadBZoohV31jZ7tQFburvluloWAafZfZglDS7YP/q QABPIrtXDF4sE/vJgxvHlar7KqxECKVEqq6OJRBokaINEHSkeE0eetAfCBX2c/4PFWBq 09OK04fPNuH2jAViAl4w6V+L7rMvqvOxp4WJgRvzFtNy6dYVSWEz1ffpSVIQyxIvw7or a4BbJlx14JfVju/cHO9LVzkEbHQYx1jcFj6hIPvTc8/Bq7SgJ0IBkQ4UlRJ0p/nsosI8 0zZQ8DEPIhSU9MnpqW0Lu4B3gXmSykUYf9jUyDW/rDLuaZ2NuHRxyqTTLtZQcd0fZ3cY EFjw== X-Gm-Message-State: AO0yUKWGbxVt6UQp5g8FqvKaRj3fBOv/cdoMYltRmi6v7tQQHL24Ctb0 6tZHjnjdqaaQrxkFHZcGYg1BDLNCVbPk7X4TVVKJ1WaixPeuAQ== X-Google-Smtp-Source: AK7set8DJl1ASDbIeX15wFIfE9ncakIuhj62sB5QQ9u5lmhQryIj60GpmwEcXme943fM7crpnJp01Etcot+PsgkT+ok= X-Received: by 2002:a50:a41d:0:b0:4ac:50e4:1eee with SMTP id u29-20020a50a41d000000b004ac50e41eeemr2587557edb.3.1676228374160; Sun, 12 Feb 2023 10:59:34 -0800 (PST) MIME-Version: 1.0 References: <67689-1675827940.088548@BxvG.D9_b.7RzI> <12608-1675903622.800470@Xj82.e3y1.svhG> <66045-1675975796.128039@FBF_.0yMO.Y8fk> <94092-1676192523.865597@yGHQ.rexg.4E4Z> In-Reply-To: <94092-1676192523.865597@yGHQ.rexg.4E4Z> From: Bart Schaefer Date: Sun, 12 Feb 2023 10:59:22 -0800 Message-ID: Subject: Re: [PATCH 1/3]: Add named references To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 51415 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Sun, Feb 12, 2023 at 1:02 AM Oliver Kiddle wrote: > > % typeset -n ref=arr[1]whatever > % echo $ref > onewhatever Aha. OK, that's pretty easy to fix. > As I've mentioned, we already have the situation where the caller > needs nothing to make a private grabable by a builtin: > private -a var > compadd -O var one two three > And writing wrappers to e.g. compadd is useful. > > But I don't think we need to address references to privates in other > scopes at this point before the other patches are even applied. May be > better to consider whether there are other advantages in moving private > to the main shell first as that may ease any implementation. I think it would in fact be necessary to move private to the main shell in order to fix this. The second-worst hack in private is the overloading of some parameter flags, and the internals of e.g. createparam() et al. need to be able to distinguish the cases of the original flag meaning from its overloaded meaning. Builtins have the advantage of not passing through that code path. > > > > typeset -n ref > > > > for ref in 'hash[(e)'${(k)^hash[(R)?*]}']'; do ... > > I can't think of a sensible way. Was just that it could be useful. What about adding ${(K)array) to return array[1] array[2] ... ? for ref in ${(K)hash}; do ... I took a quick look at the implementation of (k) and (v) and (K) looks do-able with sufficient messing around in paramsubst(). Which I'm not feeling like undertaking myself just now, though. > Best long term solution might be to allow arrays of references. Bash > does allow arrays of integers. Bash also has sparse arrays, its implementation is quite different.