zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org " <zsh-workers@zsh.org>
Subject: Re: Memory leak when working with undefined associative array keys & problems with unset
Date: Sat, 23 Sep 2017 18:48:44 -0700	[thread overview]
Message-ID: <170923184844.ZM10721@torch.brasslantern.com> (raw)
In-Reply-To: <20170923185958.7bddbd39@ntlworld.com>

On Sep 23,  6:59pm, Peter Stephenson wrote:
}
} Can we really not do something like the patch below?

The point of my later "naughty bit" remark was that we'd have to do
something exactly like that patch, so, yeah.

} > } $ unset "a[$key]"
} > } unset: a[hello * [ world]: invalid parameter name
} > 
} > Hmm, when examining ${a[$key]} we enter parse_subscript() with $key
} > tokenized, but there's no way to get the tokenized string to reach
} > the same point in the unset builtin
} 
} I gave up on this ages ago, frankly.  We certainly a need way of raw key
} reference, but I don't think we've got one, and each time we tweak it we
} seem to make it even more tortuous.

The basic problem is that a[$key]=foo is parsed in assignment context,
but unset a[$key] is parsed in ordinary word context.  I don't see any
way around this other than either making unset a keyword, or adding a
command-line option to unset as Daniel suggested.  Neither of these
alternatives makes me very happy.

As noted, ksh93 has (had?) also thrown up its hands on this one.

} Possibly we need yet another flag
} to say "FOR ****'S SAKE DON'T TRY TO BE CLEVER NO I MEAN IT ****" (but
} without the Tarantino script edit).

I can't think of anywhere to attach such a flag.


  reply	other threads:[~2017-09-24  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-16 20:57 Anssi Palin
2017-09-17 23:15 ` Bart Schaefer
     [not found]   ` <1505690609.1747008.1109155032.651AC839@webmail.messagingengine.com>
2017-09-18  0:22     ` Bart Schaefer
2017-09-23 17:59   ` Peter Stephenson
2017-09-24  1:48     ` Bart Schaefer [this message]
2017-09-24 11:37       ` Daniel Shahaf

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=170923184844.ZM10721@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).