Welcome the channel on the development of Cro, a set of libraries for building reactive distributed systems, lovingly crafted to take advantage of all the Raku Programming Language has to offer (cro.services). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
01:00 summerisle left 01:01 summerisle joined 02:58 summerisle left 03:02 summerisle joined 08:40 Xliff joined
Xliff If I have a sub with a signature like <:sub a ($text, :$n = 1)>, can I set $n in a template like this: <&a(n => 2)> ? 09:44
jnthn Well, you'd need to pass an argument for $text too, since that's not optional, and I think only colonpair syntax is supported 09:47
Xliff Ah! Thanks for that. 09:56
Next question :) 09:57
What's the best way to iterate when you only have the number of iterations stored in a variable?
Is the <@^$v> syntax supported?
jnthn No. Dunno how you'd do that with iteration. Can write it as a recursive function, though :) 09:59
Although I'd probably just send a Range into the template data instead of the number 10:00
Xliff Yeah, was thinking that. Was hoping to keep that solely in the template.
Thanks for the idea though. 10:01
I'll see if I can shoehorn that into the template language and submit a PR.
That will be in my copious free time, however.
Which is a complete lie.
jnthn I...don't really like that syntax, fwiw
Xliff Which would you prefer? 10:02
jnthn Dunno. Maybe a more general <@{ ... }> form a bit like the <?{ ... }> form 10:03
Xliff So...
<@{1..3}> ?
<@{$s..$e}> ?
jnthn Yeah. I don't even mind the ^$s inside of there, tbh
Xliff OK... so as long as it evals to a range inside the curlies? 10:04
jnthn Yeah
Xliff I should be able to work with that.
jnthn Well, I mean, it can do anything in the curlies really
Xliff Will keep you posted.
jnthn So it's 1) support having an expression in curlies, like with `?` and `!` sigil tags, 2) add range operators to the expression language 10:05
Xliff Yeah. Something like that.
jnthn Then it's neat for e.g. <@{ .some-cond ?? .some-array !! .some-other-array }> or similar 10:06
Xliff Yep. And value check would test that expression would evaluate to Iterable or throw? 10:08
Array will. Range will. 10:09
jnthn Don't think we need to; Raku doesn't 10:13
Xliff OK
jnthn (the "item is a 1-item list in such a context" rule)
Xliff jnthn: Thanks for the recusion solution. It was simple enough to implement. 10:19
jnthn: Is there any way to create a Signature object from another Signature? 11:47
lizmat Xliff: apart from .clone ? 11:48
Xliff No. 11:50
I was able to come up with this...
m: 1.say
Oh.. No bot here.
sub a ("a", "b", $c, :$d) { }; Signature.new( params => &a.signature.params[1..*] ).gist.say
The reason why I am asking, is that I am looking for ways to simplify application creation. 11:51
I'd like to set up a controller class that has controllers as the methods.
Then have the route block create the routes from the signatures of all marked methods.,
methods would be (METHOD, ...) where ... is the route
And METHOD, in this case is GET, POST, DELETE and such. 11:52
jnthn You might want to look at the OpenAPI::RoutesFromDefinition module that does something kinda similar with route handlers being partly synthesized from other things 12:51
Xliff jnthn: Ah! Thanks! 13:14
18:18 lizmat left 18:21 lizmat joined
Xliff in RakuAST, If I want to create a Parameter from a literal, can I still use StrLiteral, or do I need a ParameterTarget? 18:50
The examples aren't quite clear on that.
18:53 n1to joined 19:24 jjatria left, jdv left 19:25 jdv joined 19:31 jjatria joined 20:44 summerisle is now known as eof 21:59 n1to left