« first day (1435 days earlier)      last day (2040 days later) » 

12:55 AM
@loganfsmyth sigh. Why would they ask two distinctly different questions...
 
@Shepmaster Who knows
 
@loganfsmyth I kind of feel that the real question is "why does this statically compiled language give me warnings about something that Python doesn't"
 
yeah, it seems like at least part of it is that
 
 
8 hours later…
8:38 AM
showerthought: impl IntoIterator<Item=T> is the best way to return an arbitrary collection of elements
and now on second thought, never mind, that always requires a full iteration
whereas returning a Vec can be a move
stupid shower :P
 
9:29 AM
To everybody who says "just use size_of(x)/size_of(y), please try size_of::<[(); 3]>() / size_of::<()>()hellow 49 mins ago
????????????????????????????
You do not answer the question: the OP asks to have the result without a concrete variable. — Boiethios 56 mins ago
Ok but why
 
@Stargateur Didn't see the context but that's a divide by zero
 
haha didn't understand this way
 
@Stargateur I don't understand this comment. OP has an array of integers, not an array of units (and I wonder how an array of units is useful)
 
9:45 AM
@Boiethios OP's question is badly phrased, but it seems likely that the types he used in his code were just an example.
 
@Boiethios Well, that also why I didn't understand it first, an array of nothing, is ... empty XD
But you could iterate on an array on nothing and do thing on nothing because range iterator are mainstream
play.rust-lang.org/… Actually with size_of::<[(); 3]>() / size_of::<()>, I was hoping that compiler throw an error or at least a warning but it don't care at all. it just panic at runtime XD
 
10:07 AM
@Stargateur But if you type this, it fails to compile:
const ERROR: usize = size_of::<[(); 3]>() / size_of::<()>();
 
guys I seriously need naming help now
I have two types of slot map
 
slot_1 and slot_2
easy
 
they are indentical except one has twice as slow insertion/deletion
but in return that one has much faster iteration (how much depends on how many empty slots there are)
what to name them
 
Usually people name these things after the implementation
e.g. HashMap, BTreeMap
 
well the implementations are identical except for how the freelist is maintained
and one of the implementations has a name, SlotMap
the other is a improvement (?, more like trade-off) that's novel as far as I know
currently I'm leaning to IterSlotMap but that might be confusing
 
10:13 AM
Summarize the novel improvement in under 5 words
 
that's 4 words or less :(
Skipping contiguous vacant slots
although it doesn't explain how that works at all
 
Just call it it FastIterableSlotMap
 
that's so wordy
 
yeah
call them both SlotMap but put them in modules that describe them better
 
that... is an option
I like that best so far
or do I...
maybe BlockSlotMap
because it keeps track of blocks of contiguous elmeents
 
10:58 AM
I propose CookieMap
 
11:10 AM
SlotMap and LostMap
LinkedSlotMap
 
MegaSatanMap
 
@PeterHall I considered it
 
@orlp and why did you reject it?
 
@PeterHall because not everything is linked, linked lists have a bad name in the performance world, and I just like BlockSlotMap better
 
11:23 AM
I like the fact that people said linked list are bad, despite the fact that it's one of the base container, I think you simply can't design an OS without it
But if your implement look like a linked list just call it linkedSlopMap
If people are too lazy to read the documentation about perf between your two implementation they don't deserve to use it
 
@Stargateur Linked lists are basically only useful in OS development...
 
@Boiethios That clearly not true
 
I never ever saw linked lists in another context
(i.e. Linux memory management)
 
@Boiethios s/OS development/allocators/
or any other place where O(1) insertion/deletion in the middle of a container is non-negotiable
e.g. realtime audio
(that is, that would be a context in which it's non-negotiable, not sure why you'd need a linked list in real-time audio)
 
@orlp Sure, they are useful only in rare and very specific contexts
The best is at 99% to use a vector that is better for CPU caches
 
11:31 AM
99% is a bit false more 90%
 
maybe LinkedSlotMap is better than BlockSlotMap
decisions decisions
"There are only two hard things in Computer Science: cache invalidation and naming things."
 
actually a miss usecase is to use linked container instead of reallocing a big array, for exemple 5 vec of 5mo is better than realloc 4 times to have a vec of 25mo
 
mo?
 
mega octet
 
@Stargateur Today I'm in my 4th job, I worked in various business environments, I never saw a linked list in production.
 
11:34 AM
@Boiethios hello, 95% of people code wrong ;)
90% when it's a beautiful day
 
90% thinks they're in the 10%
:P
 
clearly
 
Linked lists can be good when the items are not individual data points, but blocks of data
 
@orlp How about ConvolvedSlotMap for the fast iterable slotmap? "Convolved" should reflect the convolved spaghetti structure between map and freelist which derives from the fact that the gaps in the freelist are ordered differently from the occupied blocks in the underlying array.
 
> which derives from the fact that the gaps in the freelist are ordered differently from the occupied blocks in the underlying array
that is entirely irrelevant for the user
and subject to change
 
11:51 AM
SameButDifferentButStillSameSlotMap
 
12:05 PM
alright
I'm going to keep calling it SlotMap I think
just in a different module
fast_iter::SlotMap
 
I think it's a good choice
 
there is another option
SlotMap<T, PerfIter> and SlotMap<T, PerfMutate>
although that's probably worse
 
12:22 PM
I don't like this at all but I don't have the level in Rust to know if it's bad in Rust
 
12:34 PM
@orlp This seems better.
But you can give an alias for that also
 
actually can't be done because their members are different
 
12:58 PM
@orlp not that you should, but can PerfIter and PerfMutate contain the different members?
 
@Shepmaster at that point it's just bad design
and I can't be arsed to figure it out I already have so much to think about at the moment
 
I'd disagree strongly with that statement in general; that's just normal dependency injection. Whether it makes sense here is a different question
 
fun fact: because fast_iter::SlotMap contains a sentinel element, so must SlotMap to allow conversion between the two
exercise for the reader to figure out why
 
1:31 PM
Isn't this naming scheme, where the distinction is merely made in the module name kind of reserved for cases like result::Result vs io::Result, in which you have specializations (type Result<T> = Result<T, io::Error>;) of a common type rather than fundamentally different implementations? For fundamentally different implementations a naming scheme like in BTreeMap vs HashMap, where the distinction is made in the name of the types, may be more appropriate.
Since SlotMap<T, PerfIter> vs. SlotMap<T, PerfMutate> is not possible, I would vote for a BTreeMap vs HashMap naming scheme.
 
then it's back to IterSlotMap vs LinkedSlotMap vs BlockSlotMap
or alternative names
 
You already had alternative names in the modules tho
FastIterSlotMap
 
@Shepmaster I think I prefer IterSlotMap over that?
maybe not I dno
 
1:53 PM
An argument for FastIterSlotMap over IterSlotMap could be that IterSlotMap might convey the false impression that iterating over the other type of slotmap is not possible at all.
 
2:14 PM
@Calculator that may not be such a bad thing
if you expect to be iterating over a lot map a lot you probably do want an IterSlotMap
 
 
2 hours later…
4:15 PM
I was pleased with this one: stackoverflow.com/a/52390733/493729 :P
 
@PeterHall Nice but still WHAT IS THE POINT OF THIS QUESTION
 
@Stargateur It's almost code golf
 
4:31 PM
Almost code golf indeed. Why the OP chose a HashSet to accumulate the intermediate values is beyond me.
 
I don't know why I do that - answer and then vote to close.
 
@PeterHall Please don't.
 
Answering gives more space to tell OP why they are wrong
:P
 
But is it "a typo or not reproducible"?
Besides, the whole point of closing a question is to prevent answers.
 
It's a brain fart
he's written it one way, for a reason. Then restructured it and taken out an "important" part in the process
 
4:36 PM
I'm not sure how that justifies what you did. :P
 
> flatten after map
I knew this was going to happen
It's only been stable for like a week
 
Yeah, I only heard of it now. And then I checked the docs and said to myself "oh, so it's .flat_map(|x| x)".
 
@Shepmaster Is there a Clippy for this?
 
@E_net4 What would you do ?
 
@Stargateur What?
@PeterHall Doesn't seem so. Will you file this?
 
4:44 PM
"Why the OP chose a HashSet to accumulate the intermediate values is beyond me."
 
@PeterHall A great question
 
@Stargateur Yeah, that was me not understanding the problem. :x The OP did want deduplication. Now what's beyond me is how they rewrote the function while forgetting about the dedup provided by the set.
 
yeah, I like the "I had it in my head rust still knew it was a set.", Op was expecting magic ^^
 
Also, terrifyingly appropriate Meta q: meta.stackoverflow.com/q/374049/1233251
 
@E_net4 I dunno. I think this question is appropriate and on-topic. It probably shouldn't gather a lot of votes over time and thus wouldn't be "an everlasting great question", but I think that's expected
 
4:49 PM
@E_net4 I don't agree trust me this rust question way 10000 times better that question of this style in C
 
@E_net4 Done
@Stargateur Rust can seem like magic sometimes
 
@PeterHall But magic != remove uniq in iter without you ask for it ^^
 
Let's thumb it up, folks!
 
@E_net4 not sure it's a good idea
it's a very opinion fact, one could prefer to keep them distinct
 
5:00 PM
Wa
 
@PeterHall Thx for the second link ;)
 
5:14 PM
Also, itertools provides a unique adaptor, which keeps track of unique values internally. — E_net4 9 mins ago
@E_net4 ^ developed here on SO, acktualllly
10
Q: How can I add new methods to Iterator?

Wilfred HughesI want to define a .unique() method on iterators that enables me to iterate without duplicates. use std::collections::HashSet; struct UniqueState<'a> { seen: HashSet<String>, underlying: &'a mut Iterator<Item = String>, } trait Unique { fn unique(&mut self) -> UniqueState; } impl ...

 
@Shepmaster haha good one
 
@Shepmaster It's not the first time that an SO question or answer brings an interesting development idea.
 
I didn't see #30 before you pointed to it. It's funny I made the same request independently. look like finally our OP on stackoverflow didn't increase the pull request feature ^^
 
 
2 hours later…
7:36 PM
@Shepmaster Can I somehow see all questions that are marked as dupe for a specific question? I have the feeling your most popular question get's asked every week or so...
 
@LukasKalbertodt Over on the right there's see more linked questions…
Which is a start
 
Oh wow...
 
52, holy banana...
 
only 0.52%
 
7:42 PM
@Shepmaster Hu? It's not the duplicate count? The query looks like that..
 
@LukasKalbertodt saying that if there's 10K rust questions, and there's 52 duplicates, then the duplicates only take up 0.5% ;-)
but i wonder why SEDE says 52 and the search has 100
 
Ah sorry, I'm slow today apparently. Yep makes sense, but still a lot ;-)
@Shepmaster Many of those are not duplicates. They probably only link to your question
 
8:10 PM
@LukasKalbertodt A thing I like about it is that it's usually clear-cut that it's a dupe
and I don't feel any remorse gold-hammering it
 
@Shepmaster Yip, I agree. Usually it's very clear. ^_^
 
 
2 hours later…
9:53 PM
@Shepmaster I really try my best with my english, that really lame to see all my errors
 
@Stargateur Je suis sûr que ton anglais est meilleur que mon français
(or Google's, as it may be)
 
@Shepmaster perfect ^^
 
10:18 PM
I have recently noticed that Either has some nice implementation, for example Deref, which lets you use it as a sort of weaker, but more general Cow.
So you can have Either<Box<T>, &T>
and it will dereference to T
But... the Deref implementation is for L: Deref, R: Deref<Target = L::Target>
So it doesn't work with Either<T, &T>
which is kind of a shame
I'm wondering if there is a way to make Either's Deref impl more general
I just can't see a way
 
10:34 PM
It seems like you need two impls of Deref. One as is, and another for A: Deref<Target = B> or vice versa
 
pub fn lines<'a>(&'a self) -> Box<dyn Iterator<Item = Cow<'a, str>> + 'a> + f(x) - g(x) + 'b - 'c + 42
 
@PeterHall something terrible like &L: Deref, R: &R: Deref<Target = &L::Target>?
@Stargateur what is the slope and the intercept of this equation
 
@Stargateur The RFCs required for this signature won't be stabilised for at least 6 months.
#![feature(numeric_bounds)]
#![feature(negative_bounds)]
#![feature(type_level_functions)]
#![feature(implicit_type_contexts)]
#![feature(consecutive_lifetimes)]
#![feature(idris_compat_mode)]
#![feature(type_arithmetic)]
2
 
10:54 PM
@Shepmaster yes
 
11:12 PM
I bet this is "we need chalk"
 
@Shepmaster what does that mean?
 
@PeterHall CHALK
 
better?
TL;DR: chalk is a more principled implementation of the trait selection logic (and more?)
 
11:28 PM
Trait selection does have a few holes
also inference sometimes just gives up when there are too many steps
 

« first day (1435 days earlier)      last day (2040 days later) »