Or maybe - Raku wants List to be parameterizable, so it can specify the
types of its elements, and those can be either mutable or immutable?

I also feel like the Array parameterization - and List parameterization -
could add similar features to - specify its ordinality (must be N elements,
or min ... max elements) - and "all elements must be of this type"
existing List[Int] style ... vs "these elements are these types in this
order" which would not have a conflicting syntax of List[Int] meaning "a
single element list with one integer in it"

-y


On Sun, Nov 2, 2025 at 2:47 PM yary <[email protected]> wrote:

> This got me thinking, "If Raku had a Tuple type, that would be good for
> this- maybe -"
>
> and then I noticed https://raku.land/zef:lizmat/Tuple - a module that
> provides Tuples
>
> "- if we can declare the types of elements of a tuple, in a signature."
>
> - well maybe here we hit the same issue as originally, since we can't
> declare mixed types for an Array, nor any types for a List, perhaps we
> can't do that for a Tuple either? And now I'm half-remembering a discussion
> about this maybe 6+ years ago?
>
> Searching for that got me looking at something related, Signature
> Literals, https://docs.raku.org/language/signatures
>
> etc... I'm not on a machine where I can test this, I imagine it doesn't
> work, and there is already the already-working "MyPair" solution above.
> still here is where I was going-
>
> use Tuple;
>
> sub x(--> Tuple[Bool,Str]) {
>     my Str $s = "hello";
>     my Bool $b = True;
>     tuple($b, $s);
> }
>
> say x;
>
> -y
>
>
> On Mon, Oct 27, 2025 at 11:57 AM William Michels <[email protected]>
> wrote:
>
>> Wow Tom!
>>
>> I had to correct one line (`my Str $s = "foo";`),
>>
>> then got this return:
>>
>> `MyPair.new(b => Bool::True, s => "foo")`
>>
>> Very cool!
>>
>> Best, Bill.
>>
>> On Oct 27, 2025, at 07:02, Tom Browder <[email protected]> wrote:
>>
>> I don't think you can do what you want exactly. But I certainly may be
>> wrong!
>>
>> Using a pair may do the trick, but my Pair foo outside a Hash is weak.
>>
>> The other way around it is to do something like this I use often:
>>
>> class MyPair {
>>     has Bool $.b;
>>     has Str $.s;
>> }
>>
>> sub x(--> MyPair) {
>>     my Bool $b = True;
>>     my Str = "foo";
>>     my $obj = MyPair.new(:$b,:$s);
>>    $obj;
>> }
>>
>> say x; # OUTPUT
>>
>> On Mon, Oct 27, 2025 at 05:34 ToddAndMargo via perl6-users <
>> [email protected]> wrote:
>>
>>> On 10/27/25 3:13 AM, Tom Browder wrote:
>>> > On Sun, Oct 26, 2025 at 19:46 ToddAndMargo via perl6-users <perl6-
>>> > [email protected] <mailto:[email protected]>> wrote:
>>> >
>>> >     Hi All,
>>> >
>>> >     What am I doing wrong here?  I want
>>> >     two things in my "returns".
>>> >
>>> >
>>> >     [2] > sub x() returns Bool,Str {}
>>> >     ===SORRY!=== Error while compiling:
>>> >     Missing block
>>> >     ------> sub x() returns Bool⏏,Str {}
>>> >           expecting any of:
>>> >               new name to be defined
>>> >
>>> >     Yours in confusion,
>>> >     -T
>>> >
>>> >
>>> > Return a List of a defined Bool and Str:
>>> >
>>> > sub x(--> List) {
>>> >      my Str $s = "hello";
>>> >      my Bool $b = True;
>>> >      $b, $s;
>>> > }
>>> >
>>> > say x;
>>> > OUTPUT: (True hello)
>>> >
>>> > -Tom
>>>
>>> Hi Tom,
>>>
>>> Dang.  List does not tell me what they are.
>>>
>>> Thank you for the help.
>>>
>>> -T
>>>
>>
>>

Reply via email to