01:00 sibl joined
simon_sibl if I give -p and a command, so like iowrap -p pwd I get permission denied (address: 127.0.0.1:True) but the type of $port is subset UInt so Bool shouldnt work: glot.io/snippets/hfi61lum8w 02:48
02:56 Nemokosch joined
Nemokosch m: say Bool ~~ UInt 02:56
camelia True
Nemokosch Or is it
02:57 arkiuat left 03:00 sibl left 03:01 Nemokosch left, sibl joined 03:05 arkiuat joined 03:10 arkiuat left 03:14 arkiuat joined 03:22 sibl left, sibl joined
simon_sibl so..what should I do to avoid this ? 03:24
what kind of weird type thingy is happening so that Bool ~~ UInt is True xD
nemokosch as they say: somebody ought to do something 03:25
the cheap way out would be to say that ultimately it doesn't seem like you need to run the command this exact way 03:27
m: say "hooray, no need to go to IRC" 03:28
Raku eval hooray, no need to go to IRC
nemokosch alright
m: say True.Int
Raku eval 1
nemokosch so I guess that would be the second way: screw booleans passing the type check, force the type 03:29
turn False and True into 0 and 1
the third way would be to hunt them down and potentially force the error
hm, how do I mock the input within a one-off, I forgot 03:31
m: dd <True False 1 2>
Raku eval ("True", "False", IntStr.new(1, "1"), IntStr.new(2, "2"))
nemokosch they don't even turn into those values inside <> lol 03:32
m: say 'does this work?' 03:33
Raku eval does this work?
nemokosch great
m: @*ARGS = <-p pwd>; sub MAIN(:p($port) = 8888, *@rest) { die 'This is silly...' if $port === True|False; } 03:34
Raku eval Exit code: 1 This is silly... in sub MAIN at main.raku line 3 in block <unit> at main.raku line 1
nemokosch m: @*ARGS = <-p 444 pwd>; sub MAIN(:p($port) = 8888, *@rest) { die 'This is silly...' if $port === True|False; say "Your beautiful port of choice is $port."; }
Raku eval Exit code: 1 This is silly... in sub MAIN at main.raku line 3 in block <unit> at main.raku line 1
nemokosch this is indeed silly 03:35
m: @*ARGS = <-p=444 pwd>; sub MAIN(:p($port) = 8888, *@rest) { die 'This is silly...' if $port === True|False; say "Your beautiful port of choice is $port."; }
Raku eval Your beautiful port of choice is 444.
simon_sibl crazy right ?
nemokosch I don't think it helps with this particular thing but I highly recommend Getopt::Long
it makes CLI parsing much saner 03:36
you don't need to do anything, just include it
courtesy of leont
simon_sibl yeah, used it a lot for perl, just not sure to understand why Raku's builtin argument parsing is getting broke because of some type thingy 03:37
nemokosch ah no, in this case it's the type system itself that is arguably broken 03:38
-p parses as p being passed as True, so far so good
but True is kind of 1, but also not quite
simon_sibl yeah yeah, I meant, the argument parsing is getting broke because of the type system that is doing something weird 03:39
nemokosch now I wonder if we get IntStr out of an integer-looking argument
simon_sibl I am close to using Str as argument for the Port xD 03:40
nemokosch m: @*ARGS = <a b 23 d>; sub MAIN(@values) { .&dd for @values; }
Raku eval Exit code: 2 Usage: main.raku <values>
nemokosch and what exactly are these, if not values, bro
m: @*ARGS = 23; sub MAIN($value) { dd $value; } 03:41
Raku eval Exit code: 1 This type cannot unbox to a native string: P6opaque, Int in block <unit> at main.raku line 1
nemokosch quite original but okay, I was kind of begging for it 03:42
@*ARGS = '23'; sub MAIN($value) { dd $value; }
oops
m: @*ARGS = '23'; sub MAIN($value) { dd $value; }
Raku eval IntStr.new(23, "23")
nemokosch okay, so it IS an IntStr
@simon_sibl now let me show you something funny
m: @*ARGS = '0'; sub MAIN(Str $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } } 03:44
Raku eval Please type something...
simon_sibl why
what
nemokosch passed the Str constraint, at which point you'd think that it's good to go
you'd think it's not empty
simon_sibl m: @*ARGS = '0'; sub MAIN(IntStr $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } } 03:45
Raku eval Please type something...
simon_sibl ???
nemokosch m: @*ARGS = '0.0'; sub MAIN(IntStr $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Exit code: 2 Usage: main.raku <answer>
nemokosch oops, one sec 03:46
m: @*ARGS = '0.0'; sub MAIN(RatStr $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Please type something...
nemokosch does this help?
simon_sibl but why it doesnt work ? 03:47
nemokosch m: @*ARGS = '-0.0'; sub MAIN(RatStr $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Exit code: 2 Usage: main.raku <answer>
nemokosch I guess this failed to parse
simon_sibl m: @*ARGS = '0'; sub MAIN(Str $answer) { say $answer.raku; dd $answer; if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval IntStr.new(0, "0") Please type something... IntStr.new(0, "0")
nemokosch so this I think was a very bad idea 03:48
as you can see, this is a value that tries to act simultaneously as an Int and a Str
simon_sibl oooh I see
its 0 so False yeah
nemokosch of course this creates a diamond problem
simon_sibl I get it I get it
nemokosch and the boolification of Int takes priority
simon_sibl m: @*ARGS = '5'; sub MAIN(IntStr $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Congratulations, your answer was: 5.
simon_sibl but yeah for the Str one, its strange 03:49
m: @*ARGS = '00'; sub MAIN(Str $answer) { if $answer { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
nemokosch also, as far as I remember, these values pass coercive type checks, yet their Str coercion is not an identity
Raku eval Please type something...
simon_sibl I guess the right way is m: @*ARGS = '0'; sub MAIN(IntStr $answer) { if $answer.defined { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } } 03:50
m: @*ARGS = '0'; sub MAIN(IntStr $answer) { if $answer.defined { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Congratulations, your answer was: 0.
nemokosch m: @*ARGS = ''; sub MAIN($answer) { if $answer.defined { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } } 03:51
Raku eval Congratulations, your answer was: .
nemokosch too bad
I think this should work with IntStr as well actually
m: @*ARGS = ''; sub MAIN(IntStr $answer) { if $answer.defined { say "Congratulations, your answer was: $answer."; } else { say "Please type something..."; } }
Raku eval Congratulations, your answer was: .
nemokosch what is the solution? Well, in my opinion, the solution would be to eventually retire these as much as possible 03:52
simon_sibl but yeah, for the Port to Bool, not sure how I can enforce that
nemokosch Bool shouldn't derive from integer, allomorphs shouldn't exist
simon_sibl can be practical sometimes I guess, but here it bites xD 03:53
nemokosch I have grown to really dislike the rhetorics about "practical". "Practical" usually means nothing else than "it helps me save 5 keystrokes and feel clever about it"
simon_sibl isnt that the whole point of Perl and Raku ? 🫣 šŸ˜† 03:54
nemokosch unfortunately it is but I don't think it has to be
you know the saying "easy things [should be] easy and hard things possible" 03:55
simon_sibl yep
easy thing is here indeed, not easy 03:56
nemokosch because of the issues we have been checking in this sesh, I rephrased it as "easy things are impossible"
you get these middle-ground things that are often outright impossible to ignore or opt out of
simon_sibl so what brought you to Raku ? 03:57
nemokosch "easy thing" would be to just get a bunch of strings
and be able to decide on the parsing yourself
I wrote a lot of small one-off scripts at my previous workplace, a lot of them for text processing, also shelling out a lot to Unix built-ins 03:58
so the situation was: Bash I think is a crime against humanity which I'm barely willing to even read
on the other hand, Python often had more visual overhead than the effective part of the script 03:59
simon_sibl and Perl vs Raku ?
nemokosch I more or less coincidentally chose Raku because that's the new(er) thing that I was curious about for some time 04:00
it looks a bit more like a programming language, too - this was especially true a few years back
nowadays I have a lot of respect for the people who actually use the language, as in, more than as a calculator or a handy string processor - it's almost like they are the future generation lol 04:04
I'm more interested in Raku as a project, be it language design, implementation or marketing; not like I'm an expert at any of these 04:05
simon_sibl I like Raku a lot, if that was not for those quirks and the speed, would be perfect to me 04:06
I can make shorter and more readable code in Raku than my colleagues using Python but then the benchmarks just kill me šŸ˜†
nemokosch right? it's not like the language has no redeeming qualities, there is a certain addictive factor to it 04:07
simon_sibl it just feels so cumbersome to write in other languages for me now 04:08
when I go back to Perl, Python, feels so slow to write so much boilerplate
nemokosch I like to write Prolog for recreational purposes these days, it's a different kind of challenge 04:10
it certainly has its own type of boilerplate with the bajillion of intermediate variables
simon_sibl I am gonna try pascal, if its a nice language and can easily make cross platform gui, I am all in xD 04:13
nemokosch Pascal was my first language
I find it quite elegant for a fairly low-level language 04:14
easy cross platform gui - wish granted, the Lazarus VCL is exactly that
actually, I'm a patron of Castle Game Engine to this day - never used it though xD 04:15
these days I'm mostly working for Ada, although might need to hop on another project soon 04:16
now Ada is like Pascal written by some lawyer
very redundant, very wordy, deliberately annoying, almost like the design principle was that you focus more when you're under stress 04:17
one develops a kind of Stockholm syndrome with Ada
I mean, it's fairly intelligent design compared to Go
Go is much like Ada without stressing C developers too much 04:18
simon_sibl but Ada is much safer than Go
nemokosch Ada is clearly not meant to be pleasant to use
simon_sibl can easily dereference a null pointer in Go, or have race conditions
nemokosch that they cannot be accused with,...
I wish it was harder to dereference a null pointer in Ada95 04:19
of course to some extent it's the system's fault
it's a bit like Greenspun's tenth rule
there is a lot of dynamism implemented with raw pointers 04:20
and then they complain whenever there is a panic
Ada is - or at least was up to the 95 revision - more like, make it hard to cause harm but never outright banning you from it 04:22
visibility, accessibility, modularity concepts were great 04:23
clearly a lot of thought went into those
anyway, Raku is like candy, it's the kind of drug that has an immediate and seemingly light-hearted influence on you if you are prone to it 04:25
Ada is like, I don't know, your strict teacher who always tells you that they want what's best for you but somehow it still hurts
xdd 04:26
simon_sibl I found a way for the Port
subset Port where { .Int ~~ 0..65535 and $_.WHAT !~~ Bool|List };
nemokosch every interaction is like a bit of conversion
simon_sibl dont ask me why it becomes a List
if I only put Bool in there, it becomes a List
xD
nemokosch if you define the same argument multiple times in the CLI, I think that's when it can become a list 04:27
simon_sibl actually this seems to work:
subset Port where { .Int ~~ 0..65535 and $_.WHAT ~~ IntStr };
ok it doesnt, unless I put 8888 as '8888' 04:28
ok even '8888' doesnt work with IntStr 04:29
šŸ’„
well !~~ Bool|List it is 🫠 04:30
reminds me of rust
nemokosch Rust has certain properties that are clearly reflected in the community 04:31
it is viral - it only works well when interacting with other Rust code
and it has a certain opinionated purist view that it strictly enforces with the compiler 04:32
no surprise that a large part of the users are more like believers of the language than users of it
simon_sibl Yeah, strong believer 🄲 04:50
Meanwhile the kernel QR code error module is alsways messed up 04:51
Bsod rust module
05:19 human_blip left 05:20 human_blip joined 05:28 arkiuat left
subset Host of Str; subset Port of UInt where { .Int ~~ 0..65535 and $_ !~~ Bool }; unit sub MAIN( Host :b(:$bind) = '127.0.0.1', #= Bind to this address Port :p(:$port) = 8888, #= Bind to this port Bool :d(:$debug) = False, #= Show debug messages *@cmd, #= Command to run ); this works well 05:49
06:30 atcroft left 06:31 atcroft joined 08:24 sibl left 08:26 sibl joined 09:09 dakkar joined 10:08 sibl left 11:57 sergot left 12:02 librasteve_ joined 14:56 arkiuat joined 17:35 arkiuat left 17:38 dakkar left 17:46 arkiuat joined 17:50 arkiuat left 18:20 arkiuat joined 18:25 arkiuat left 18:35 arkiuat joined
arkiuat I added a comment to issue 504 re the introduction of Cool behavior to div and mod that apparently inspired the 2024.02 "breakage" github.com/Raku/problem-solving/is...3853342543 19:19
whoops, wrong channel! 19:20
20:56 arkiuat left 21:13 arkiuat joined
librasteve @simon_sibl ... this is somewhat late to the party, but docs.raku.org/assets/typegraphs/Int.svg shows that class Bool is Int ...I think that the use of 0 and 1 to represent False and True is a deep historic reflection of C and perl 21:55
nemokosch are all (numeric) enums integers? 22:01
lizmat they don't need to be, but generally are 22:44
nemokosch so to ask the runtime directly 22:46
m: enum Choice<this that>; say Choice ~~ Int
Raku eval True
nemokosch (True)
lizmat m: num A (a => 3.14, b => 6.28); dd A ~~ Rat; dd A ~~ Int 23:06
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> num<HERE> A (a => 3.14, b => 6.28); dd A ~~ Rat;
expecting any of:
infix
infix stopper
statement end
statement modifier…
lizmat m: enum A (a => 3.14, b => 6.28); dd A ~~ Rat; dd A ~~ Int
camelia Bool::True
Bool::False
lizmat on that note: 23:07
m: enum A (a => 3.14, b => 6) # that's an LTA error
camelia ===SORRY!===
Incompatible MROs in P6opaque rebless for types Int and A