Re: Automatic coercion and context

2006-10-01 Thread Jonathan Lang
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 into a Foo. O

Re: Automatic coercion and context

2006-09-30 Thread Bob Rogers
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 > parameters because C. Wouldn

Re: Automatic coercion and context

2006-09-30 Thread Jonathan Scott Duff
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. > > ...Or am I completely off t

Re: Automatic coercion and context

2006-09-30 Thread Jonathan Lang
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 asks for a Bar can just as easily be given

Automatic coercion and context

2006-09-30 Thread Joshua Choi
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 say ( S

Re: coercion and context

2005-09-14 Thread Dave Rolsky
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 of coersion pur

Re: coercion and context

2005-09-14 Thread Juerd
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 what are the imp

Re: coercion and context

2005-09-14 Thread Luke Palmer
On 9/14/05, Juerd <[EMAIL PROTECTED]> wrote: > Instead, if you don't want something to coerce, be explicit: > $foo.does(Blah) or fail;, or even: $foo.isa(Blah) or fail;.) We've been thinking of changing .isa to something longer, or a method on .meta, because it's a notion that is often misused. U

coercion and context

2005-09-14 Thread Juerd
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's strongest language