develooper Front page | perl.perl5.porters | Postings from January 2022

Re: Things you can't do in a signatured sub

Thread Previous | Thread Next
From:
Darren Duncan
Date:
January 31, 2022 22:00
Subject:
Re: Things you can't do in a signatured sub
Message ID:
1389c9d0-7b40-80f2-c2f9-e0ef589b5b3e@darrenduncan.net
On 2022-01-31 1:08 p.m., Dave Mitchell wrote:
> Again, with query parameters this is simple:
> 
>       sub name ($self, ??$has_value, $value = undef) {
>           if ($has_value) {
>               $self->{name} = $value; # even if undef
>           }
>           else {
>               return $self->{name};
>           }
>       }
> 
> $has_value is a boolean value which is true if there are any args
> remaining at that point in parameter processing.

Thanks for the explanation.

I kept hearing references to "query parameters" and they didn't really make 
sense to me before in this context.

The only other place I hear "query parameters" is in reference to calling SQL 
DBMSs from a program, and "query parameters" mean the same thing as plain old 
"parameters", for example when one writes something like:

    SELECT foo FROM bar WHERE baz = :quux

... and after you prepare that, each execution binds "quux" to an argument, 
because it is a "query parameter".

-- Darren Duncan

Thread Previous | Thread Next


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