empty element in 'structure'.

Ray Andrews <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <e6d4d3ce-4def-467d-935c-add79886d2e6__45097.0069783338$1778775020$gmane$org@eastlink.ca>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.