# New Ticket Created by  Elizabeth Mattijsen 
# Please include the string:  [perl #126050]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126050 >



[23:19:47]  <lizmat>    m: sub a { .Int with $^a }; a(Str).perl.say  # somehow 
I expect this to say Str instead of ()
[23:19:48]  <+camelia>  rakudo-moar 0d47a4: OUTPUT«()␤»
[23:21:29]  <vendethiel>        m: say Str.Int.perl
[23:21:29]  <+camelia>  rakudo-moar 0d47a4: OUTPUT«Invocant requires an 
instance of type Str, but a type object was passed.  Did you forget a .new?␤  
in block <unit> at /tmp/yFKn3e0pMl:1␤␤»
[23:22:10]  <vendethiel>        lizmat: the "with" is not traversed, that's 
correct, right? I don't think it should return its operand in the other case
[23:23:37]  <lizmat>    vendethiel: I was thinking about this: 
[23:23:41]  <lizmat>    .lines(:close, |c) with self.open(|c)
[23:23:59]  <lizmat>    if the open fails, I would like to see it returned 
[23:23:59]  <vendethiel>        lizmat: wouldn't .given be more useful there?
[23:24:11]  <lizmat>    .given ???
[23:24:20]  <vendethiel>        uhm. I mean given{} :P
[23:24:31]  <vendethiel>        well, I guess you could invent a .given...
[23:25:20]  <lizmat>    given self.open(|c) { .... and then ?
[23:27:20]  <vendethiel>        lizmat: you can "cling onto" the result with it 
(and just end the block with $_ I guess). But I was actually thinking of some 
closing mechanism (python-like "with"), so disregard my comment
[23:28:43]  <lizmat>    I think .method with $a returning the value of $a if 
not defined, would be a useful idiom
[23:29:08]  <vendethiel>        lizmat: seems a bit like andthen, in some way, 
maybe?
[23:29:35]  <vendethiel>        m: say Str andthen .Int
[23:29:36]  <+camelia>  rakudo-moar 655a45: OUTPUT«(Str)␤»
[23:29:41]  <vendethiel>        m: say "3" andthen .Int
[23:29:42]  <+camelia>  rakudo-moar 655a45: OUTPUT«3␤»
[23:31:09]  <lizmat>    vendethiel++
[23:32:23]  <lizmat>    m: sub a { $^a andthen .Int }; a(Str).perl.say; 
a(42).perl.say   # still not quite what I want :-(
[23:32:24]  <+camelia>  rakudo-moar 655a45: OUTPUT«()␤42␤»
[23:32:43]  vendethiel  wats
[23:33:03]  <vendethiel>        m: sub a { say $^a.perl; $^a }; a(Str).perl.say
[23:33:03]  <+camelia>  rakudo-moar 655a45: OUTPUT«Str␤Str␤»
[23:33:14]  <vendethiel>        m: sub a { say $^a.perl; $^a andthen 1 }; 
a(Str).perl.say
[23:33:15]  <+camelia>  rakudo-moar 655a45: OUTPUT«Str␤()␤»
[23:33:32]  <lizmat>    bug?
[23:33:38]  <vendethiel>        m: sub a { say $^a.perl; say $^a andthen 1 }; 
a(Str).perl
[23:33:38]  <+camelia>  rakudo-moar 655a45: OUTPUT«Str␤(Str)␤»
[23:33:47]  <vendethiel>        lizmat: ...looks like a part of it isn't 
returned? idk
[23:33:53]  <vendethiel>        m: sub a { say $^a.perl; return $^a andthen 1 
}; a(Str).perl.say
[23:33:53]  <+camelia>  rakudo-moar 655a45: OUTPUT«Str␤Str␤»
[23:33:56]  <vendethiel>        lizmat: ^
[23:33:58]  <vendethiel>        seems like a bug
[23:34:17]  <lizmat>    m: sub a { return $^a andthen .Int }; a(Str).perl.say; 
a(42).perl.say
[23:34:18]  <+camelia>  rakudo-moar 655a45: OUTPUT«Str␤42␤»
[23:34:20]  <lizmat>    aha...
[23:34:22]  <lizmat>    bug indeed
[23:34:36]  <vendethiel>        lizmat++ # golfing

Reply via email to