Re: New type Stash for Block is not a mixin type

2020-09-28 Thread Fernando Santagata
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

Re: New type Stash for Block is not a mixin type

2020-09-26 Thread Fernando Santagata
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

Re: New type Stash for Block is not a mixin type

2020-09-24 Thread Elizabeth Mattijsen
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

New type Stash for Block is not a mixin type

2020-09-24 Thread Fernando Santagata
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

Re: subs and the type system

2020-07-21 Thread Theo van den Heuvel
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

Re: subs and the type system

2020-07-20 Thread Tobias Boege
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

Re: subs and the type system

2020-07-20 Thread Gianni Ceccarelli
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

Re: subs and the type system

2020-07-20 Thread Theo van den Heuvel
: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

Re: subs and the type system

2020-07-20 Thread Tobias Boege
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,

Re: subs and the type system

2020-07-20 Thread Gianni Ceccarelli
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

subs and the type system

2020-07-20 Thread Theo van den Heuvel
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

Re: cannot create an instance of subset type

2020-07-11 Thread Ben Davies
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.

Re: cannot create an instance of subset type

2020-07-11 Thread Elizabeth Mattijsen
> 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

Re: cannot create an instance of subset type

2020-07-11 Thread Marcel Timmerman
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

Re: cannot create an instance of subset type

2020-07-10 Thread Brad Gilbert
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

cannot create an instance of subset type

2020-07-10 Thread Marcel Timmerman
an instance of this type (DEF)   in block at xt/subset-test.pl6 line 15 Why is this? Regards, Marcel

No such method 'prefix' for invocant of type 'Capture' when trying to patch a new library include path

2020-05-10 Thread Konrad Bucheli via perl6-users
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

Re: Changing the error message from subset type violation

2020-01-12 Thread yary
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

Changing the error message from subset type violation

2020-01-12 Thread Joseph Brenner
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

Re: type?

2020-01-09 Thread ToddAndMargo via perl6-users
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

Re: type?

2020-01-09 Thread Elizabeth Mattijsen
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

Re: type?

2020-01-09 Thread ToddAndMargo via perl6-users
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

Re: type?

2020-01-09 Thread Elizabeth Mattijsen
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

Re: type?

2020-01-09 Thread ToddAndMargo via perl6-users
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

Re: type?

2020-01-08 Thread WFB
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 >

type?

2020-01-08 Thread ToddAndMargo via perl6-users
Hi All, Is there a way to ask a variable what "type" it is? Many thanks, -T

Re: implicit type change

2019-12-08 Thread Elizabeth Mattijsen
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

Re: implicit type change

2019-12-08 Thread Marcel Timmerman
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

Re: implicit type change

2019-12-08 Thread Marcel Timmerman
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

Re: implicit type change

2019-12-08 Thread Elizabeth Mattijsen
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

Re: implicit type change

2019-12-08 Thread Fernando Santagata
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

implicit type change

2019-12-08 Thread Marcel Timmerman
: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

RE: FW: Type name limit?

2019-08-14 Thread Mark Devine
# 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

Re: FW: Type name limit?

2019-08-14 Thread yary
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

Type name limit?

2019-08-13 Thread Mark Devine
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

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-21 Thread Timo Paulssen
> 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

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-21 Thread Timo Paulssen
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

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-21 Thread Parrot Raiser
> 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.

Re: Exactly what is type match?

2018-12-21 Thread Laurent Rosenfeld via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread JJ Merelo
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

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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!!

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread Laurent Rosenfeld via perl6-users
: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, &

Re: Exactly what is type match?

2018-12-20 Thread Laurent Rosenfeld via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Re: Exactly what is type match?

2018-12-20 Thread Will Coleda
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

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
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

Re: Diamond <> or fileinput-like input handling (was Re: what type $in,$out and $err is)

2018-11-10 Thread yary
- 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

Diamond <> or fileinput-like input handling (was Re: what type $in,$out and $err is)

2018-11-05 Thread Trey Harris
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

Re: what type $in,$out and $err is

2018-11-05 Thread Ralph Mellor
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

Re: what type $in,$out and $err is

2018-11-01 Thread Ralph Mellor
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

Re: what type $in,$out and $err is

2018-10-28 Thread Brad Gilbert
"-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

Re: what type $in,$out and $err is

2018-10-28 Thread Brandon Allbery
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

what type $in,$out and $err is

2018-10-28 Thread Xiao Yafeng
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

Coercion/type checking: manually reproduce Perl6 standards

2018-09-01 Thread Vadim Belman
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

Re: How to deriving own distinguish type from Int?

2017-05-31 Thread Elizabeth Mattijsen
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

How to deriving own distinguish type from Int?

2017-05-31 Thread cle-perl6
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

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-28 Thread Brandon Allbery
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

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-28 Thread Francesco Rivetti
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.

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread Richard Hainsworth
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

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread ToddAndMargo
> 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

Re: Am I suppose to be able to change a variable's type on the fly?

2017-03-22 Thread Brad Gilbert
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

Am I suppose to be able to change a variable's type on the fly?

2017-03-21 Thread ToddAndMargo
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

Algebraic Data Type module for perl6

2013-04-01 Thread Timo Paulssen
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

Re: very basic type checking

2010-06-30 Thread Darren Duncan
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

Re: very basic type checking

2010-06-25 Thread Moritz Lenz
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

Re: very basic type checking

2010-06-24 Thread Jan Ingvoldstad
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

Re: very basic type checking

2010-06-24 Thread yary
; 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?

Re: very basic type checking

2010-06-24 Thread Darren Duncan
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

Re: very basic type checking

2010-06-23 Thread Darren Duncan
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