Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Named reference (and other) pending work



One example of dubious behavior is if you try to unset (with no -n) a placeholder reference or a chain to a placeholder reference. This should unset the referred variable but since there is no such variable the current code unsets the placeholder reference. I think that in this case it would make more sense to complain about the fact that there is no referred variable. Similarly, if you use typeset -i var to change the type of var and it turns out that var refers to a placeholder reference, it tries to change the type of the placeholder reference (which triggers an incompatible type change error) while it would make more sense to complain that there is no referred variable.

At least for unset, an alternative to raising an error about the placeholder could be to simply do nothing. After all, unsetting an undefined variable also simply does nothing and if expanding a placeholder is valid then unsetting a placeholder also ought to be valid.

 Should NO_UNSET complain about placeholder references?

After some more thoughts, I think this might be the way to go. The general rule could be to do the following: 

- if placeholder then
  - if KSH_MODE or NO_UNSET
    - then raise an error about the placeholder
    - else default to null/no-op

For more granularity, we could introduce a new option FAIL_ON_PLACEHOLDER but I think it's reasonable to piggyback on NO_UNSET.

Philippe



Messages sorted by: Reverse Date, Date, Thread, Author