empty element in 'structure'.
Ray Andrews <[email protected]> Thu, 14 May 2026 08:48:07 -0700
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------a3opA6ds1yoeo7Qw1vqO4gaZ
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Some of my functions use what is in practice a structure tho in theory I
guess it's just a collection of scalars and arrays, but it's all copied
in one go like this:
set -A IN "${(@Pkv)1}" # Copy the array to IN, the working copy.
... anyway it's very fragile, the 'structure' must never change, so even
when a given 'element' isn't used, it must exist. Here's a slice of one
such structure:
body[window]="Body"
body[list]="body_list"
body[page_tops]="Btops"
Bclicks=()
body[mouse_clicks]="Bclicks"
# body[mouse_clicks]="()"
body[hight]=$((Hight))
body[width]=$BW
... now here's the issue: 'body[mouse_clicks]' isn't used but again, it
must exist otherwise the 'set' command above crashes. If I use the
rather phony:
Bclicks=()
body[mouse_clicks]="Bclicks"
... it works fine. But if I cut to the chase and do:
body[mouse_clicks]="()"
... it doesn't work, the 'structure' fails cuz the 'element' vanishes --
I think. Purely as a question of semantics is there a way to do it the
'direct' way and avoid the placeholder 'Bclicks'? I know there's ways of
hanging on to empty elements in an normal array and I thought the
quotes "()" would do it, but nada. Or is this pushing zsh where she
doesn't want to go? That is, preserving an entire empty array withing a
pseudo structure? But again, doing it the 'long way' works fine.
--------------a3opA6ds1yoeo7Qw1vqO4gaZ
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="DejaVu Sans"><br>
Some of my functions use what is in practice a structure tho in
theory I guess it's just a collection of scalars and arrays, but
it's all copied in one go like this:<br>
<br>
set -A IN "${(@Pkv)1}" # Copy the array to IN, the working
copy.<br>
<br>
... anyway it's very fragile, the 'structure' must never change,
so even when a given 'element' isn't used, it must exist. Here's
a slice of one such structure:<br>
</font><font face="monospace"><br>
body[window]="Body" <br>
body[list]="body_list" <br>
body[page_tops]="Btops" <br>
<br>
Bclicks=()<br>
body[mouse_clicks]="Bclicks" <br>
# body[mouse_clicks]="()" <br>
<br>
body[hight]=$((Hight)) <br>
body[width]=$BW <br>
<br>
... now here's the issue: 'body[mouse_clicks]' isn't used but
again, it must exist otherwise the 'set' command above crashes. If
I use the rather phony:<br>
<br>
</font><font face="monospace"> Bclicks=()<br>
body[mouse_clicks]="Bclicks" <br>
</font><font face="monospace"> <br>
... it works fine. But if I cut to the chase and do:<br>
<br>
</font><font face="monospace"> body[mouse_clicks]="()" <br>
<br>
... it doesn't work, the 'structure' fails cuz the 'element'
vanishes -- I think. Purely as a question of semantics is there a
way to do it the 'direct' way and avoid the placeholder 'Bclicks'?
I know there's ways of hanging on to empty elements in an normal
array and I thought the quotes "()" would do it, but nada. Or is
this pushing zsh where she doesn't want to go? That is, preserving
an entire empty array withing a pseudo structure? But again, doing
it the 'long way' works fine. <br>
<br>
</font><br>
</body>
</html>
--------------a3opA6ds1yoeo7Qw1vqO4gaZ--