[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect / Inconsistent behavior with nameref assignments in functi
From: |
Greg Wooledge |
Subject: |
Re: Incorrect / Inconsistent behavior with nameref assignments in functions |
Date: |
Fri, 28 Aug 2020 12:14:42 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Fri, Aug 28, 2020 at 06:37:00PM +0300, Oğuz wrote:
> 28 Ağustos 2020 Cuma tarihinde Greg Wooledge <wooledg@eeg.ccf.org> yazdı:
> > func1() {
> > declare -n _func1_ref="$1"
> > local _func1_i
> > ...
> > }
> >
> This doesn't make the slightest sense. What is the point of having local
> variables then?
You need to distinguish between two types of functions: ones which
use namerefs, and ones which do not.
If a function doesn't use name references, then you may safely use
local variables with any names you like. Nothing has to change.
If a function is going to use a name reference, then you need to
bullet-proof it from head to toe. All local variables have to be
mangled to minimize the chance of collisions. It's an entirely
different problem.
Re: Incorrect / Inconsistent behavior with nameref assignments in functions, Binarus, 2020/08/28
Re: Incorrect / Inconsistent behavior with nameref assignments in functions, Chet Ramey, 2020/08/31
Re: Incorrect / Inconsistent behavior with nameref assignments in functions, Koichi Murase, 2020/08/28