This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
02:39 razetime joined 03:32 razetime left 07:00 siavash joined 07:57 siavash left 07:59 siavash joined 08:04 siavash left, siavash joined 08:12 teatime left, teatime joined 08:13 teatwo joined 08:17 teatime left 09:00 siavash left, siavash joined 09:49 habere-et-disper joined 09:50 ab5tract joined
habere-et-disper What's the name for doing `3 < $foo < 10` ? A compound comparator ? 09:52
Oh, and what do we call `@bar[ 3, 10 ]` ? Multi-indexing ?
lizmat the latter we call a slice 10:04
I'm not sure what we call the former :-)
habere-et-disper Thanks -- these two are favourites and I enjoy knowing what to call them ! =D 10:08
kjp For the former, the docs talk about chaining operators in some places?
nemokosch That type of associativity is definitely called "chaining" 10:29
lakmatiol python also calls it a chained comparison 10:35
habere-et-disper Inequality chained notation (Wikipedia) 10:38
en.wikipedia.org/wiki/Inequality_(...d_notation
10:53 ab5tract left 11:35 razetime joined 13:03 habere-et-disper left 13:17 ab5tract joined 13:23 poohman joined
poohman Hello all, when I try to overload the comparison operators in a inherited class which already implements it, will the first argument be self or should I use 2 arguments - can you please point me to some examples. 13:26
lizmat operators don't have a self ? 13:27
poohman lizmat - sorry, I dont understand. For example, will something like the following make sense, method infix:<>>(DateTimemilli $a, DateTimemilli $b --> Bool) { where I compare $a and $b} OR method infix:<>>(DateTimemilli $a --> Bool) { where I compare self with $a} 13:35
as a method in the DateTimemilli class which inherits from DateTime 13:36
lizmat infixes are not methods, they are subs 13:38
so in your example s/method/sub/ and you are on your way
maybe also add :D to DateTimemilli
to make sure the infix only works on defined objects 13:39
13:46 siavash left
poohman lizmat - thanks - ill give it shot 13:53
tanto_grs i have a question, is there a newer module of WebService::TMDB, i try to install it with zef, but its every time fails by OpenSSL, i try it also with the flags --force-build and --force-test, have anybody an idea, to solve the problem? i use raku on windows 10 13:56
lizmat sadly, Windows has been out of my mind for the past 20 years or so :-( 14:00
librasteve maybe try learn.microsoft.com/en-us/windows/wsl/install 14:08
tanto_grs i have also WSL on Windows, also its important to use linux, ok, thx i have to do this 🙂 14:11
librasteve cool ;-) 14:12
then I recommend rakubrew rakubrew.org/?platform=linux 14:13
tanto_grs and yeah, i know windows is not the best system, but i have to use it on work, i try everything to change there the os to linux, the most developer think also, but the productive part don't want it 😄 14:14
ok, i will install it on my WSL 14:15
poohman lizmat - I was able to get it to compile and run with multi sub infix:<\>>(DateTimemilli:D $a, DateTimemilli:D $b --> Bool:D), but this sub in the class does not seem to override the > original sub from the DateTime class. Is there some override mechanism which needs to be explicitly specified? 14:35
lizmat it should, can you make a gist? 14:36
librasteve wonder if you need to escape the '>' in '<>"?
<\>> <== like that 14:37
lizmat ah, that could be it... try using «<»
poohman librasteve - cant get it to compile without it
lizmat ah, that could be it... try using «>» actually :-) 14:38
librasteve please share the gist and we can check
poohman how do I get that small less than greater than operator in the keyboard - cant copy (easily) as I am in WSL 1 14:39
librasteve copy and paste
poohman ok let me google how to copy into WSL 1 14:40
lizmat I have: 14:43
:iabbr <<< «
:iabbr >>> »
in my ~/.vimrc
librasteve errr - you still have to copy paste lmao 14:45
docs.raku.org/language/unicode_entry 14:47
poohman ok got it - copy in windows and then just left click with the touch pad in WSL1 Emacs
but it didnt solve the problem
ill share the gist
moment
librasteve tx
oooo 14:52
poohman <script src="gist.github.com/winfredraj/55bbd5d...script> 14:57
I copied the whole file - sorry
still learning the ropes with copying gists etc
librasteve gist.github.com/winfredraj/55bbd5d...95aa8c93b5 14:58
looking...
nemokosch it's weird to have it in the scope of a class 15:00
also, mandatory disclaimer that this is not something nice to do as it is basically an interface breaker for the > operator
poohman I initially thought it needed to be a member function 15:01
nemokosch if you want to overload operators badly, rather overload cmp, before, after
that's the reason they exist as separate operators
poohman nemokosch - noted!
But does not DateTime class implement it, I was just thinking to overload that 15:03
nemokosch Well I've been trying to fight that off, too, truth be told
some of the overloads have been removed by now, in favor of implementing the corresponding Numeric coercion 15:04
not blaming people who think that code in the core is some untouchable source of truth but please consider that it's basically just a 1. massive amount of 2. Raku code, contributed by various people over time 15:08
the good thing about numeric operators is that they can be eliminated basically without any breakage, by merely implementing the coercion methods... 15:10
15:10 ab5tract left 15:18 Guest93 joined 15:19 Guest93 left
librasteve gist.github.com/librasteve/2063318...9b37586ff5 15:45
poohman: I hope that this answers your questions - I think you were on the right track ... and have commented where I have adjusted your code 15:46
as @nemokosch implies DateTime will anyway be coerced to a something like a number for comparison by the standard cmp operator so it is probably cleaner to override that than > or < 15:51
m: my $dt1 = DateTime.new(1470853583.3); my $dt2 = DateTime.new(1470853588.3); dd $dt1; say $dt1 cmp $dt2; 15:52
Raku eval Less DateTime $dt1 = DateTime.new(2016,8,10,18,26,23.3)
librasteve m: my $dt1 = DateTime.new(1470853583.3); dd +$dt1; say +$dt1 ~~ Numeric 15:54
Raku eval True Instant.from-posix(1470853583.3)
librasteve (looks like dd is run in another thread)
nemokosch hm, how did you conclude that? 15:55
librasteve since it prints to the chat after the previous say 15:56
nemokosch lol true, that's unexpected 15:57
tanto_grs @librasteve on WSL it works all, rakubrew and the install over zef - WebService::TMDB, thx for the way 😄 16:11
librasteve happy to help! 16:12
poohman librasteve - just returned from dinner - will have a look immediately - Thanks a lot! 17:00
tanto_grs Which editor do you prefer, for development raku on linux? 17:16
17:28 razetime left
poohman librasteve - thanks, got it running when I got it out of the class scope - that was probably something I used to do when I programmed using C++ in college, define the operator overloading in the class definition itself - in that case the first variable used to be the "this" variable - so I was expecting self to do the same thing here. Could have 17:28
alos been why I didnt find it it problematic to overload the "<" operator - as it would have been within the class
thats some unlearning I need to do 17:29
17:35 razetime joined 17:42 razetime left
librasteve i prefer vim, but that has a quite a learning curve … maybe nano these days? 18:08
nemokosch yeah well, to overload the "<" operator is not a technical problem in and of itself, it's rather just an "antipattern" 18:14
there are two approaches when it comes to operations provided on certain types: a) leave the types be and provide sufficient meaning for the operation on them b) leave the operation be and provide sufficient coercions between the types involved 18:15
either way, if you want to write robust code, there needs to be a "fixed point": the type of the operands or the behavior of the operator 18:17
since the < = > operators already coerce to Numeric as the default case, and they are sort of advertised as something meant for numeric comparison, it rather makes sense to keep this "promise" 18:20
especially when there is before eqv after, advertised as the "generic comparison operators", hinting that they are the ones meant to be overloaded 18:21
there is nothing to enforce any of this, it's just a convention to avoid chaos
poohman nemokosch - thanks for the information 18:23
tanto_grs i know both, vim and nano, also emacs, but thx for the answer, i got my visualstudio code it works for both 😉 18:43
19:49 poohman left 20:12 tea3po joined 20:14 tea3po left, tea3po joined 20:15 tea3po left, teatwo left, tea3po joined 21:25 habere-et-disper joined 21:33 habere-et-disper left 21:37 habere-et-disper joined 22:00 ab5tract joined 23:30 ab5tract left 23:51 habere-et-disper left