zsh-users
 help / color / mirror / code / Atom feed
From: Pier Paolo Grassi <pierpaolog@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Bart Schaefer <schaefer@brasslantern.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: A way to untie -T vars?
Date: Sun, 22 Jan 2023 10:34:21 +0100	[thread overview]
Message-ID: <CAP+y1xAJq6TrkbTOSFNs=jbf7_=sTYnj3Y1=qHoF5W4S1r=Zkg@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMpo9i5qr-HmH2ymaxaJ6hQLg-gThZkSRJvafUEp1oN0ag@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

and what your solution could look like? I would use something like
___untie_array and ___untie_scalar that I would never use outside the untie
function, but I wonder if there is a more general solution

Il giorno sab 21 gen 2023 alle 20:16 Roman Perepelitsa <
roman.perepelitsa@gmail.com> ha scritto:

> On Sat, Jan 21, 2023 at 7:53 PM Bart Schaefer <schaefer@brasslantern.com>
> wrote:
> >
> > Speaking of unorthodoxy ...
> >
> > untie () {
> >   emulate -L zsh
> >   case ${(tP)1} in
> >   (scalar-tied)
> >     local scalar=${(P)1}
> >     unset $1
> >     typeset -g $1=$scalar
> >     ;;
> >   (array-tied)
> >     local array=( ${(P)1} )
> >     unset $1
> >     # Need eval here for array assignment, as
> >     # reserved word doesn't work with $1=(...)
> >     eval "typeset -ga $1=( \$array )"
> >     ;;
> >   (*) ;;
> >   esac
> > }
>
> Bravo.
>
> `untie scalar` and `untie array` won't work due to name clashes but
> this seems easily fixable.
>
> Roman.
>
> --
Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1635 bytes --]

  reply	other threads:[~2023-01-22  9:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 16:37 Sebastian Gniazdowski
2023-01-21 16:55 ` Bart Schaefer
2023-01-21 17:11   ` Bart Schaefer
2023-01-21 18:52     ` Bart Schaefer
2023-01-21 19:15       ` Roman Perepelitsa
2023-01-22  9:34         ` Pier Paolo Grassi [this message]
2023-01-22  9:58           ` Roman Perepelitsa
2023-01-23  2:14             ` Bart Schaefer
2023-01-23  9:47               ` Roman Perepelitsa
2023-01-23 18:27                 ` Bart Schaefer
2023-01-23 18:42                   ` Mikael Magnusson
2023-01-23 18:43                     ` Mikael Magnusson
2023-01-23 19:12                     ` Bart Schaefer
2023-01-24  5:45                   ` Bart Schaefer
2023-01-24  9:56                     ` Roman Perepelitsa
2023-01-24 16:42                       ` Bart Schaefer
2023-01-24 16:45                         ` Peter Stephenson
2023-01-24 17:40                           ` Bart Schaefer
2023-01-24 17:54                             ` Roman Perepelitsa
2023-01-24 22:54                               ` Bart Schaefer
2023-01-25 14:41                                 ` Roman Perepelitsa
2023-01-25 22:39                                   ` Bart Schaefer
2023-01-25 23:48                                     ` Bart Schaefer
2023-01-26  2:34                                       ` Bart Schaefer
2023-01-21 17:15   ` Roman Perepelitsa
2023-01-21 17:23     ` Bart Schaefer
2023-01-21 17:31 ` Bart Schaefer
2023-01-21 17:48   ` Roman Perepelitsa
2023-01-21 17:50     ` 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='CAP+y1xAJq6TrkbTOSFNs=jbf7_=sTYnj3Y1=qHoF5W4S1r=Zkg@mail.gmail.com' \
    --to=pierpaolog@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=schaefer@brasslantern.com \
    --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).