« first day (1681 days earlier)      last day (1809 days later) » 

2:22 AM
"Im saying the code I attached here doesn't build"

"ALSO, the code compiles just fine".
And I'm out
@E_net4 is there a ? /s
 
3:19 AM
@Shepmaster yes but no
 
 
3 hours later…
6:02 AM
@Shepmaster actually the example in this question is ReprEx. If you are referring to the fact that the creation of that specific struct (and therefore the invocation of the new associated function) is not happening in the code, then ask for that specifically if you think that is necessary.
 
here we go again
and again
x)
 
here we go I flag all his questions as spam
 
6:55 AM
@Shepmaster Ambiguous. "derive please" or "doves please"?
 
@Shepmaster I'll second that, bright screens for bright minds!
 
 
1 hour later…
8:23 AM
All the time related function parameters are signed integer here again
- What Time is it?
- It is minus half past three ^^
 
@Websterix A negative duration makes sense
 
@Websterix Careful when playing with that. Languages do have interestingly creative ways to state time.
Also, that. Signed components here is not necessarily problematic.
 
I think that it is a waste of memory here
why not u64 instead?
 
u64 has exactly the same size as i64.
Where's the waste of memory? :s
 
yes but more range
in unsigned manner
 
8:30 AM
I don't think we need more range here. 2^63-1 milliseconds does seem like... enough.
 
if you don't use the minus range in signed types, it is waste Imo
 
Some people might use it, though.
 
How?
 
but as I said... negative durations are perfectly legal
 
See the top of the doc:
> This also allows for the negative duration
 
8:32 AM
I could not accept that time value as minus in my mind ^^
 
And using only checked positive integers make many computations more complex even if the result must be positive. If you have i64 you can have intermediate negative values
 
It's the temporal distance between two localized time events. The sign of the duration indicates which one happened first.
 
 
2 hours later…
10:49 AM
@Stargateur I also found that the same issue causes a significant slowdown in serde_json, even for very simple cases. Benchmark: gist.github.com/peterjoel/eafb936143a988f6a922efd2b52ebf18
 
11:03 AM
 
I think it is reasonable to assume that #[serde(flatten)] is essentially zero-cost, or should have the same performance as deserializing to an already-flat struct.
 
Is there a cleaner way to write this?
        if current.is_some() {
            blocks.push(current.take().unwrap()); // unwrap can't fail
        }
(current is an option, and blocks is a vector)
 
@DenysSéguret you could use something like:
if let Some(current) = current.take()
{
    blocks.push(current);
}
 
@PeterHall Yeah I saw your update on the issue
I agree with peter
2
 
@PeterVaro It's cleaner, yes. Why did I miss it ?
 
11:18 AM
how should I know? ;)
 
@PeterVaro Isn't your brace style a little unconventional in rust ?
 
posted on May 21, 2019 by Félix Descôteaux

Let me start by saying I really like Ruby. I tend to agree with the statement saying Ruby is optimized for developer happiness. However, nothing comes for free. Programming ecstasy is a double-edged sword and writing slow Ruby is as easy as it is pleasant.

 
Why std library doesn't have big sized atomic types like Atomic<u128>, I guess I need to add 'Atomic' crate for that?
 
@Websterix Because they are not supported on every platform
and a Atomic<u128> is very exotic
better use a rwlock or mutex
 
11:29 AM
@hellow well, not all platform have atomic<u64>
 
@Stargateur true, IIRC they are opted out for the platform that don't support them
 
System.as_millis() returns u128, That was why I have asked
 
But use the primitives from crossbeam, since they are lighter than the std ones
 
Atomic<u64 is still unstable, isn't it ?
 
@DenysSéguret Nope
 
11:30 AM
SystemTime*
 
1.34
 
@DenysSéguret latest stable pulled them in
 
oh. so it's time for me to use them
 
Just remember that atomic integer are not without problem, it's often better to have a mutex than just use atomic everywhere
 
@Stargateur Source?
 
why would the time in millis be in u128? I miss something here
 
AtomicU128 exists, but I don't know a platform that supports them
 
@FrenchBoiethios me
 
@Stargateur I don't share your opinion here ;)
 
11:32 AM
@DenysSéguret Sorry it is not systemTime it is Duration
 
@Websterix if you have a duration which is u64::max, then how to represent as_millis in u64? Not possible, therefore u128
 
@hellow Yeah, I did not complained(objected) the return type as u128 ^^
 
@Stargateur The atomic numbers are much better than mutexes because under the hood intrinsics are used.
 
11:48 AM
@FrenchBoiethios The main problem is getting your head around the memory ordering model
 
11:59 AM
@PeterHall Once you've got that, it's even better because some ordering values like Relaxed have a good performance
 
From what I can tell, Relaxed is the same perf as Release or Acquire on any modern CPU, at least on Intel
Since Intel CPUs have a strong memory ordering guarantee anyway
 
Oh I already heard something like that: that newest CPUs have registries that do atomic operations by themselves
 
@FrenchBoiethios did you know that a mov rax rbx does not actually move data around, but instead the CPU just "renames" the register internally x) It's really weird what CPU do today
micro-ops etc... it's black magic
 
That's crazy
 
In computer architecture, register renaming is a technique that abstracts logical registers from physical registers. Every logical register has a set of physical registers associated with it. While a programmer in assembly language refers for instance to a logical register accu, the processor transposes this name to one specific physical register on the fly. The physical registers are opaque and can not be referenced directly but only via the canonical names. This technique is used to eliminate false data dependencies arising from the reuse of registers by successive instructions that do not have...
 
12:10 PM
Thanks for the link ;)
 
12:38 PM
https://internals.rust-lang.org/t/pre-rfc-remove-static-mut/1437
whaaaaaaaat
 
Fun.
We've been witnessing stunning changes recently.
 
oh ... wait.. that's 4 years old x)
whyyyy does discourse not showing the year, if it's not the same year as we currently have
https://github.com/rust-lang/rust/issues/53639
a more recent version
 
@hellow Do you know how many registers a single core has? HUNDREDS! This register renaming is actually costing quite a bit of complexity (ie, surface) and power... That's why I really liked the idea of Mill Computing; hoping they'll manage to actually produce their baby.
 
Pff. This is new however.
 
@E_net4 I read it this morning. Quite neat :)
 
12:42 PM
@MatthieuM. Hundreds? That sounds a bit off. Which CPU architecture do you speak of?
 
@MatthieuM. yes.. I'm aware of the amount of registers. It's all about speed and to reduce the time of a context switch, which can be really expensive
 
Yum.
 
@MatthieuM. I hope that risc-v will become big soon enough...
 
Eh, I still had in mind a few dozens of registries. I'm old
 
@FrenchBoiethios yes, you can only access a few of them by name (rax, rbx, rcx, ...) 16 IIRC, there are more under the hood
 
12:49 PM
Why can't everything be like MS-DOS...
 
Ah, that's why
 
 
1 hour later…
2:17 PM
> I have programmed in 28 languages
But doesn't know how to make a MCVE?
 
@Shepmaster I had an engineering course titled "Exotic Languages" where each week a different language was presented, its principles, etc... can I claim I programmed in each of those languages? :D
 
@MatthieuM. All depends on what "program" means, I suppose
I like a little more nuance to that statement when I use it
"dabble" and "production ready" for example
 
stackoverflow.com/a/56258784/1021920 @Shepmaster that's some black magic that you did there... I searched for a way to create a Waker, but haven't found anything useful... fancy dancy
but where does that RawWakerVTable::new come from? I can't find it in the docs..
nor in the sources...
 
2:32 PM
@hellow what
you looking at the nightly docs?
I literally just followed the docs
 
@Shepmaster no.. haven't look at it, was using stable... sorry :/
 
@hellow Yeah, there were last minute changes, so the stable docs don't include it
 
2:49 PM
This dtolnay's serie of articles is super cool: github.com/dtolnay/case-studies
 
 
2 hours later…
4:56 PM
1
Q: How can I run a set of functions on a recurring interval without running the same function at the same time using only the standard Rust library?

nbariI would like to use Rust to create a simple scheduler in order to run multiple concurrent functions at a defined time but do not start more if they haven't finished. For example, if the defined interval is one second, the scheduler should run the functions and don't start more if the previous fu...

Is this OP just deliberately misunderstanding me?
 
5:12 PM
Iiiii... am not sure?
To me, this reads as someone who expects not to think about the implementation details of what other language's libraries have provided. And in rust, something like this is likely to require thought about the implementation details.
That is: We don't have a runtime that can be listening to/polling system time or timing events. We don't abstract over the OSes events by default. We don't have some naive way to do this, at least not in std.
Looks to me like Go does. I know C# does. I seem to remember Java also having a similar facility. I think it's just a comprehension issue. Does that seem to tack with what they've said, to you? That what I get out of it.
(Also a typical "Can you just answer anyway, so I can copy your code and move on? attitude. Not very SO)
 
@Zarenor this last part has left a bad taste in my mouth
I have an answer
so I'm debating posting
but I also wonder if the Q is on- or off-topic
 
5:35 PM
I think it's tough to say. It's the kind of thing that almost certainly has an answer for Go and C#, for example. But I'm not sure it's covered in std for rust, and so I think it might be off-topic. I almost want to punt you the question back: How much do we or do we not want to point people at crate-based answers, which may expire over time.
I know we answer them sometimes. To me, this feels syscall-y, like we'd want to tall them to use OS libs. But you have a better solution than that? is it tokio based?
 
@Zarenor I just posted it. It uses the standard library only
@Zarenor I don't like questions that say "stdlib only", but I think that they are fine on SO
Sometimes the answer is "no, you can't do that with the stdlib" (and often we include a "but if you use this crate...")
 
Yeah, as maybe you can infer, I'm a little leery of the premise in general. But I'm also leery of suggesting a crate as the !!right!! answer (because of the lack of stability and maintenance guarantees)
Maybe that's a self-inconsistent viewpoint? I'm not sure.
Your answer, though, I think answers exactly what they're asking. Probably not the most robust way, but they also don't look to be wanting some industrial-quality use-this-in-production answer.
 
@Zarenor yeah, they use a channel to stop the scheduler, which I ignored, as well as generalizing to N functions
 
Yeah... shouldn't be too hard to figure out.
 
5:50 PM
@Zarenor I'm kind of justifying it to myself as "how do I do X with Y crate" seems like it would be on-topic. libstd is a crate. Therefore "how do I do X with standard library" feels OK
if the question was "how do I do X in Rust", then it seems overly broad.
because the answer might be "use crate X or Y or Z"...
 
6:51 PM
hmm
[MCVE] in comments is now expanded as "minimal reproducible example"
 
And is [MRE] expanded ?
 
@Shepmaster yeah they replace it without ask
 
The Meal, Ready-to-Eat – commonly known as the MRE – is a self-contained, individual field ration in lightweight packaging bought by the U.S. Department of Defense for its service members for use in combat or other field conditions where organized food facilities are not available. While MREs should be kept cool, they do not need to be refrigerated. MREs replaced the canned MCI, or Meal, Combat, Individual rations, in 1981, and is the intended successor to the lighter LRP ration developed by the United States Army for Special Forces and Ranger patrol units in Vietnam. MREs have also been distributed...
 
There's still some work to make it consistent
 
6:56 PM
@Stargateur I do. But it's not currently "reprex"
(thank god)
 
can you do a min-reprex plz
so clear
 
MRE is easy to remember. If everywhere we use it it's expanded, it would be OK. The reader wouldn't even have to know we called it a MRE
 
7:21 PM
fn gen() -> impl Iterator<Item = impl Iterator<Item = usize>> {
    (1..1000).map(|i| (1..i % 30).map(move |j| i * j % 50000))
}

    let sets: Vec<Vec<_>> = gen().map(|i| i.collect()).collect();
beautiful
 
7:54 PM
@Shepmaster That'll always be an MRE to me. Both my parents are Army vets, and I was in the Nat'l Guard for 6 years. Eaten more of those than maybe I care to talk about.
To approach the problem directly: I don't think min-reprex or MRE or MCVE are particularly better or worse than one another. The issue is still that what we mean is obvious to us - people who understand what the site is trying to do, how, and why - and not necessarily obvious to new users. Maybe the new user experience helps with that. I think no amount of bikeshedding for marketable abbreviations helps explain what we're asking for better.
@Shepmaster See, I'm ambivalent here, because I'm really wary of causing what would be a sane request with a standard answer or couple of answers in another language to be 'too broad' here, because we're really careful about what we include in std
 
I don't much mind "MRE" vs "MCVE"
My annoyance is at the unilateral change and amount of churn for no obvious improvement
 
@Zarenor That just seems like hamstringing ourselves for our principles, when that's not the problem either set of principles (rust's std policies or SO's broadness policies) was intended to solve (really).
 
like, MRE isn't head-and-shoulders better than MCVE
 
Yeah. Nobody likes to be reminded their vaguely democratic institution is actually oligarchic or dictatorial. You can see the same issues with controversial RFC decisions. I just try to get less worked up about it than I feel.
I fully agree it seems like needless or nearly-needless change. I even agree that I don't see a real benefit. But I don't know that there's a real cost..?
 
Costs are mostly to people like myself, who are used to asking for MCVEs
my autocomments are now out of date
The tag info for rust tells people how to make a MCVE
which now isn't a "thing" anymore
but I don't want to change it in case the name changes again
 
8:11 PM
Ah. And because they're not links, they don't get renamed/redirected/updated. I take your point.
 
 
3 hours later…
11:23 PM
35
Q: MCVExit redux: I don't need a milkshake to know when I've missed the mark

Shog9A week ago, I had an idea: change a URL with thousands of outstanding uses and try to replace an awkward initialism with... Another awkward made-up word. ...Ok, that was... not a great idea. Fortunately, many of you generously donated your time to point out just how not-great that idea was, and ...

 
> "Magic" links have been added for [reprex], [repro], [mre], [example] and [mcve] that all point to /help/minimal-reproducible-example - use any of those in comments and they'll be turned into a link.
I'm ok with that
 

« first day (1681 days earlier)      last day (1809 days later) »