Skip to content
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

where{} section triggered in signature despite param optional and not given #2622

Closed
p6rt opened this issue Jan 27, 2012 · 4 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Jan 27, 2012

Migrated from rt.perl.org#109182 (status was 'rejected')

Searchable as RT109182$

@p6rt
Copy link
Author

p6rt commented Jan 27, 2012

From @bbkr

$ perl6 -e 'sub foo ( :$id? where { say "I should not be here when there is no
param passed"} ) {}; foo()'

Returns​:
I should not be here when there is no param passed

$ perl6 --version
This is perl6 version 2012.01 built on parrot 3.11.0 revision RELEASE_3_11_0

@p6rt
Copy link
Author

p6rt commented Jan 27, 2012

From @masak

On Fri Jan 27 02​:21​:32 2012, pawel.pabian@​implix.com wrote​:

$ perl6 -e 'sub foo ( :$id? where { say "I should not be here when
there is no
param passed"} ) {}; foo()'

Returns​:
I should not be here when there is no param passed

$ perl6 --version
This is perl6 version 2012.01 built on parrot 3.11.0 revision
RELEASE_3_11_0

<masak> nom​: sub foo($x? where { .defined }) { say "OH HAI" }; foo
<p6eval> nom 6eae67​: OUTPUT«Constraint type check failed for parameter
'$x' [...]
<masak> what say you? should the above run the where clause or not?
<jnthn> masak​: I was dubious about that ticket.
<moritz> masak​: it's wrong
<jnthn> masak​: We used to have a bug where we didn't type check default
values.
<moritz> type checks also apply to defaults
<jnthn> Right
<jnthn> Yeah, I think the ticket is wrong.
<moritz> and optional params are just some weird kind of automatic
undefined default
<jnthn> It's not so hard to imagine a where condition that matches on
undefined and defined values.
* masak rejects ticket

A case can be made for either behavior (don't where-check not provided
variables, type-check provided variables), but I think Perl 6 is
converging on semantics where parameters that don't get passed are very
similar to uninitialized variables. From the perspective of the callee,
it shouldn't matter whether an argument wasn't passed, or whether it was
passed in some undefined form.

@p6rt
Copy link
Author

p6rt commented Jan 27, 2012

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 27, 2012

@masak - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jan 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant