a weird problem. I have
>> a module like this:
>> >
>> > unit class Class1;
>> > etc.
>> >
>> > Then a second module:
>> >
>> > unit class Class2;
>> > use Class1;
>> > etc.
>> >
>> > In a program I need
t; >
> > In a program I need both modules, so it begins with two lines:
> >
> > use Class1;
> > use Class2;
> > etc.
> >
> > At this point if I run the program I get this error:
> >
> > New type Stash for Block is not a mixin type
> &g
hen a second module:
>
> unit class Class2;
> use Class1;
> etc.
>
> In a program I need both modules, so it begins with two lines:
>
> use Class1;
> use Class2;
> etc.
>
> At this point if I run the program I get this error:
>
> New type Stash for Bloc
run the program I get this error:
New type Stash for Block is not a mixin type
pointing to the line of code that uses Class2. If I remove the "use Class1"
line, that program works fine.
But it bugs me, because I don't understand that behavior.
Any hint?
The whole thing worked fine usi
reef op 2020-07-20 14:00:
On Mon, 20 Jul 2020, Theo van den Heuvel wrote:
Hi gurus,
after looking at the documentation on Sub, Signature and the raku type
system I find myself unable to constrain the types of functions in the
way I
think I need.
The situation: I have a function, let's call in
er
> types and covariant in the return type (i.e. if the caller passes a
> Numeric, the callback should accept a Numeric or a *more general*
> type, and if the caller expects a Numeric back, the callback should
> return a Numeric or a *more specific* type).
>
> But then ``:(Numeric $ --&g
On Mon, 20 Jul 2020 14:00:33 +0200
Tobias Boege wrote:
> You cannot write `Walkable ` in the signature of because the
> combination of a type and the &-sigil apparently means that ``
> should be Callable and return a Walkable. That's why I use the
> $-sigil.
Aha! That's the
:00:
On Mon, 20 Jul 2020, Theo van den Heuvel wrote:
Hi gurus,
after looking at the documentation on Sub, Signature and the raku type
system I find myself unable to constrain the types of functions in the
way I
think I need.
The situation: I have a function, let's call in 'walker', whose fi
On Mon, 20 Jul 2020, Theo van den Heuvel wrote:
> Hi gurus,
>
> after looking at the documentation on Sub, Signature and the raku type
> system I find myself unable to constrain the types of functions in the way I
> think I need.
>
> The situation: I have a function,
On Mon, 20 Jul 2020 12:37:33 +0200
Theo van den Heuvel wrote:
> The situation: I have a function, let's call in 'walker', whose first
> parameter is a callback.
> I wish to express that only callbacks with a certain Signature and
> return type are acceptable.
> Let's say the
Hi gurus,
after looking at the documentation on Sub, Signature and the raku type
system I find myself unable to constrain the types of functions in the
way I think I need.
The situation: I have a function, let's call in 'walker', whose first
parameter is a callback.
I wish to express
It looks like you're trying to create an alias for a type. I'd use a
constant for this, not a subset, for reasons Brad has already explained.
Your code runs fine for me when DEF is written like my constant DEF = ABC.
> On 10 Jul 2020, at 23:37, Brad Gilbert wrote:
> I honestly think that there is an argument to be made that it shouldn't even
> be possible to write a `subset` without a `where` clause.
Making the "where" clause non-optional, is remarkably simple: removing a '?'
However, there appear to be
On 2020-07-10 23:37, Brad Gilbert wrote:
Subset types are not object types.
A subset is basically a bit of checking code and base type associated
with a new type name.
In something like:
my ABC $a .= new;
That is exactly the same as:
my ABC $a = ABC.new;
Well
Subset types are not object types.
A subset is basically a bit of checking code and base type associated with
a new type name.
In something like:
my ABC $a .= new;
That is exactly the same as:
my ABC $a = ABC.new;
Well there is no functional `.new` method on any subset types, so
an instance of this type (DEF)
in block at xt/subset-test.pl6 line 15
Why is this?
Regards,
Marcel
cat foo.rakumod
unit module foo;
use Test;
$ raku -I . -e "use foo"
===SORRY!=== Error while compiling -e
===SORRY!=== Error while compiling /home/kb/foo.rakumod (foo)
No such method 'prefix' for invocant of type 'Capture'
at /home/kb/foo.rakumod (foo):2
at -e:1
$
Interestingly
As I was next to you in today's Raku gathering, I came up with this as a
sort-of answer. Not very happy with it but it gets partway there.
#!/usr/bin/env perl6
use v6.d;
## Simple version to check membership, but the type error won't tell which
strings
# subset Critter of Str where any
ed
$thingie = 'nada'; # fails as expected, with message:
# Type check failed in assignment to $thingie; expected Monster but
got Str ("nada")
I was wondering if there's some way to replace that error message
with a better one. If there's only a half dozen allowed values
I'd want
On 2020-01-09 07:38, Elizabeth Mattijsen wrote:
Argh. Indeed, you can't.
say int32.^name; # int32
You can only find out the name of the type,*not* when you used that type to
create a variable. Because that is just a value in memory*without* a specific
type. To be able to call
Argh. Indeed, you can't.
say int32.^name; # int32
You can only find out the name of the type, *not* when you used that type to
create a variable. Because that is just a value in memory *without* a specific
type. To be able to call a method on it, it needs to be ugraded to its object
On 9 Jan 2020, at 15:50, ToddAndMargo via perl6-users
wrote:
Any way to get WHAT to tell me specifically that it
is an int32?
my int32 $j=0x45; say $j.WHAT
(Int)
-T
On 2020-01-09 07:04, Elizabeth Mattijsen wrote:
> my int32 $a; say $a.^name; # int32
>
Hi Elizabeth,
Now what am I
Thu, 9 Jan 2020 at 03:58, ToddAndMargo via perl6-users
>> mailto:perl6-users@perl.org>> wrote:
>> Hi All,
>> Is there a way to ask a variable what "type" it is?
>>Many thanks,
>>-T
>
>
> Hi W,
>
> Sweet. Thank
On 2020-01-08 23:06, WFB wrote:
Hi Todd,
dd or .WHAT will give you that information.
dd $i;
say $i.WHAT;
Greetings
On Thu, 9 Jan 2020 at 03:58, ToddAndMargo via perl6-users
mailto:perl6-users@perl.org>> wrote:
Hi All,
Is there a way to ask a variable what
Hi Todd,
dd or .WHAT will give you that information.
dd $i;
say $i.WHAT;
Greetings
On Thu, 9 Jan 2020 at 03:58, ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:
> Hi All,
>
> Is there a way to ask a variable what "type" it is?
>
> Many thanks,
> -T
>
Hi All,
Is there a way to ask a variable what "type" it is?
Many thanks,
-T
t;
>>>
>>>> use NativeCall
>>>> my CArray[byte] $ba .= new( 255, 254, 3, 4);
>>> NativeCall::Types::CArray[byte].new
>>>> $ba[0].WHAT
>>> (Int)
>>>> $ba[0..*-1]
>>> (-1 -2 3 4)
>>>
>>>
>>> This means (for me) that there is an implicit type conversion from unsigned
>>> to signed integer and it is not possible to use positive numbers only,
>>> afterwards.
>>>
>>> Regards,
>>> Marcel
the following (REPL)
use NativeCall
my CArray[byte] $ba .= new( 255, 254, 3, 4);
NativeCall::Types::CArray[byte].new
$ba[0].WHAT
(Int)
$ba[0..*-1]
(-1 -2 3 4)
This means (for me) that there is an implicit type conversion from unsigned to
signed integer and it is not possible to use p
This means (for me) that there is an implicit type conversion from
unsigned to signed integer and it is not possible to use positive
numbers only, afterwards.
Regards,
Marcel
--
Fernando Santagata
L)
>
>
> > use NativeCall
> > my CArray[byte] $ba .= new( 255, 254, 3, 4);
> NativeCall::Types::CArray[byte].new
> > $ba[0].WHAT
> (Int)
> > $ba[0..*-1]
> (-1 -2 3 4)
>
>
> This means (for me) that there is an implicit type conversion from unsigne
o the following (REPL)
>
>
> > use NativeCall
> > my CArray[byte] $ba .= new( 255, 254, 3, 4);
> NativeCall::Types::CArray[byte].new
> > $ba[0].WHAT
> (Int)
> > $ba[0..*-1]
> (-1 -2 3 4)
>
>
> This means (for me) that there is an implicit type conv
:Types::CArray[byte].new
> $ba[0].WHAT
(Int)
> $ba[0..*-1]
(-1 -2 3 4)
This means (for me) that there is an implicit type conversion from
unsigned to signed integer and it is not possible to use positive
numbers only, afterwards.
Regards,
Marcel
# delete 46 chars from
‘need’, ‘has’ type, and assignment type
* ~/bin/ManagedSystems#
good compile, expected results
When I fold the module higher up in the hierarchy like the above, it
compiles/executes successfully. I’m stumped.
Thanks,
Mark
longest & 2nd longest) fail to compile with:
>
>
>
> ===SORRY!===
>
> Type
> 'Hypervisor::IBM::POWER::HMC::ManagedSystems::ManagedSystem::EnergyManagementConfiguration'
> is not declared
>
> at /home/mdevine/
> github.com/perl6-Hypervisor-IBM-POWER-HMC/lib/Hypervi
This is Rakudo version 2019.07.1 built on MoarVM version 2019.07.1 implementing
Perl 6.d.
Is there a type “name” size limit in Perl 6/Rakudo/Moar?
I’ve been making a hierarchy of classes to take in a > 4MB XML file, and I
found it organized & convenient to use the names of the e
On 12/21/18 12:28 PM, ToddAndMargo via perl6-users wrote:
On 12/21/18 12:13 PM, Timo Paulssen wrote:
Like this? > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{
(<:N>+) [.] >
(\d+)}; $D0 ~= $0; $D1 ~= $1; print "$D0 $D1\n";' > > 11 2 >
There's an important difference between "$D1
On 12/21/18 12:13 PM, Timo Paulssen wrote:
Like this? > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] >
(\d+)}; $D0 ~= $0; $D1 ~= $1; print "$D0 $D1\n";' > > 11 2 >
There's an important difference between "$D1 ~= $0" and "$D1 = ~$0".
They only do the same thing if $D0
> Like this? > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+)
> [.] >
(\d+)}; $D0 ~= $0; $D1 ~= $1; print "$D0 $D1\n";' > > 11 2 >
There's an important difference between "$D1 ~= $0" and "$D1 = ~$0".
They only do the same thing if $D0 (and $D1) are empty at that point; if
they
xpression "$D1 ~ $1" in sink context (line 1)
Useless use of "~" in expression "$D0 ~$0" in sink context (line 1)
Use of uninitialized value of type Str in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to
something meaningful.
in bl
On 12/20/18 10:32 PM, JJ Merelo wrote:
I didn't think I needed to answer a question that can be so easily
obtained from the documentation: https://docs.perl6.org/type/Match,
which, unsurprisingly, says: "|Match| objects are the result of a
successful regex match"
That
quot;$D1 ~ $1" in sink context (line 1)
> Useless use of "~" in expression "$D0 ~$0" in sink context (line 1)
> Use of uninitialized value of type Str in string context.
> Methods .^name, .perl, .gist, or .say can be used to stringify it to
> something meaningful.
> in blo
ot;$D1 ~ $1" in sink context (line 1)
Useless use of "~" in expression "$D0 ~$0" in sink context (line 1)
Use of uninitialized value of type Str in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to
something meaningful.
in block at -e li
> If you get a crash using it, I suspect you made another mistake somewhere.
Possibly a compiler version difference? A perl6 -v output might be
worth including.
You're free to use a Str method call if you prefer, but using the ~ to
stringify $0 and the like works perfectly for me in perl -e ... context.
$ perl6 -e' "abc" ~~ /.(\w)./; put $0.perl; my $c = ~$0; put $c;'
Match.new(list => (), made => Any, pos => 2, hash => Map.new(()), orig =>
"abc", from
El jue., 20 dic. 2018 a las 23:17, ToddAndMargo via perl6-users (<
perl6-users@perl.org>) escribió:
> >> El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> escribió:
> >>
> >> Hi All,
> >>
&g
On 12/20/18 3:51 PM, ToddAndMargo via perl6-users wrote:
On 12/20/18 2:49 PM, Laurent Rosenfeld via perl6-users wrote:
JJ Merelo accurately responded
Absolutely. He just did not answer the question I asked.
JJ make a mistake? The earth would wobble on its access!!
chuckle: Axis
On 12/20/18 2:49 PM, Laurent Rosenfeld via perl6-users wrote:
JJ Merelo accurately responded
Absolutely. He just did not answer the question I asked.
JJ make a mistake? The earth would wobble on its access!!
instantly recognize .Str when I look at it.
What initially confused me was thinking that the match would
take on the type of what it matched. (<\N>+) would look
for number like characters, so a string and (\d+) would
look for digits, so an integer. Woops! Good thing I
asked.
Thank you for all the help!
-T
On 12/20/18 2:59 PM, Laurent Rosenfeld via perl6-users wrote:
$0 /does /work with "perl6 -e" if you use correctly the tilde ~
operator. For example:
$ perl6 -e ' "abc" ~~ /.(\w)./; say ~$0;'
b
This is because "say" is also a converter. My issue
is when assigning to another variable that
:17 PM ToddAndMargo via perl6-users
> >> wrote:
> >>>
> >>>>> El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users
> >>>>> mailto:perl6-users@perl.org>> escribió:
> >>>>>
> >>>>> Hi All,
&
Match is a class defining the type of the objects that you get (for example
in variable $/) when a regex match is successful or through regex captures
into $0, $1, etc. or into named captures.
JJ Merelo accurately responded that such objects can be coerced into
strings with the tilde ~ prefix
On Thu, Dec 20, 2018 at 5:17 PM ToddAndMargo via perl6-users
wrote:
El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users
mailto:perl6-users@perl.org>> escribió:
Hi All,
Exactly what is type "Match"?
Here I want $D0..$D3 to only be strings. And it thro
s AST (abstract syntax tree), which can be used to build
data structures from complex regexes and grammars." -
https://docs.perl6.org/type/Match
When you say $0, you're using the Match. If you want the Str version,
explicitly cast it to Str with:
~$0
or
$0.Str
Regards.
On Thu, Dec 20, 2018
El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users
mailto:perl6-users@perl.org>> escribió:
Hi All,
Exactly what is type "Match"?
Here I want $D0..$D3 to only be strings. And it throws a match error.
$ p6 'my $x="11.2.3.4"; my Str $D0; my S
Hi All,
Exactly what is type "Match"?
Here I want $D0..$D3 to only be strings. And it throws a match error.
$ p6 'my $x="11.2.3.4"; my Str $D0; my Str $D1; my Str $D2; my Str $D3;
$x~~m{ (<:N>) [.] (\d+) [.] (\d+) [.] (\d+) }; $D0 = $0; $D1 = $1; $D2 =
$2; $D3 = $3
-
see IO::CatHandle type if you need old behaviour
( Isn't "CatHandle" just a long way of writing "tail" ? :-o )
https://docs.perl6.org/type/IO::CatHandle - Its constructor accepts a list
of strings as filenames ... because IO::Handle is responsible for
converting strings (Coo
mean different things (that simply happen to semantically overlap
frequently):
- In <https://docs.perl6.org/routine/open>, use of '-' indicates $*IN
or $*OUT for read-only or write-only uses respectively.
- In Proc <https://docs.perl6.org/type/Proc>, the default of '-'
indi
On Sun, Oct 28, 2018 at 7:26 PM Xiao Yafeng wrote:
> Besides, just curious, why choose '_' as default it looks strange
>
Turns out it's deprecated in 6.d:
https://marketing.perl6.org/id/1541379592/pdf_digital
On Sun, Oct 28, 2018 at 7:26 PM Xiao Yafeng wrote:
> I'm curious about what type of $in is on Proc class.
`$in` isn't "on `Proc` class".
`$in` is a *parameter* of the `.new` *method*.
> I mean, if $in is IO::Pipe object
As a *parameter* of the `.new` method *decla
"-n", in => $in, out => $out;
run "cat", "-n", :in($in), :out($out);
---
Basically that is a way to indicate that you are actually interested
in those filehandles,
and for the routine to set them up for you.
On Sun, Oct 28, 2018 at 2:26 PM Xiao Yafeng wro
It takes Any — and quite a few more things than are currently documented,
like IIRC filenames, and looks at the actual type passed to decide what to
do with it.
On Sun, Oct 28, 2018 at 3:31 PM Xiao Yafeng wrote:
> I'm curious about what type of $in is on Proc class. As described in
> pe
I'm curious about what type of $in is on Proc class. As described in perl6doc:
$in, $out and $err are the three standard streams of the
to-be-launched program, and default to "-" meaning they inherit the
stream from the parent process. Setting one (or more) of them to True
makes
Hi everybody,
I'm just transferring here a StackOverflow topic
https://stackoverflow.com/questions/52117678/coercion-type-checking-manually-reproduce-perl6-standards
because what was a question over there turned immediately into a discussion
which doesn't fit into SO format. Not sure if I
ossibility. I
> am used to dynamical typed languages like Perl 5, Ruby, Python ... you name
> it. But I am very fond of strong static typing especially if it comes with
> automatic type inference like in languages like OCaml, Go and recently C++
> since 2011. But I like languages li
very fond of strong static typing
especially if it comes with automatic type inference like in languages
like OCaml, Go and recently C++ since 2011. But I like languages like
Ada too :-)
Now I would like to define two datatypes in Perl 6 deriving from `Int`
but being incompatible with `Int
On Tue, Mar 28, 2017 at 3:09 AM, Francesco Rivetti <o...@oha.it> wrote:
> you don't change the type of a variable. instead you use a type which is
> "broader" and accept any object type.
This; and if you didn't specify a type, the type is Any. Which is not quite
the
On 22. mars 2017 06:59, ToddAndMargo wrote:
So, unless I specifically declare a variable as a
particular type, I can change its "type" on the fly.
you don't change the type of a variable. instead you use a type which is
"broader" and accept any object type.
e.g.
I think the strict answer to 'Is it correct?' is 'No'.
The point being that 'my $x' gives $x type 'Any'.
But practically, having type Any allows for $x to be assigned any value,
be it Str, Int etc.
So 'practically' the answer to 'Is it correct?' is 'Yes'.
On Wednesday, March 22, 2017 02:07
> On Wed, Mar 22, 2017 at 12:59 AM, ToddAndMargo
<toddandma...@zoho.com> wrote:
>> Hi All,
>>
>> Yes, I know, Perl is "lexiconical".
>>
>> $ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";'
>> 1e+23
>>
>> $ perl
The default type constraint is Mu, with a default of Any (everything
is of type Mu, and most are of type Any)
You shouldn't be able to change the type constraint of a scalar
container (used for rw variables)
Changing the type of a value, of course makes no sense. (a Str is
always a Str, even
Hi All,
Yes, I know, Perl is "lexiconical".
$ perl6 -e 'my $x="abc"; $x=1E23; print "$x\n";'
1e+23
$ perl6 -e 'my Str $x="abc"; $x=1E23; print "$x\n";'
Type check failed in assignment to $x; expected Str
but got Num (1e+23) in block at -e li
gist
automatically by supplying a haskell-like declaration of the data type.
(skip to the end of the mail for the code)
Here's what it can do:
my %res = create_adt(Tree = Branch Tree left, Tree right | Leaf Str
storage);
my \Tree = %resTree;
# create the tree with named parameters
Moritz Lenz wrote:
But I fear that optimizations are a risky business, considering our
rather low test coverage (and considering that we don't really know how
much of our code paths are actually covered by tests).
In that case, perhaps Rakudo should have a config or compile-time (of Rakudo
redefiniton of the Str type
Since the + is implemented as a multi sub, it can't just know the return
type, but it has to execute the 2 + 3 at compile time (constant folding)
to find the type of the return value.
That is why the specification doesn't mandate a minimum level of type
inference
On Wed, Jun 23, 2010 at 20:21, Darren Duncan dar...@darrenduncan.netwrote:
If all invocations of myop use a code literal for the $y argument, then
this can be checked at compile time, but if the argument is a variable, they
have to look further out.
Yup.
For those who don't quite see what
;
not failing at compile time, the question was about
my Int $i='abc';
or how about
sub square(Int $n='o hai');
Would it be wrong for the cut-off point be after an immediate assignment/
declaration of a built-in type to a literal constant? Or does even checking
that at compile time lead to headache?
yary wrote:
Yes but- the OP wasn't asking about
my Str $s;
my Int $i=$s;
not failing at compile time, the question was about
my Int $i='abc';
or how about
sub square(Int $n='o hai');
Would it be wrong for the cut-off point be after an immediate assignment/
declaration of a built-in type
Hiroki Horiuchi wrote:
My question is:
In current Rakudo,
my Int $i = '123';
causes a runtime error, not a compile time error.
How about in future Perl 6?
Generally speaking, in a dynamic language like Perl 6, one has to do the type
checking at runtime anyway, because we don't always have
78 matches
Mail list logo