🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
tbrowder hi, i would like to define some cirumfix operators that would only work if both operands were class objects of the same class. is that possible? example for multiplication: $a = A.new; $b = A.new; $c = $a * $b 17:54
*circumfix
where $c is shiny new object of class A 17:55
*a shiny
lizmat m: sub a(::T $a where !*.defined, T $b where !*.defined) { dd :$a:$b }; a Int, Int 17:57
camelia :a(Int)
:b(Int)
tbrowder my use case is extending core capability of handling real numbers up to base 36
lizmat m: sub a(::T $a where !*.defined, T $b where !*.defined) { dd :$a:$b }; a Int, Str
camelia Type check failed in binding to parameter '$b'; expected Int but got Str (Str)
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat sadly ::T:U syntax is not supported atm
tbrowder ok, then i can work around the but a bit uglier 17:58
just wanted to make sure i wasn't missing something 17:59
extending to base 91
can't think of a practical reason, but interesting thanks to Wolfram and Wikipedia 18:01
and other sources
tbrowder so now to name a typical method for operator *: "multiply-by", or "times" or ? 18:09
it wll have to have 2 inputs: number, and base 18:10
or another class object
sdomi what's the state-of-the-art HTTP server library / web framework as of right now? 18:26
i'm considering writing my own as an excercise with learning Raku, just wanted to see the prior art :)
(for context: this is my Bash web framework git.sakamoto.pl/laudom/HTTP.sh/ - whatever I end up writing in Raku would probably end up similar in spirit to this) 18:27
tbrowder sdomi: sounds cool to me, but i can't offer and 18:29
*any advice
sdomi thanks anyways :p
tbrowder can anyone help , 18:30
*help me understand diff between "type smileys"? to me the docs don't show the diff between :D and :U for a user class arg 18:32
sdomi tbrowder: can you link to the relevant page? I'm curious now 18:40
[Coke] Those in particular are defined, undefined.
like 1 vs Int
docs.raku.org/language/glossary#Type_smiley links to docs.raku.org/language/signatures#...finiteness 18:41
To recap, here is a quick illustration of these type constraints, also known collectively as type smileys: 18:42
(look for that text on the last page, it's got a bunch of code samples)
tbrowder so i have an object of my class A, i should use: sub foo(A:D $a) {...} to ensure i have the "right stuff" 19:13
the problem with those code samples is it seems to only contrast raku core things 19:15
so the subtleties get in the way
thnx [Coke] 19:19
m: class F {has $.n=1}; my $a = 1; my $b = F.new; sub f(F:D $a) {}; f($a); f($b) 19:23
camelia Type check failed in binding to parameter '$a'; expected F but got Int (1)
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
tbrowder i now think the term 'binding' is part of my confusion. 19:24
le
let me look at the docs again...what would be the purpose of a :U smiley if the arg were undefined? 19:27
a practical example, that is. would it mean "accept anything but the named object? 19:31
m: class F {has $.n=1;}; my $a = 1; sub f(F:U $a) {}; f($a); 19:39
camelia Type check failed in binding to parameter '$a'; expected F but got Int (1)
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
tbrowder m: class F {}; my $a = F.new; sub f(F:U $a) {}; f($a) 19:44
camelia Parameter '$a' of routine 'f' must be a type object of type 'F', not an
object instance of type 'F'. Did you forget a 'multi'?
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
tbrowder that's the confusion in my brain, is there a type object of F? 19:46
outside the core type definitions, is there a use for such in my own class type? hm, maybe in the methods? 19:49
TWEAK? 19:51
Voldenet practical example would be undefined value handling 20:20
erm, unassigned value
m: class F {}; my F $f; my F $f2 .= new; multi sub f(F:U) { "F:U" }; multi sub f(F:D) { "F:D" }; say (f($f), f($f2));
camelia (F:U F:D)
Voldenet sdomi: Cro, Bailador, Humming-Bird 20:31
sdomi Voldenet: thank you! 20:33
rir [tbrowder] I believe the only special aspect of CORE classes is that they automatically exist. 20:38
librasteve sdomi: there have been some requests for a Cro middleware module that does HTTP(S) cacheing - just mentioning in case you want to make something that we will grab and use ;-) 20:43
sdomi: btw Bailador is pretty much dead --- Hummingbird is less amibitious that Cro, kind of simple and fast basic option, Cro is more extensive and more capable - both have had relatively recent releases 20:45
sdomi i see! 20:46
no clue how much spoons I actually have for exploring Raku, tried it a year ago, got really excited, but my energy ran out after a few days of fiddling 20:47
(learning absolutely new systems is hard, wouldn't you know...)
librasteve yeah - picking up a language and a web framework is a lot to do together ... 20:51
you may want to check out github.com/librasteve/raku-HTMX-Examples - the main branch has all the HTMX examples done with regular Cro templates and the fragments branch has examples rewritten using the new Cro template fragments feature 20:52
sdomi neat, this will be helpful :) thank you 20:54
librasteve HTMX is very cool for non JS web scaffolds like Cro since it enables a dynamic UX with all the code on the server side 20:55
sdomi yup, i've heard of it before, haven't had a chance to use it yet (but it sounds really cool) 20:56
generally most of my recent web projects are entirely void of JS, just forms and a lot of clever CSS
librasteve hi o/ ... I have a class MyPage {...} and a sub sub mypage(*@a, *%h) { MyPage.new( |@a, |%h ) }; that lets me use the class in a functional context - I would like to generalize this as a class trait, lets say is subbed ... please can someone point me to an example / docs or how to do that with the MOP?? 23:07
(must sleep - will check back in 8 hours !) 23:07