bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Feature: parameters declared in body


From: Manuel Collado
Subject: Re: [PATCH] Feature: parameters declared in body
Date: Fri, 8 Apr 2022 10:20:12 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

El 07/04/2022 a las 20:28, Kaz Kylheku escribió:
Hi,

I'm posting this as a proposal. If this is accepted, in some
shape, then of course there will be test cases and
documentation.

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.

Perhaps a simpler approach is to introduce a @local directive. So instead of writing:

function myfun( arg1, arg2,        local1, local2) {
    ...
}

We could write:

function myfun( arg1, arg2 ) {
    @local local1, local2
    ....
}

The semantics of the latter could be a bit different. Extra arguments in the function call will not assign initial values to locals.

HTH. Regards.

--
Manuel Collado - http://mcollado.z15.es



reply via email to

[Prev in Thread] Current Thread [Next in Thread]