A stricter typed variable

2017-01-07 Thread Fernando Santagata
Hello, I have a function like this: sub test(Str :$format, :@filter) { say $format; say @filter; } and I wish to have a stricter type control over the second parameter. The natural way to do it seemed this: sub test(Str :$format, Array[Str] :$filter) { say $format; say $filter; } but

Re: A stricter typed variable

2017-01-07 Thread Moritz Lenz
Hi, On 07.01.2017 12:45, Fernando Santagata wrote: > Hello, > > I have a function like this: > > sub test(Str :$format, :@filter) > { > say $format; > say @filter; > } > > and I wish to have a stricter type control over the second parameter. > > The natural way to do it seemed this: > > s

Re: A stricter typed variable

2017-01-07 Thread Joseph Garvin
Being able to type the elements in containers was considered a major problem in Java for years before they added generics. And the whole point of having a computer is to have it do repetitive things, e.g. loop over a bunch of stuff and do the same thing to all of it. How is this an "exaggerated" us

Re: A stricter typed variable

2017-01-07 Thread Moritz Lenz
Hi, On 07.01.2017 15:52, Joseph Garvin wrote: > Being able to type the elements in containers was considered a major > problem in Java for years before they added generics. Please note that Java and Perl 6 are coming from very different directions. Java 1 a statically typed language, where every

Re: A stricter typed variable

2017-01-07 Thread Fernando Santagata
On Sat, Jan 7, 2017 at 4:19 PM, Moritz Lenz wrote: > > How is this an > > "exaggerated" use of containers? Why have the language feature at all if > > it's too clunky for people to use it? > > I'm not saying it's always too clunky to use. I'm saying there's a cost > attached, and you should consi

Re: A stricter typed variable

2017-01-07 Thread Siavash
Hi, If you really want to avoid `Array[Str].new`, you can do something like this: sub foo (@a where .all ~~ Str) {...} On 2017-01-07 11:45:55 GMT, Fernando Santagata wrote: > Hello, > > I have a function like this: > > sub test(Str :$format, :@filter) > { > say $format; > say @filter; > } >

Re: A stricter typed variable

2017-01-07 Thread Parrot Raiser
On 1/7/17, Moritz Lenz wrote: > I observe some weird behavior in Perl 6 newbies (and I've observed it in > myself too): they're so enamored by type constraints that they use them > everywhere, and run into all sorts of type errors they didn't expect. > There seems to be no feature in software (e

Hi perl6 users

2017-01-07 Thread faraco
Hello, I'm new here. Firstly, I like Perl 6. It has some nice attractive features that makes me want to finally settle down to learn the language, the beauty and the ugly, and become a part of this growing community. Despite of what people say about Perl and Perl 6 users community, I found the co

Re: Hi perl6 users

2017-01-07 Thread Parrot Raiser
Welcome. What are your principal applications for P6 likely to be? On 1/7/17, faraco wrote: > Hello, I'm new here. > > Firstly, I like Perl 6. It has some nice attractive features that makes > me want to finally settle down to learn the language, the beauty and the > ugly, and become a part of th