On Fri, 29 Apr 2005, Brent 'Dax' Royal-Gordon wrote:
David Storrs <[EMAIL PROTECTED]> wrote:On Thu, Apr 28, 2005 at 03:28:41PM +0200, Ingo Blechschmidt wrote:so we had junctions of Code references some days ago, what's with junctions of Class and Role objects? :)
Could we see some code that shows why this is a good idea? My initial reaction is horror; I can very easily see huge numbers of subtle, hard-to-reproduce bugs coming out of this. On the other hand, I do not immediately see major applications...most of what I can see is things that reduce the amount of code needed, but don't actually accomplish anything fundamentally new. What do junctions of Class|Role objects give us that can't be achieved in other ways?
I'm quite willing to believe that there are such things, but I'm not coming up with them.
What do you think this is?
sub foo(Str | Int $bar) { ... }
I believe you mean sub foo(Str^Int $bar){...} ( something that is Int or Str but not both). But that, too, just reduces the amount of code and is merely a shortcut for:
multi sub(Str $bar){...}
multi sub(Int $bar){...}
I do not see how any auto-threading occurs in that code. It is completely innocuous in that sense, and I don't think that is what horrified David. What was troublesome was, I think:
my Str|Int $x;
$x.foo(); # runs two methods and returns a junction
I would like to be able to read the above code to mean: type X ::= Scalar where Str|Int; my X $x; # $x = non int/non string now a runtime error $x.foo(); # no different from if you had just said my $x
Feel free to tell me I am barking up the wrong tree if that is what I am doing.
--abhijit