New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parameter predicates in signatures #16245
Comments
From zefram@fysh.orgCreated by zefram@fysh.orgSignatures as they currently exist are conspicuously missing the The original purple_signatures branch had an implementation of parameter We should probably require that parameter predicates be implemented as a Perl Info
|
From @xsawyerxOn Tue, 14 Nov 2017 07:21:25 -0800, zefram@fysh.org wrote:
We discussed this at length at the core hackathon with no exact decision on how to implement this. One suggestion was the following syntax: sub abc ( $foo?, ?$is_foo) { Another (which was not happily received) was: sub foo ($x, $y ? $is_y) { Yves suggested having another value (like PL_sv_undef) but that used for predicates, to differentiate a value not sent and a value sent as undef. |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgSawyer X via RT wrote:
What is the "?" suffix on "$foo" about? We already have the "= undef"
If that's all you're doing with a parameter predicate, it's better
You still need a default value expression. If the intent is that I have a concern about incorporating the parameter predicate into the Apart from that non-fatal disadvantage, I'd be fine with something
And how would we distinguish an argument being passed with that special -zefram |
From @demerphqOn 20 Nov 2017 13:24, "Zefram" <zefram@fysh.org> wrote: Sawyer X via RT wrote:
What is the "?" suffix on "$foo" about? We already have the "= undef" People want to distinguish no value passed from a default undef. The idea was that the ? at the back of the first var allows the next var to
If that's all you're doing with a parameter predicate, it's better
You still need a default value expression. If the intent is that This is a variant of the previous idea, $y ? $is_y means, the ? signals Again, this is to distinguish no-value passed from a default undef. I have a concern about incorporating the parameter predicate into the Apart from that non-fatal disadvantage, I'd be fine with something
And how would we distinguish an argument being passed with that special Well, I dunno. This is a variant of the semipredicate problem: We want to Lets assume we do not use any of these flag-based solutions, how would we Answer: the same way you solve any semipredicate problem: use a unique { So now there is no way a caller provided value can be mistaken for the All I was thinking of was a standardized way to implement this pattern. So you could so something like this: sub foo($x?) { maybe the magic would know what sub it came from, and when is_nothing($x) Frankly, I /personally/ don't see a need to support this in the signature cheers, |
From zefram@fysh.orgdemerphq wrote:
The parameter variable will still get some value, if the argument wasn't
So the effect of the "?" on the primary parameter variable is merely
Again, $y would actually have some default value.
Right, we can drop that idea then.
That sort of idea was raised in the old "acceptable signatures" thread,
That canard again. We're not designing signatures for other languages, Quick comparisons: * C doesn't need parameter predicates because it puts the burden of * Most versions of Lisp (pretty much any that support named optional * Bourne shell doesn't support naming of parameters to shell functions, -zefram |
From @SmylersZefram writes:
• PHP has the func_num_args() function, which returns the equivalent That has the advantages of not requiring any special syntax in Smylers |
From @demerphqOn 21 November 2017 at 13:52, Zefram <zefram@fysh.org> wrote:
I am getting a bit tired of explaining things that other people want, So the idea was that the ? style syntaxes would tell Perl that it is needed.
Again, this isnt my argument. I am explaining what other people said.
This sarcasm is unnecessary and unwelcome.
Sure.
I dont find that very respectful Zefram, especially considering I am A canard is defined as "an unfounded rumour or story". My opinion on whether Perl should not egregiously deviate from
I understand your view, and I even respect it. But it would be nice to
This is a good argument. But not that compelling to me. I dont think
Like I said, I don't care what we do beyond a general aesthetic So do what you want, I am out of this discussion now. Yves -- |
From zefram@fysh.orgdemerphq wrote:
I, too, would rather have the idea from someone who actually wants it,
The parameter predicate item itself serves to signal that the information This sounds rather as though we're debating something that got mangled en
That's not sarcasm. If there's no actual proposal there then there is
That's a more nuanced position that was implied by the blanket statement -zefram |
From @xsawyerxLet me pause things right here, if I may. I am afraid Yves is here because of me. While we were discussing Yves was at the discussion and offered his suggestion on how one might Given time, I'm sure Todd would fill in the blanks on his need so they On 11/21/2017 03:56 PM, Zefram wrote:
|
From curtis_ovid_poe@yahoo.comIf I may jump in: On Tuesday, 21 November 2017, 16:08:30 CET, Sawyer X <xsawyerx@gmail.com> wrote: Let me pause things right here, if I may. I am afraid Yves is here because of me. While we were discussing Yves was at the discussion and offered his suggestion on how one might Given time, I'm sure Todd would fill in the blanks on his need so they On 11/21/2017 03:56 PM, Zefram wrote:
|
From zefram@fysh.orgOvid via perl5-porters wrote:
That is a very different situation from that with which this ticket
This too should go in its own ticket. -zefram |
From @xsawyerxOn 11/21/2017 06:38 PM, Zefram wrote:
Ovid, I don't think this approaches the situation here. I think we're foo(); In the first, $bar will have a default or undef (depending on signature)
Ovid, could you please open an issue for this? I think it's important |
From @rjbs* Sawyer X via RT <perlbug-followup@perl.org> [2017-11-20T06:44:50]
My suggestion at the time was, and remains now, to provide argc in caller. The "was $x provided" is rarely needed, and checking argc is simple, out of the The down side is needing to update the positions numbers used in checking argc. -- |
From zefram@fysh.orgRicardo Signes wrote:
This would suck, for several reasons. The more important reasons Firstly, checking argc is an annoying way of doing this job. This isn't Also, all of the proposed means of accessing argc decouple the argc But even if we're happy with a decoupled argc as a means of determining The intention with signatures always appeared to be that they should This concept of feature completeness does not lead to adding an unlimited As for caller() as the place to get argc, it's a sensible place to acquire
It's not that rare. I found that 20% of my optional parameters needed -zefram |
From @demerphqOn 30 November 2017 at 18:58, Zefram <zefram@fysh.org> wrote:
I've never encountered this problem in a way it couldn't be solved Just my $0.02 cents. cheers, -- |
From @leonerdAnother potentially simple workaround: $ perl -E \ f(); The signatures feature is experimental at -e line 1. -- leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS |
Migrated from rt.perl.org#132444 (status was 'open')
Searchable as RT132444$
The text was updated successfully, but these errors were encountered: