« first day (1373 days earlier)      last day (2098 days later) » 

1:45 AM
@Stargateur it'd be nice if pthreads had any kind of mention of this in the docs
 
@Shepmaster well, I suppose rust don't want to worried user about these low level concept
 
@Stargateur which is fine, I think. But I want pthreads to document that you should never move a mutex
 
@Shepmaster std::mutex doesn't tell it ?
 
I mean, Rust isn't using std::mutex
 
sys:mutex never mind
I don't find sys::mutex in the doc
 
1:47 AM
you mean in Rust?
yeah, there's some platform trickery
it gets imported as sys::
 
@Shepmaster ah you means posix pthreads doc ?
 
@Stargateur exactly
 
Let me find it
 
@Stargateur I think if you can, that would provide wonderful additional information to your linked question and the one I added.
 
2:05 AM
In fact posix doesn't explicitly say don't copy it
"If mutex does not refer to an initialized mutex object, the behavior of pthread_mutex_lock(), pthread_mutex_trylock(), and pthread_mutex_unlock() is undefined.", pubs.opengroup.org/onlinepubs/9699919799/functions/…
"If mutex does not refer to an initialized mutex object, the behavior of pthread_mutex_lock(), pthread_mutex_trylock(), and pthread_mutex_unlock() is undefined.", pubs.opengroup.org/onlinepubs/9699919799/functions/…
etc, I suppose almost all function have this UB
IBM doc explicitly say "Once a mutex is created, it cannot be validly copied or moved to a new location. If the mutex is copied or moved to a new location, the new object is not valid and cannot be used. Attempts to use the new object result in the EINVAL error.", ibm.com/support/knowledgecenter/en/ssw_i5_54/apis/users_61.htm
witch is false because UB is UB
And now I realize that I copy twice the same quote
first should be "The behavior is undefined if the value specified by the mutex argument to pthread_mutex_destroy() does not refer to an initialized mutex."
 
 
5 hours later…
7:26 AM
We have a lot of low quality questions those days :(
 
7:36 AM
@Boiethios MCVE, clear description of the problem, I found the last one is good
"I've been stuck on this error for a few days now." haha, well if it's true I'm sorry XD
 
@Stargateur The last one is ok, but the question is too simple and I'm pretty sure it is a duplicate
 
that doesn't make it a bad question
 
 
2 hours later…
9:46 AM
I wonder if there is a way to add subcommands to Rustup.
 
10:10 AM
Ahah, this guy is funny loyc.net/2015/ultimate-language.html
I wonder how someone can want to create the "ultimate" language while each people have different taste/needs
 
10:24 AM
so
I'm torn between rejecting the duplicate and digging in my heels until somebody explains pthreads to me
or accepting it and trying to seek an answer in
@Stargateur This statement is intriguing
 
 
2 hours later…
12:58 PM
@trentcl What more would you like to see?
I've wondered the same thing in the past, but knowing that Linux implements it with based on the mutex address satisfies my curiosity
 
 
2 hours later…
3:03 PM
@Shepmaster Well, it feels a bit like a non-answer.
An answer would be something like "the mutex contains its own address"
 
> Some implementations of pthreads use the address of the mutex. If you move it, the address changes, and then the mutex is no longer initialized
 
Ok... "the mutex contains its own address, because [something strange I don't currently understand]"
Or "there is a global list of mutexes maintained by the OS and they are indexed by address"?
 
I assume the latter
 
brb
 
But really, such an answer would best belong in one of the linked questions
 
3:10 PM
if rust use posix thread whatever implementation is doing, then must ensure that the mutex doesn't move, because posix said it's would be UB to use it that way
 
@Stargateur where does the posix docs say that? you seemed to be unable to find those docs
 
there say it by saying don't use a mutex not initialized
 
Sure, but that doesn't mean that moving a mutex "uninitializes" it
 
yes it does
because they say the only way to initialize a mutex is to use the macro or init mutex
I know this kind of standard wording that I hate the most
but with time I'm starting to understand how they think
 
that's some amazing logical leaps you are making there and I strongly disagree
This logic means that no struct ever can be moved, basically
 
3:15 PM
yes because C standard say it
 
says what
that you can't move variables?
 
obviously they is not move semantic in C
C tell you you can copy variable (not all variable)
Posix say you can init a mutex with ...
they never tell you you can copy/move it
so you can't
they only tell you what you can do
and sometime they tell you what it's undefined behavior
but the list is never exhaustive
 
Have you ever seen any documentation that says that you can move a variable?
My point is that being able to move a variable is the default
 
that the way C standard work
 
Removing that is the exception
 
3:18 PM
you think is you want me to find a quote about "you can't move a mutex"
but the true is that the fact I can't find a quote about "you can move a mutex" is the answer ;)
 
I also want you to point to any documentation for any (common?) api that initializes a value that says you can move it. I don't think you will
Which, by your logic, means moving it is UB
 
Not sure what I'm looking at here
 
same as me, that where I can't follow, I just know that some thing are not legal to be copy in C, and that mutex is one of them, it's really hard to find revelant quote into this
Because they almost never explicitly say rules
they say you can do that, and it's up to you to find if mutex fit all requirement to be allow to copy them
 
3:34 PM
I'm going to try my luck pinging the authors of some old answers
 
 
1 hour later…
4:35 PM
I'm feeling a bit rusty. I was trying to flat_map elements behind a Result, and this feels excessively tricky.
 
5:21 PM
@E_net4 borrow checker?
 
5:37 PM
@PeterHall Just monads within monads, basically.
 
5:48 PM
@E_net4 What kind of tricky? Like, the fact that you can flat_map just doesn't feel obvious?
 
@E_net4 Aren't monads within monads just monads?
 
unless they are different monads
 
6:21 PM
@Shepmaster That too, I think. Can't made an MCVE right now. :-(
 
6:40 PM
@kennytm Oh right. No HKT in Rust...
Is there a way to partially drain a Vec?
Ie. Consume the vec, and return a tuple of an iterator over (say) 3 items, and Vec that starts at item 4 of the old one.
Do I need to do that with unsafe?
 
vec.drain(..3) ?
the vec will be modified to contain old_vec[3..] after the returned iterator is dropped
 
@kennytm oh!
So stupid. I have code right there with vec.drain(..) - what did I think the .. was?!
 
...
...!
 
...?
 
..=
 
6:55 PM
I actually read @kennytm's code like that
vec.drain(..3)?
I was like "what is the Result here"
 
lol
 
Can I expect vec.drain(..1) to be way better performance than vec.remove(0) ?
 
o_O
 
Docs unclear. Does drain move the ptr or move every item?
 
what do you mean by "move the ptr"
each call to Drain::next should do the equivalent of a ptr::read
and when it's dropped, the Vec does a memmove of all the remaining values
(sprinkle in panic safety and bounds checks and whatever)
 
7:03 PM
Ok, yeah there are better comments in the source itself than in the docs
 
So I'd expect vec.drain(..1) to be slightly worse than remove because it's more general
 
@Shepmaster Right
 
But I'd expect vec.drain(..2) to be noticeably better than 2x remove
 
I thought perhaps the special case of (..n) might do some funky unsafe stuff to the vec's raw parts
just subtract n from the len and add n to the ptr
 
oh, that seems like it would be bad
cause you have to use the original pointer to free
 
7:06 PM
 
See, this is why I don't write unsafe code
 
Oh, Gankro
 
yep
 
Do I have to link the unsafe picture
 
7:22 PM
@Shepmaster Not necessary
I wish the Rust collections docs showed time complexity for each operation
 
@PeterHall if only, doc.rust-lang.org/std/collections/#sequences, oh OOOOO OOOOOOOOOOOO ;)
 
Nice
Still, would be convenient to have that information inline in the docs
but thanks, I'd forgotten about that page :)
It's not very complete. VecDeque.push_front - I presume is O(1)
I guess that's insert(0) in the table?
 
@PeterHall not it's O(min(i, n-i))*
 
Yes, so if i = 0...
 
more i = len - 1
so it's O(1)*
"Operations which have an amortized cost are suffixed with a *"
so it's O(1) and sometime O(n)
Which part of the code are you expecting to know about the directory pyth? — Shepmaster 2 mins ago
I was like "if i'm starting to say that and that I didn't know that it's a implicit rule of cpython::PyModule::import i would pass for an idiot"
 
7:47 PM
@Stargateur This person really doesn't have solid debugging / rational inference skills
Like, if something isn't found, then chances are it's in the wrong place or I said the wrong place.
 
8:02 PM
incredible ! ;)
 
8:15 PM
@Shepmaster, mm, I just need it to se the module fibo.py so thought it may be better to put it in a separate folder, thats all :) — Hasan A Yousef 22 mins ago
OP doesn't understand at all
 
... Does he just expect it to do a recursive search, unprompted?
 
8:30 PM
@Zarenor This is what I mean. Like, what if they put it in C:\Windows32 or in Dropbox or whatever
VTC "lacking ability to draw conclusions"
 

« first day (1373 days earlier)      last day (2098 days later) »