Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Type constraint for named parameters, and questions about 6.c backwards compat

5 views
Skip to first unread message

Rob Hoelz

unread,
Dec 21, 2015, 2:00:04 PM12/21/15
to perl6-l...@perl.org
Hello Perl 6 users and developers!

I asked this in #perl6, but I wasn't getting a response there, so I
figured I would try here.

In the following code:

> use v6;
>
> class C {
> has Str $!dist-id;
>
> submethod BUILD(:$!dist-id) {}
> }
>
> my ( $build ) = C.can('BUILD');
> say $build.signature.params[1].type; # prints Any, should it be Str?

If I try to pass a non-Str to C.new, I will get a type check failure,
as the value cannot go into $!dist-id, so that functionality works.
However, as in the example, if I am inspecting the signature, the type
constraint is Any. Should we change this so that it's Str instead?

This brings up another question: how backwards compatible will 6.c be?
Let's say that the above behavior occurs with 6.c, and someone brings up
the Any vs Str question after 6.c is released. Since someone could
technically depend on introspection of the signature returning Any in
this case, would we be hesitant to change the behavior?

Thanks,
Rob
0 new messages