« first day (2613 days earlier)      last day (858 days later) » 

7:54 AM
That's a lot of emojis...
(and a lot of people notified)
 
8:14 AM
@DenysSéguret, ha
 
@Jason I wanted to add one too
So 20 seems to be the limit
 
Hello everyone sorry to bother, I'm trying the AoC with Rust on my free time and was wondering if anyone could take a look at my solution for the part 1 of day 1? The tests are passing but somehow the value is off by one, is it because of the input file?
 
 
4 hours later…
12:01 PM
I am reading about Rust's borrow checker, and I came across this:
> In addition to handling memory allocation and freeing for the programmer, the borrow checker also prevents data races (though not general race conditions) through its set of sharing rules.

I do not understand the difference between "data races" and "general race conditions"
 
12:14 PM
1 message moved from C++ Questions and Answers
 
 
3 hours later…
2:51 PM
@MangaD The Rustonomicon has a whole page on that.
 
Thanks. I probably did not elaborate my question properly and thus it got moved here. ^^'
 
Well, the concept isn't specific to Rust or C++, but the way the message was phrased makes it seem like you wanted to ask a Rust question.
 
I was wondering what would a data race look like
Like, a thread reads while another thread writes to the same memory address. What could happen?
 
@MangaD A simple example: imagine two threads doing a = a + 1 in parallel. You could have both treads reading the same value of a, and thus having only one increment done in the end
 
They both would read from a
I see!
 
3:01 PM
cool
 
Because a+1 is not an atomic operation
But there is also the case of "volatile"
 
and because the whole isn't atomic
 
One thread could cache the variable in a register, right?
 
this can be prevented, it's another problem
This is a simple example. And it's nasty because you can have programs running for years and never encountering the problem, then you get unlucky. And since you have hundreds of thousands of lines of code you can't guess where it broke
 
Regardless of what might happen, the languages state that data races are undefined behavior, so no concrete behavior is to be relied on.
@MangaD volatile does not contribute to concurrent programming here.
 
3:05 PM
@DenysSéguret It is a dreadful problem
 
Rust forces you to look at it, and you can't make such basic data races without really trying (with unsafe)
In other languages, you may use a mutex of some sort, or just ignore it
 
Got it :)
In C++ there is `std::atomic` for this
 
There's not much that you can do atomically
The problem is usually not just a counter
Imagine a set of people you've paid. Looking in the set, then doing the task if the person isn't in the set, then adding an entry in the set, that's something big, and you can't do that atomically.
 
You would need a mutex for that. But, for your previous example of a+1, std::atomic would solve the problem
 
not just a+1 but a++, the biggest problem is in the gap between reading and writing
Yesterday I solved a problem of a colleage who was writing in a log in a multithread env and was filling some buckets with values before they were written. As the filling was long and there was no mutex, the values were mixed. That was in java
 
3:12 PM
And Rust deals with this while other languages require the explicit usage of mutexes?
 
It prevents you to write data races (not all logical races). But explicit mutexes aren't always the right solution. Channels are cool too, or various kind of reduce algorithms (your two threads could have a counter each and just sum at the end)
 
Basically, the compiler stops you whenever you try to share a resource in a way which could lead to data races.
E.g. one immutable reference and a mutable reference of the same value cannot co-exist.
 
(and this is clearer if you know that "mut" really means "exclusive")
 
 
3 hours later…
5:54 PM
I really really really hate people who handle ipv6
oh we don't really know
and ALL SAY SOMETHING DIFFERENT
USELESS RFC
> IP version 6 is the new version of Internet Protocol, which is way better than IP version 4 in terms of complexity and efficiency.
OH REALLY
 
6:16 PM
such complex, very efficient, many unique address!
/poll should I buy red dead redemption II? rumour has it it's got possibly the best ai in terms of response from the humans around the character
 
red dead 2 is one of the best game ever create so if it's your style of game just go
 
I think it is :)
 
7:36 PM
I’m voting to close this question because it's too basic: the basic building bricks of the language, as they're shown in the Rust book for example, should have been looked at before asking — Denys Séguret 8 secs ago
I'm afraid it reads like RTFM... but that's what it is
 
@Stargateur part of me is afraid, very afraid suddenly, that Rust falls down from all this. Or gets forked.
 
@FélixAdriyelGagnon-Grenier all of me is saying "core team should resign at this point"
@DenysSéguret mmmm actually I think this question could be usefull
basic sure but why not
If we answer "one letter generic are generally used for ..."
mcarton link is quite what I was thinking about
 
"one letter" ? Why "one letter" ?
 
hmmm I say we reopen it and close as dupe while we're at it
 
Am I the only one defining generics with whole words sometimes ?
 
8:01 PM
nope
exemple of my code:
pub(crate) fn ether_type<Stream, Context, Error, Item>(
  stream: Stream,
) -> ParseResult<Stream, EtherType, Context>
where
  Stream: Clone + Eq,
  Stream: SplitFirst<Item = Item, Error = Error>,
  Context: UtilsContext<AnyContext<Stream, Error>>,
  Context: UtilsContext<FillContext<Stream>>,
  Item: Into<u8>,
{
  integer(u16::from_be_bytes)
    .map(EtherType::new)
    .parse(stream)
}
can't wait to make a first release of my parsing crate
I'm actually hype for my own work
quite strange
for example this integer parser is INCREDIBLE
thx to generic_const
 
@Stargateur Looks like my approach: giving complete semantic names when there are many constraints between types
 
@DenysSéguret in comparaison... nom code docs.rs/nom/7.1.0/src/nom/multi/mod.rs.html#633-671
 
I'm tired by those discussions on Rust governance with everybody being "We all know who's at fault, no need to tell, everybody knows what this person dit then, etc."....
@Stargateur yes.... this is horrible...
pub fn fold_many0<I, O, E, F, G, H, R>(
(this being lightly said, as I didn't read much of this source)
 
here my fold:
pub fn fold<Bounds, Stream, Output, Context, Parser, Acc, Init, F>(
  bounds: Bounds,
  parser: Parser,
  init: Init,
  fold: F,
) -> FoldParser<Output, Parser, Bounds, Init, F>
where
  Stream: Clone,
  Stream: Eq,
  Context: UtilsContext<FoldContext<Stream>>,
  Parser: Parse<Stream, Output, Context>,
  Init: FnMut() -> Acc,
  F: FnMut(Acc, Output) -> Acc,
{
  parser.fold(bounds, init, fold)
}
 
Generic naming makes it clearer, yes
 
8:32 PM
Hum... the concept of star on GitHub seems to be evolving or getting more precise
 
 
3 hours later…
11:06 PM
https://stackoverflow.com/questions/70295663/rust-understanding-the-letters-u-meaning-in-function-declarations-such-a-f-t-n
This question got closed, and reopened, I would vote to close it as a dupe of https://stackoverflow.com/questions/60590029/what-does-t-stand-for-in-resultt-e-in-rust/60590428, but because of the gold badge, it would close immediately, and I wrote the answer of that dupe.
What do you think?
 
damm
shep beat me
 
@mcarton welcome to my world <3
 
well we was 3 so legit here
@DenysSéguret OP send you a love message
"im voting to close this question its too basic" such a helpful answer, thanks for taking the time to type this out. Do you not read titles before clicking on questions, here is a tip if its too basic for your elite skills dont click on it. but we all know you did click just to post and complain because your sad. — user1003967 43 mins ago
 
An easy flag to raise
 

« first day (2613 days earlier)      last day (858 days later) »