ssues/3807)
but unfortunately none of us has done so yet :( That issue does link to a
several blog
posts that explain the new coercion protocol – you might find those useful and
you or
anyone else might also be able to adapt them into a great doc PR.
-codesections
Thanks Daniel and Liz. I can t
of us has done so yet :( That issue does link to a
several blog
posts that explain the new coercion protocol – you might find those useful and
you or
anyone else might also be able to adapt them into a great doc PR.
-codesections
It is being tested in Roast, so I'd say it's not really that experimental
anymore :-)
> On 11 Feb 2022, at 15:20, Marcel Timmerman wrote:
>
> Hi,
>
> I stumbled over a discussion between Raku developers on
> "Raku/proplem-solving" issue 227 "Coer
Hi,
I stumbled over a discussion between Raku developers on
"Raku/proplem-solving" issue 227 "Coercion reconsidered and unified" and
I saw something interesting about coercion. Without much knowledge I
started to experiment with a method called COERCE(). This ended
su
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 for
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
Re-opening this, as there's a much more common case where a typecheck of the
coercion result would be desired and that's when coercion results in a Failure:
m: multi sub foo(Int() $) { }; foo Inf
rakudo-moar 5a6ff4073: ( no output )
Re-opening this, as there's a much more common case where a typecheck of the
coercion result would be desired and that's when coercion results in a Failure:
m: multi sub foo(Int() $) { }; foo Inf
rakudo-moar 5a6ff4073: ( no output )
https://github.com/rakudo/rakudo/issues/1361 has been fixed back in February
2018.
All three code snippets from this issue are failing with
X::Syntax::Variable::BadType now.
I've added a test to S12-coercion/coercion-types.t with commit
https://github.com/perl6/roast/commit/7fcc804bb9.
On Fri, 16 Mar 2018 16:02:15 -0700, jan-olof.hen...@bredband.net wrote:
> On Tue, 30 Aug 2016 16:30:24 -0700, allber...@gmail.com wrote:
> > I think the problem is that there's already another syntax using that
> > sequence: coercion types. FF(FF(2)) is being parsed as a co
On Tue, 30 Aug 2016 16:30:24 -0700, allber...@gmail.com wrote:
> I think the problem is that there's already another syntax using that
> sequence: coercion types. FF(FF(2)) is being parsed as a coercion type from
> FF to FF(... and then it falls over because it's not expectin
On Wed, 14 Mar 2018 14:16:06 -0700, comdog wrote:
> I was playing with coercion types and wondered what would happen if
> a .Int method did not return the right sort of type:
>
> class Foo {
> method Int ( --> Str ) { 'Hello' }
> }
>
>
On Wed, 14 Mar 2018 14:16:06 -0700, comdog wrote:
> I was playing with coercion types and wondered what would happen if
> a .Int method did not return the right sort of type:
>
> class Foo {
> method Int ( --> Str ) { 'Hello' }
> }
>
>
# New Ticket Created by "brian d foy"
# Please include the string: [perl #132980]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=132980 >
I was playing with coercion types and wondered what would happen if
a .I
On Wed, 17 Jan 2018 15:48:31 -0800, c...@zoffix.com wrote:
> On Sun, 01 Jan 2017 09:06:32 -0800, dougljenk...@gmail.com wrote:
> > I would expect this code to ignore the conversion of $foo if no value is
> > passed for it.
> >
> > $ perl6 -e 'sub (Int(Cool) :$foo){}()'
> >
> > Use of uninitialize
On Wed, 17 Jan 2018 15:48:31 -0800, c...@zoffix.com wrote:
> On Sun, 01 Jan 2017 09:06:32 -0800, dougljenk...@gmail.com wrote:
> > I would expect this code to ignore the conversion of $foo if no value is
> > passed for it.
> >
> > $ perl6 -e 'sub (Int(Cool) :$foo){}()'
> >
> > Use of uninitialize
On Sun, 01 Jan 2017 09:06:32 -0800, dougljenk...@gmail.com wrote:
> I would expect this code to ignore the conversion of $foo if no value is
> passed for it.
>
> $ perl6 -e 'sub (Int(Cool) :$foo){}()'
>
> Use of uninitialized value of type Cool in numeric context
> in sub at -e line 1
>
> IRC
On Sun, 01 Jan 2017 09:06:32 -0800, dougljenk...@gmail.com wrote:
> I would expect this code to ignore the conversion of $foo if no value is
> passed for it.
>
> $ perl6 -e 'sub (Int(Cool) :$foo){}()'
>
> Use of uninitialized value of type Cool in numeric context
> in sub at -e line 1
>
> IRC
# New Ticket Created by Christian Bartolomaeus
# Please include the string: [perl #132694]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=132694 >
On the JVM backend the coercion type returned from .keyof for a
regular h
On Fri, 23 Oct 2015 03:29:12 -0700, elizabeth wrote:
> [12:14:56] m: sub a(Int:D() $a) { dd $a }; a "42" #
> type smileys not complete first citizen yet :-(
> [12:14:57] <+camelia> rakudo-moar 3df263: OUTPUT«Type check failed
> in binding $a; expected Int but got Str in sub a at
> /tmp/b
On Fri, 23 Oct 2015 03:29:12 -0700, elizabeth wrote:
> [12:14:56] m: sub a(Int:D() $a) { dd $a }; a "42" #
> type smileys not complete first citizen yet :-(
> [12:14:57] <+camelia> rakudo-moar 3df263: OUTPUT«Type check failed
> in binding $a; expected Int but got Str in sub a at
> /tmp/b
de75: OUTPUT«ONOES»
> (10:20:59 AM) jnthn: Bah, I knew somebody would try that :P
> (10:21:03 AM) vendethiel: *g*
> (10:21:31 AM) jnthn: I only did coercion types so far sufficient that
> we could migrate away from the deprecated "as" in sigs.
> (10:21:50 AM) jnthn: That one s
On Fri, 23 Oct 2015 03:29:12 -0700, elizabeth wrote:
> [12:14:56] m: sub a(Int:D() $a) { dd $a }; a "42" #
> type smileys not complete first citizen yet :-(
> [12:14:57] <+camelia> rakudo-moar 3df263: OUTPUT«Type check failed
> in binding $a; expected Int but got Str in sub a at
> /tmp/b
On Sat, 03 Jun 2017 21:20:49 -0700, c...@zoffix.com wrote:
> (found in discussion in
> https://rt.perl.org/Ticket/Display.html?id=131493 )
>
>
> We have some special casing for coercion of allomorphs in some
> instances, which
> is done so there'd be some way to for
On Sat, 03 Jun 2017 21:20:49 -0700, c...@zoffix.com wrote:
> (found in discussion in
> https://rt.perl.org/Ticket/Display.html?id=131493 )
>
>
> We have some special casing for coercion of allomorphs in some
> instances, which
> is done so there'd be some way to for
ave some special casing for coercion of allomorphs in some instances, which
is done so there'd be some way to force one of the two types to fall out of it,
since we have types where to whom object identity matters a bunch:
m: <1>.Str.^name.say
rakudo-moar 7344a3: OUTPUT: «Str»
e latter ones fail to detect use of coercion and don't complain, but don't
coerce either.
18:43 Zoffix m: class { has Int() $.x = '42'}.new.x
18:43 camelia rakudo-moar fb7dd8: OUTPUT: «5===SORRY!5=== Error while
compiling Coercion Int(Any) is insufficiently type
# New Ticket Created by Douglas Jenkins
# Please include the string: [perl #130479]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=130479 >
I would expect this code to ignore the conversion of $foo if no value is
passed for it
(Apologies if this appears twice.)
I was told on IRC to report this as an NYI.
https://irclog.perlgeek.de/perl6/2016-12-03#i_13674766
Thanks,
- Michael
On 6-Dec-16 17:36, Will Coleda via RT wrote:
On Sat, 03 Dec 2016 11:31:59 -0800, pe...@mscha.org wrote:
Coercion type works quite nicely in signatures, e.g.
sub foo(Int(Cool) $f) {
say $f.WHAT;
}
foo "42";# (Int)
but it doesn't work yet in variab
On Sat, 03 Dec 2016 11:31:59 -0800, pe...@mscha.org wrote:
> Coercion type works quite nicely in signatures, e.g.
>
> sub foo(Int(Cool) $f) {
> say $f.WHAT;
> }
> foo "42";# (Int)
>
> but it doesn't work yet in variable declarati
# New Ticket Created by Michael Schaap
# Please include the string: [perl #130253]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=130253 >
Coercion type works quite nicely in signatures, e.g.
sub foo(Int(Cool)
S13-overloading.pod
Log Message:
---
Be more specific about coercion being a convention
Fixed in https://github.com/rakudo/rakudo/commit/b508576fc5
Tests added in https://github.com/perl6/roast/commit/dedfdf91e7
I think the problem is that there's already another syntax using that
sequence: coercion types. FF(FF(2)) is being parsed as a coercion type from
FF to FF(... and then it falls over because it's not expecting nested
coercion types.
On Tue, Aug 30, 2016 at 7:13 PM, Brian S. Julin &l
# New Ticket Created by "Brian S. Julin"
# Please include the string: [perl #129142]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=129142 >
$ perl6 -e 'enum FF ; FF(2).perl.say'
FF::two
$ perl6 -e 'enum FF ; FF(FF::two).per
# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #128964]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=128964 >
m: sub a( --> Str() ) { 42 }; dd a # should this work ?
rakudo-mo
773
> ($a * (2e0**51)) % 1e0
0
> $a.FatRat.perl
FatRat.new(11, 10)
The Num->FatRat conversion is being performed inexactly. Every finite
Num value is in fact rational, and therefore exactly representable as a
FatRat, so I would expect the coercion to preserve the value exactly.
It
# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #126433]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=126433 >
[12:14:56] m: sub a(Int:D() $a) { dd $a }; a "42" # type smileys
not compl
{ "OHAI".say
}; multi method foo($a) { "ONOES".say }; }; g[Int(Str)].new.foo("100")
(10:19:09 AM) camelia: rakudo-moar 35de75: OUTPUT«ONOES»
(10:20:59 AM) jnthn: Bah, I knew somebody would try that :P
(10:21:03 AM) vendethiel: *g*
(10:21:31 AM) jnthn: I only did coe
:
M S32-setting-library/IO.pod
Log Message:
---
Some doc tweaks, mostly related to coercion
This segfault is gone, also:
$ perl6-p
> my Int $x = NaN;
Type check failed in assignment to '$x'; expected 'Int' but got 'Num'
> ^D
$
$ perl6-p --version
This is perl6 version 2015.01-60-g12db81b built on parrot 7.0.1 revision
RELEASE_7_0_1
So the same question as in ticket 115322: Is this c
# New Ticket Created by Zefram
# Please include the string: [perl #120484]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=120484 >
I tried a test case from [perl #61602] in Rakudo and got this:
$ perl6
> my Int $x = NaN
Type
-bits.pod
Log Message:
---
clobber 'as' returns; use coercion types instead
-data.pod
Log Message:
---
[S09] fix coercion syntax usage, TimToady++
-bits.pod
Log Message:
---
define coercion types, value/impl types better
We were using two different meanings of "value type", so now
value vs implementation type is "of" type vs "container" type.
We also now have a coercive type syntax, so there'
On Fri Jun 05 08:11:56 2009, jn...@jnthn.net wrote:
> of is done, so renaming to just have "as"
"as" is done too now, so renaming to the empty string. :-P
(Resolving ticket. moritz++ says we have some tests for "as" already in
t/spec/S06-traits/as.t)
On Fri Jun 05 08:11:56 2009, jn...@jnthn.net wrote:
> of is done, so renaming to just have "as"
"as" is done too now, so renaming to the empty string. :-P
(Resolving ticket. moritz++ says we have some tests for "as" already in
t/spec/S06-traits/as.t)
# New Ticket Created by Richard Hainsworth
# Please include the string: [perl #74638]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=74638 >
from #perl6 Apr 24
this works:
rakudo: class B {has @.a;has $.u;method m { for $.
# New Ticket Created by [EMAIL PROTECTED]
# Please include the string: [perl #58022]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=58022 >
On Mon, Mar 05, 2007 at 09:22:59AM -0800, Dave Whipp wrote:
: I was wondering about the semantics of coercion of non-numbers, so I
: experimented with the interactive Pugs on feather:
:
: pugs> +"42"
: 42.0
: pugs> +"x42"
: 0.0
:
: I assume that pugs is assuming &q
I was wondering about the semantics of coercion of non-numbers, so I
experimented with the interactive Pugs on feather:
pugs> +"42"
42.0
pugs> +"x42"
0.0
I assume that pugs is assuming "no fail" in the interactive environment.
However, Is "0.0&qu
gabriele renzi <[EMAIL PROTECTED]> writes:
> Steffen Schwigon ha scritto:
>> I looked at [1]. What's the purpose of "multi" in this case?
>> (Maybe you wanted to write it as more than one subs, did you?)
>
> look the comment:
>
> # Yet, it should be possible to define it even for commutative rings
shed. Type constraints were syntactically accepted but worked
similar to typeless code in Perl5. I'm not sure about the current
state.
I see
Anyway, in your example I hadn't expected a value coercion (from 10.1
to 10), but something like an error if the type doesn't match.
this
ccepted but worked
similar to typeless code in Perl5. I'm not sure about the current
state.
Anyway, in your example I hadn't expected a value coercion (from 10.1
to 10), but something like an error if the type doesn't match. But I
can't find the right place in the synopses to ver
Hi everyone!
I solved the (easy) problem 32, implementing gcd($a,$b).
You can check the code in the repository or on the web[1]
But while writing this I noticed that a function written as
sub gcd(Int $a, Int $b)
still accepts float/rational values in input.
I think I read once that a variable
Jonathan Scott Duff wrote:
I hope you're way off the mark. Automatic coercion was one of the
annoyances I remember from C++. Debugging becomes more difficult when
you have to not only chase down things that are a Foo, but anything
you've compiled that might know how to turn itself
From: Jonathan Scott Duff <[EMAIL PROTECTED]>
Date: Sat, 30 Sep 2006 17:23:54 -0500
On Sat, Sep 30, 2006 at 11:48:04AM -0700, Joshua Choi wrote:
> How does automatic coercion work?
[ deletia ]
> 1. C automatically coerces its C arguments into C
> param
On Sat, Sep 30, 2006 at 11:48:04AM -0700, Joshua Choi wrote:
> How does automatic coercion work?
[ deletia ]
> 1. C automatically coerces its C arguments into C
> parameters because C.
> 2. C then automatically coerces its C arguments into
> C parameters because C.
>
> ...O
My understanding is that "does" will prevent coercion. In particular,
it is erroneous to say that 'Str does Num' or that 'Num does Str'.
If you say 'Foo does Bar', what this means is that anything Bar can
do, Foo can do, too. As such, any routine that as
Kudos to all(@Larry)!
How does automatic coercion work? Like, when a routine wants a
parameter of a certain type, and is called with an argument of a
different type that C
(For instance, is it something a little like this?
multi sum ( Num $addend1, Num $addend2 --> Num ) { ... }
multi
On Mon, Apr 03, 2006 at 08:24:51PM -0700, Larry Wall wrote:
: There's some discussion about whether it should simply be:
:
: method as (Str) {...}
: method as (Int) {...}
:
: maybe with an "is deep" thrown in for good measure, but we haven't
: quite got there yet.
Er, to have multiple of
On Mon, Apr 03, 2006 at 07:23:28PM -0700, Joshua Choi wrote:
: Kudos to all on the Perl 6 mailing list,
:
: What's the conceptual difference (or relationship) between context and type
: coercion? Is
: $moose.prefix:<~>
: the same as
: $moose.coerce:(Str)
: for instance?
No
Kudos to all on the Perl 6 mailing list,
What's the conceptual difference (or relationship) between context and type
coercion? Is
$moose.prefix:<~>
the same as
$moose.coerce:(Str)
for instance?
And forgive my brain, but how would you nicely define coercion in a class?
Like
(More brain dump.)
"Context" is implemented as type coercion calls, implicitly inserted
by the compiler.
There are five types used in these calls. The "..." below denote
the positions where these contexts typically occur, using common
Perl 5 operations as
On Wed, 14 Sep 2005, Luke Palmer wrote:
my Int $int = $num;
Explicit coercion, however, isn't done with context: it is done with the
.as() method: $num.as(Int). I think that's weird.
Not to mention the fact that you might have put an Int there for
typechecking purposes instead o
Luke Palmer skribis 2005-09-14 22:21 (+):
> (conversely, is ~ just a Str context applicator?)?
Yes, the way I think of it is that ~ is short for Str(), + is short for
Num(), and ? is short for Bool().
> If a parent class defines a coercion operation, do you get it too
> (and wha
otion that is often misused. Use .does
instead; that's what you mean anyway (unless you're snooping around
the guts of an object).
> my Int $int = $num;
>
> Explicit coercion, however, isn't done with context: it is done with the
> .as() method: $num.as(Int). I think that
I was asked to { Verb 'p6l' } the idea of types providing context, and
well, here it is.
(We got at these thoughts from a discussion of a hypothetic lexical pragma
to disable automatic coercion, which I thought was a bad idea because
that's practically to ignore context, Perl'
69 matches
Mail list logo