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

Re: Up-scope named references, vs. ksh



Bart Schaefer wrote:
> The word "scalar" is just as important in that sentence as the word
> "global" -- "read" and "zstat" can specify whether the variable is
> scalar or array, you can't do that with a nameref.  Furthermore, if

Isn't defaulting to a scalar type fairly normal. For the read use case,
it works for some basic tests when you start the function with:

  [[ -v $1 ]] || typeset -g $1
  typeset -un ref=$1

A different problem I'm finding is with not being able to hide the
reference type of a variable in a called function:

  inner() {
    local var=hello
    typeset -p var
  }
  outer() {
    typeset -n var=value
    inner
  }
  outer

This outputs

  typeset -g -n var=value

The value "hello" is lost but a subsequent assignment within inner()
applies to the reference.

I would expect the `local var` in inner to hide any variable including
references with the same name from an outer scope.

(I'm currently testing with the typeset -nu and Fix crash on
unset-through-nameref patches applied).

Oliver




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