00:05
librasteve_ left
05:25
kjp left
05:27
kjp joined
05:36
kjp left
05:37
kjp joined
05:46
kjp left
05:47
kjp joined
05:49
kjp left
05:50
kjp joined,
kjp left
05:51
kjp joined,
kjp left,
kjp joined
08:00
jaguart joined
08:01
jaguart left,
jaguart joined
|
|||
winfredraj | Hello all | 11:38 | |
What does the *% stand for in function arguments?? | |||
*%_ to be exact | 11:39 | ||
I'm trying to use the from-xml function in XML::Class and it seems like this argument is also required | 11:40 | ||
multi method from-xml(XML::Class:U: Str $xml) returns XML::Class multi method from-xml(XML::Class:U: XML::Document:D $xml) returns XML::Class multi method from-xml(XML::Class:U: XML::Element:D $xml) returns XML::Class | 11:42 | ||
cdn.discordapp.com/attachments/768...20222& | |||
jaguart | the docs are here: docs.raku.org/type/Method#index-en...arguments) | ||
winfredraj | Thanks jaguart | 11:43 | |
jaguart | effectively a sig of *%_ means the sub only has optional named args - no positionals | 11:44 | |
looks like you need to pass in a Str, an XML::Document, or an XML::Element and method dispatch will call the appropriate method | 11:58 | ||
winfredraj | I did pass a string (XML string) | 12:04 | |
In fact I passed the same string that was created by the to-xml sub for the class | 12:05 | ||
jaguart | weird - if you `say $xml.^name;` can you confirm the type of the XML String? | 12:11 | |
winfredraj | It seems to expect the filename as string | 12:30 | |
But that did not help as the parse failed by XML::Grammar.parse | 12:31 | ||
So rummaging in XML::Grammar in repl, but the parse is not working | 12:32 | ||
cdn.discordapp.com/attachments/768...6a963& | 12:33 | ||
This was created by to-xml sub from the class | |||
Can't check with LibXML::Class as I am working on Android | 12:39 | ||
jaguart | Haven't used XML::Class - are you doing something like: `my $str = $foo.to-xml(); my $bar = $foo->from-xml($str)` to get a copy of Foo in $bar? | 12:40 | |
winfredraj | Ja something like that but saving it in file and reading it | 12:45 | |
from-xml($str) seems to expect a filename for $str and not a string with XML | 12:46 | ||
cdn.discordapp.com/attachments/768...f9b74& | 12:48 | ||
I'll check in Linux with LibXML once I land, in a flight now and don't have a lot of options | 12:49 | ||
jaguart | XML::Document will accept a Str or IO::Path - why don't you just `dd`` the actual input you are sending in | 12:51 | |
winfredraj | Let me give it a shot | 12:53 | |
I'll get the IO:Path out as the data member in the class, that looks suspect to me | 12:59 | ||
14:01
jgaz joined
|
|||
greenfork | m: unit sub MAIN (); CATCH { default { .payload.say } }; die "Dead"; | 16:23 | |
camelia | Dead in sub MAIN at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
greenfork | Do you know why I can't use CATCH in unit sub MAIN? | 16:24 | |
Here the output should have been just "Dead" | |||
jaguart | is it because the CATCH / die are not within a block? | 16:28 | |
m: sub MAIN () { CATCH { default { "Oops".say ; } }; die "Dead"; } | |||
camelia | Oops | ||
greenfork | So how do I put it in a block? Or I can't use "unit sub" in this case? | 16:33 | |
Top-level example also works without any blocks | 16:34 | ||
m: CATCH { default { "Oops".say ; } }; die "Dead"; | |||
camelia | Oops | ||
jaguart | m: unit sub MAIN() { CATCH { default { "Oops".say ; } }; die "Dead"; } | 16:36 | |
camelia | Oops | ||
jaguart | its inconsistent - but if you just make your sub body a block it seems to do what you want. | 16:37 | |
greenfork | Yep, works for me, thank you! | 16:38 | |
17:04
jgaz left
18:06
jaguart left
22:00
teatime joined
|