[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Feature: parameters declared in body
From: |
Neil R. Ormos |
Subject: |
Re: [PATCH] Feature: parameters declared in body |
Date: |
Fri, 8 Apr 2022 10:38:00 -0500 (CDT) |
Manuel Collado wrote:
> Kaz Kylheku escribio:
>> The idea is that there is a new kind of attribute syntax
>> whereby, inside a function, if we put the @param: prefix
>> before a variable, that variable is added as a parameter
>> to the surrounding function, which has the effect of making
>> it a local variable.
>> This effectively extends the Awk language with a nice way
>> of defining locals, that is easy to use from code generators
>> and macro preprocessors, and is based in the existing model
>> of Awk local variables being parameters.
I agree with Ed Morton's request not to "introduce a construct that lets you
declare a variable as a parameter without it appearing in the function
declaration" for the reasons he mentions.
> Perhaps a simpler approach is to introduce a
> @local directive. [...]
Voluntary, Algol-style lexical scoping, where @local marks a variable as local
to the enclosing {} pair, could be extremely valuable in making Gawk programs
easier to write, understand, and maintain.