develooper Front page | perl.perl5.porters | Postings from December 2019

Re: Aliasing and Read-only variables

From:
David Nicol
Date:
December 3, 2019 14:21
Subject:
Re: Aliasing and Read-only variables
Message ID:
CAFwScO82ngUj7bR6faDod1CPsog05ugG1LaU0ugtiGuFtDxWPg@mail.gmail.com
there's Ada'a (and PL/SQL's,etc) convention of marking all parameters
as IN, OUT, or INOUT depending on if they carry values (IN) or are
pass-by-reference (the INOUT ones) or meant for accepting results
(OUT). Assignment operator in function signatures generally means
default value, does it not?  looked at that way, standard perl subs
are all the same with positional INOUT parameters and one OUT value --
except for scalar/list context of course.

https://cs.lmu.edu/~ray/notes/subroutines/ is a nice overview
including Ada and everything else

On 12/3/19, Zefram via perl5-porters <perl5-porters@perl.org> wrote:
> I wrote:
>>usage you're proposing has nothing at all to do with typeglobs, so the
>>association with the glob sigil is misleading.  It also might interfere
>>a bit with any future work to process actual typeglobs in signatures.
>
> Thinking about it more, I find the case compelling to avoid using
> any sigil character as a prefix meaning anything other than the sigil.
> But I agree with a prefix character for this aliasing use being superior
> to a postfix (though not for your reason).
>
> I suggest that "=" would be a better prefix character, mnemonically
> suggesting a stronger-than-usual equality between the argument and the
> parameter variable.  In assigning that character I'm assuming that "="
> wouldn't be used for the pair-constructor shorthand (because of the POD
> clash) and therefore also wouldn't be used for named-parameter shorthand
> in signatures.  However, making it possible to have "=" at the start
> of a signature item invokes a milder version of the POD clash that I
> described in respect of pair shorthand.  It's milder because this isn't
> letting an actual expression begin with "=", and therefore isn't letting
> a *statement* begin with "=".
>
> If "=" is somehow ruled out for this purpose, there are many options
> of weaker mnemonic value that are about as good as each other.  "+"
> is probably my second favourite.
>
> -zefram
>


-- 
Coming to you live, from behind Sneelock's store, in the big vacant lot.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About