🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
Xliff \o 15:31
Good morning#raku
Happy to report that total compile time of my projects is the lowest it has been since Jan at ~12,800 seconds 15:32
github.com/Xliff/p6-GLib/blob/mast...ounts.xlsx 15:33
MasterDuke nice 15:58
Skarsnik maybe I should run my gumbo benchmark x) 16:06
Xliff Here's a question... why doesn't Duration have methods for .years, .months, .weeks, .days, .hours, and .minutes? 17:23
Would a PR be welcome?
Skarsnik hm 17:27
wxhat method do you have on Duration?
Xliff I don't think there are any methods specific to Duration 17:34
patrickb japhb: I'm looking at your Termial::LineEditor. There is a lot to learn. :-)
japhb: In github.com/japhb/Terminal-LineEdit...kumod#L620 why do you use a react block instead of two awaits? IMHO the awaits would have been the more obvious solution. 17:36
lizmat Xliff: makes sense 17:37
question becomes: should Duration.hours be a Real or an Int ?
also: .years and .months are ambiguous, so I would not add those 17:38
as Durations do not have an "anchor" :-)
perryprog I suspect the reason it doesn't have those methods is because no one wants to write date and time code ;) 17:50
lizmat well, a nice addition would be to have a "ago" method on Duration, which would do something for "just now" if < 10 seconds, "N seconds ago" if < 50 seconds, "about a minute ago" if < 90, etc etc 17:54
El_Che just saying something without reading the backlog :) : if booleans there is a Before and After method in Go that kind of cover most of the use cases I can think of 18:00
lizmat El_Che: elaborate ? 18:03
El_Che you take care of the exact duration before the if 18:05
if entries[i].ValidUntil.Before(now) { ... }
if entries[i].ValidUntil.Before(now.AddDate(0,0,-7) { ... }
a week ago
etc
lizmat we have .earlier and .later on dates and datetimes 18:07
if that's what you mean?
ugexe if the number of seconds every year isnt the same then can a Duration actually have such methods?
lizmat that's what I said... :-) 18:08
El_Che :) 18:10
patrickb japhb: Are you aware that Terminal::termios has parts written in C and thus requires a C compiler to be installed? Terminal::LineEditor depends on it. That's a bit of a bummer for the "written in pure Raku" aspect of Terminal::LineEditor. 18:15
japhb patrickb: re: react instead of two awaits -- by-product of multiple refactorings. Can probably be changed to awaits now, yeah. 18:26
patrickb japhb: Good morning! :-)
japhb patrickb: termios written in C: Grrr. Yet another yak to shave. :-( I mean, it's still useful that Terminal::LineEditor itself is written in Raku, because it's easier to contribute to than e.g. Readline. But yeah, yet another thing to do. 18:28
I have shaved a damn *herd* of yaks at this point, and there's no end in sight!
patrickb: Good morning! :-)
(On the plus side, I refreshed my state machine skills writing Terminal::ANSIParser, so I guess not all the yak shaves are useless.) 18:29
patrickb They are not useless at all! I really appreciate having a fine set of terminal plumbing available in Raku directly. 18:32
Xliff lizmat: I don't think Duration needs an anchor, as that should come from context, which is application specific. 18:35
Duration implies things like days, weeks, months and years.
I do like the concept of .ago, however.
I'll include that in my PR.
japhb Oh, I can see right off one of the reasons that termios has parts written in C -- according to my trusty copy of APUE, the struct varies. And not trivially, either. 18:37
Xliff: Once you subtract two Instants, you are left with a quantity that is only a size on the Instant scale ... the original instants are lost, and you no longer have a concept of anchor points; you have magnitude only. 18:38
Xliff japhb: DateTime - DateTime = Duration. In this situation, there is an anchor. 18:46
If the concern is Instants - Instants, then that should not return a Duration.
It should return an Int.
I also disagree that two instance is not anchored. 18:48
If a DateTime can be created from an Instant, then Instants DO have an anchor when used with context.
Instant - Instant = Duration. (Anchor is the first Instant)
But the above is only true within the application context from which that Instance is derived. 18:49
Juerd If anyone's looking for a project, pypi.org/project/bpython/ has me drooling and I'd love to see a braku :) 19:07
Xliff Juerd: That's neat! Quite an ask though. At least for me. 19:17
japhb Xliff: I'm saying, you created the Duration from two instants there. But the Duration does not remember those instants. It is now just a quantity, which can then be applied to other things.
Xliff japhb: And I'm saying that the nature of that quantity impliee the methods that I wish to add! 19:18
s/impliee/implies/
japhb OK, let's say you subtract Oct 1, midnight from Nov 1, midnight, and you add it to Feb 1. What should happen? 19:19
Xliff sourceable: sub MAIN { }
sourceable6 Xliff, No idea, boss. Can you give me a Code object?
Xliff japhb: The hours and minute different from the first should be added to Feb 1st
(see what I did that?) :) 19:20
s/that/thar/
japhb Juerd: Well, I'm slowly working my way to the point that that *could* be done with Terminal::LineEditor. But it will take someone spending a while thinking about compiler state to complete that.
Xliff: OK, you've made a choice. Why do you think it's the correct one, that can be applied in all instances as a rule, rather than a lot of special cases? 19:21
Xliff japhb: Yes, I've made a choice. From the options provided. Once that CAN BE VALID given specific situations. 19:22
You are trying to tell me this choice in invalid and that the tools that choice provides are not useful.
japhb Xliff: Yes, you've now hit the nail on the head ("given specific situations"). I think what you *want* is a different class than Duration, but related to it. 19:23
Xliff If you really are telling me that "class Duration" doesn't need operations typically done on a duration.
Why call it a Duration?
Duration IMPLIES units of time.
Don't take the word and change its meaning!
japhb Because it is a duration in the sense of physical passage of time, but passage of time in TAI is not the same as passage of time on the Gregorian Calendar. 19:24
Xliff A duration, in most ALL of its usages, imply "the interegnum between two moments in time"
japhb And no, I'm very much not saying what you're talking about it is unreasonable. Just different.
Xliff How is passage of time any different in any context?
japhb Oh man, there's a lot of physics in the answer to that.
But ... hold on a sec. 19:25
Xliff And if you are not saying it's not unreasonable, then why tell me not to write the PR?
japhb Because you're not looking for CORE Duration, you're looking for "GregorianDuration" or some such
CORE is TAI. 19:26
Xliff japhb: And this is how Raku loses! Because you want to take a generic concept, and turn it into something specific that doesn't mean what the commen sense interpretation is!
japhb: Where in the online docs does it say CORE is TAI. Please point to the page.
And if you can't reference it then please find a place where said reference should be and I will update the docs. 19:27
And then tell me how .minutes, .hours, .days, .weeks, .months, and .years are not TAI when Instants and Durations are mesured in seconds. 19:28
japhb Um, look at src/core/Duration.pm6? 19:30
Because a minutes is not always 60 seconds, a day is not always 24 hours, and a month is not always 30 days. 19:31
(And a year is not always 365 days, forgot that one)
Xliff Now this is true. 19:32
At least among purists.
However pratical coders don't give a shit. 19:33
ugexe they dont until it matters
Xliff And we need more practical coders in Raku if it's going to grow.
ugexe: Think it will matter when they reach for Duration.days and find it missing?
ugexe I have never once needed to reach for such a thing, and I feel like I've done a lot of DateTime related business logic in my life 19:34
Xliff Funny. I neded it today.
And it wasn't for anything overly complex. I had to also reach for "augment", which I usually NEVER have to do. 19:35
To each their own.
ugexe maybe i misunderstand, but how would you do this with e.g. perl?
japhb Also ... Raku is the home of NFG, and characters === grapheme clusters. We try at least to do the actual right thing.
Xliff The use of "augment" is made a bit ugly by its requirement on MONKEY-TYPING and all that opens up.
ugexed: How does how it is used with perl matetr? 19:36
s/matetr/matter/ ?
I hate how my typing is deteriorating... :/
ugexe prior art is usually so for a reason
in other words: why would another language choose to not have such a thing? 19:37
Xliff Because the authors were not that forward thinking.
ugexe are you sure they would not say the same of you?
Xliff There are a lot of other reasons, but that's the big one.
ugexe: I don't think they would. If they aren't going to use it. They won't care that it is there. 19:38
japhb Let's not get into talking about people's intelligence or ability to think in general. That way lies incivility.
Xliff OK, so if the inclination is to not have this in core, then I guess I can module-space it. 19:39
Xliff I just think that's a cop out. These methods should be usable out of the box. 19:39
japhb Xliff: I'm not saying what you're asking for is useless, it's really not. I'm saying, it's not *Duration* as defined in Raku. It's a different thing. Just like a "Fiscal Year" and a "Calendar Year" are related but not the same.
Let me try a different angle, Xliff. Make a module that is the API you *want*, and then we can discuss. 19:40
Xliff japhb: I do think I just offered that. 19:41
japhb Because I can guarantee that the human perception of dates and the physical notion of time only resemble each other in a "fun house mirror" sort of way.
Xliff: Sorry, our messages passed in the ether
Xliff Ho!
"TAI times are identified by year, month, day, hour, minute, and second."
cr.yp.to/proto/utctai.html
Second paragraph 19:42
This is EXACTLY as I would lay out each method.
japhb Great. Do so. I think you've misunderstood what DJB means by "identified by" though .... 19:45
Xliff How so? 19:46
japhb Because TAI does not have timezones or leap seconds. 19:47
Xliff I never mentioned either of those concepts. 19:48
Durations don't recognize those etiher.
s/those/them/
japhb You can absolutely specify a YMDhms for TAI ... they are not the same as YMDhms in any other time system. And in *particular*, a duration in TAI cannot be applied to any other time system than TAI and still be accurate. 19:49
Xliff You mean to tell me that a TAI second is not the same as the seconds we use every day? 19:50
If this is true, why use it?
japhb Yes, read the literal next sentence from the one you pointed out.
Xliff heh. I didn't read that far. 19:51
japhb Because it is a continuous, not changing atomic time. (Time Atomic International, except with French spelling)
Things that require super-accurate, invariant time sources (like GPS) need to care about that. 19:52
(And in case you were wondering if it matters on earth, well ... Google's Spanner database depends on super-accurate time, as do quite a few of the timeouts and such within Google's systems. In order to be hide the difference between UTC and TAI and keep everything from going to absolute hell, they have to smear every UTC leap second over 20 hours to get the difference to stop being prohibitive.) 19:54
Xliff japhb: github.com/Xliff/raku-Duration-Uni.../Units.pm6 20:46
japhb Xliff: Years are ~ 365.24 days long, not 365.75. :-) 21:03
The almosts can be filtered out by doing that at the end. 21:05
(They are all equivalent to `$almost = $time-val < 1` at the end) 21:06
But yeah, for human durations, that's a good start.
It's biased towards English, of course, but that's a separate problem. 21:07
japhb .tell patrickb github.com/japhb/Terminal-LineEdit...4ce1cab3e5 -- thanks for the suggestion! 21:32
tellable6 japhb, I'll pass your message to patrickb