« first day (1311 days earlier)      last day (2406 days later) » 

00:29
@Stargateur I feel this is real ugly, but should be able to be clean
@Shepmaster Did that guy upvote you and mark yours the answer, and then remove the upvote?
Weird
Also your answer is more complete
@PeterHall I dont know if I got an updoot or not
I was looking at the dichotomy though
complete, but not necessarily better.
It's just odd to mark it the answer and then upvote a different answer INSTEAD
Also, I liked your answer because I learnt something :)
for<'a> syntax is something I can read and understand, but I'd never think to use it to solve a problem. If I needed to write the code there, I'd probably have tried a few things and then given up.
 
1 hour later…
01:44
@PeterHall That's wonderful!
02:06
Pop quiz...
what does "".find("") return
@Shepmaster well I would expect Some(0)
and "trent".split("") ?
@Shepmaster I think that's ["", "t", "r", "e", "n", "t", ""] or something bizarre like that
you are correct
and it's damned annoying for Jetscii
I'm trying to figure out how much I care
pretty lucky guess, I knew it was weird though
you know about split_terminator, right?
gets rid of the trailing ""... you still have to skip the leading one
02:23
I'm coming from the other side
Implementing Pattern
@Shepmaster trying to decide whether you want to agree with split or to make your own kind of sense?
yeah. I match Pattern's impl for &str otherwise
but
    assert_eq!(SearchStep::Match(0, 0), searcher.next());
    assert_eq!(SearchStep::Reject(0, 1), searcher.next());
    assert_eq!(SearchStep::Match(1, 1), searcher.next());
    assert_eq!(SearchStep::Reject(1, 2), searcher.next());
    assert_eq!(SearchStep::Match(2, 2), searcher.next());
    assert_eq!(SearchStep::Reject(2, 3), searcher.next());
    assert_eq!(SearchStep::Match(3, 3), searcher.next());
    assert_eq!(SearchStep::Done, searcher.next());
That's the pattern for "abc".find("")
And it feels like the overhead of tracking that is super annoying
03:03
a little more readable
03:22
@Stargateur that it is. Although NLL is like easy mode 😉
We need this in stable ;)
@Stargateur I hang out in the NLL chat rooms its fun to listen in, but I rarely understand all the details. I know they are working on trying to make it happen though
03:52
actually I have a algo with recursive function but I don't know how to take iterator as argument xd
 
8 hours later…
12:12
Dum, dedum, dedum...
 
3 hours later…
14:44
@Shepmaster That last question.. It's definitely the worst thing about Rust right now
> How can I create an iterator of chars from stdin with Rust?
?
The fact that it works fine with return...
14:52
@PeterHall worst really?
@Shepmaster Ok you're right. The fact that you can't define a generic Monad or Functor trait. It's inhumane!
I do agree with Peter that it's jarring.
@MatthieuM. It's also very hard to explain
Notably because the stylistic recommendation is to NOT use return in this case.
So the default style throws you head first into the error.
@PeterHall: To be honest, I don't see any way to explain it beyond "the devs screwed up desugaring" :x
"I cannot answer the why" — Shepmaster
I've always heard this issue in the context of NLL. But if it's a bug, it could have been fixed already?
14:58
@PeterHall I mean, the bug fix is nll
@Shepmaster It sounds more like the bug fix is a side-effect of NLL
@PeterHall: I think it could have been fixed in isolation by fixing the desugaring; but since NLL will fix it and it's not a major hindrance nobody really saw fit to work-around the lack of NLL for this case.
well, the bug is that the ast-based borrow checker has to be overly conservative because it cannot know as much as the mir-based one
@MatthieuM. Right
so any fix would entail providing more info
could it have been incremental? maybe. I think they tried that and it failed
15:01
Or auto-replacing expressions in return position with return expr; ?
Anyway, it's still fascinating
@PeterHall perhaps
i dont think it happens real frequently
you need a temporary, mutability and an implicit return
@Shepmaster This is no good for the thread question ?
@Stargateur i think its a fine solution. can remove the clone though
oh, indeed ;)
I have a fear that perf issues will delay NLL. They don't want to undo the good work in speeding it up over the last 6 months
http://perf.rust-lang.org/
The NLL tests generally run the same or much worse
15:08
@PeterHall thats a concern they are aware of at least. they have ideas on fixing
Yeah. I wonder if it would be worth taking the hit. It's a huge feature
@PeterHall very nice stats ;)
actually with incremental compilation NLL should be fine
still 10x faster than cpp
@Stargateur Really? I had no idea cpp was so slow
I've only ever worked on tiny C++ projects
I don't know if clang++/g++ is more slow than rust... but cpp has so many feature, template are turing complete... imagine
Such stupidity
Most runtime code you write doesn't even need a Turing Complete language
15:13
haha, don't insult cpp too fast, sdleffler.github.io/RustTypeSystemTuringComplete
before c++11 a lot of project include boost... well, you know you have to think twice before add one header ;)
@Stargateur Heh. :S
There are two problems with C++:
- textual inclusion & macros means that each translation unit requires compiling MBs of code,
- the duck typing of templates combined with overload resolution requires expensive computations for each different instantiation (combination of parameters) of each template...
now they are rolling back my edits and reapplying them manually
They might have been editing while you were :p
I think then that you are presented with a dialog box asking "yours or the other", and if you click yours it rolls back + submit yours... maybe...
15:23
@MatthieuM. but does that trigger a rollback? "Rollback to Revision 2"
i thought it just overwrote
Maybe?
Ive half a mind to roll back to the identical version for spite
Tssss!
i shant, but i like thinking about it
No rollback wars please, peace and love only!
15:28
@MatthieuM. is it really a rollback if the content doesnt change
@Shepmaster XD
they rolled back just so they could do the exact same edit?
@Shepmaster do you really made a roll safe meme-ception ? ;)
thats how the edit history makes it look. I did botch my edit at first ([` foo] `), but fixed it quickly
so maybe they saw that, rolled back, then edited
or like MatthieuM. mentions, maybe the system does it automatically
@Stargateur I had an idea a while ago to write a sudoku solver in Haskell's type system. The idea was to create a compile error, where the "expected" type is the completed grid. I didn't get very far ;)
15:33
haha that why I like functional, you don't compile and several hours later, you finally compile and the result is correct at the first succeed compilation XD
@Stargateur If someone would just write a mapping Hindley-Milner <=> DataLog, it would make it much easier :)
@PeterHall you know datalog?
@Shepmaster I have used it.
I would take a little while to get back up to speed probably. But there isn't much to it
@PeterHall sounds like you can help make NLL a reality then
Oh you mean based on that blog post?
15:55
@PeterHall i mean based on the fact that I am watching them implement datalog for NLL
ah
I didn't read that link
I have thought of making a toy Prolog implementation in Rust, to teach myself about things.
I guess I should finish my toy Scheme interpreter first.
16:11
@trentcl write one in the other
There was a programming challenge years back
where I wrote a brainfuck interpreter in ruby and a ruby interpreter in clojure
It's taken me years to get to this point and it's not even turing complete yet.
I tend to work on it in 2-week-long spurts every couple months
3
Q: Is a rollback ever generated by any method other than clicking the rollback link?

ShepmasterRecently, I edited a question to add some minor formatting. Later, I noticed that my edits had been rolled back and then the OP had then re-applied the exact same edits. This seems like a very strange sequence of events, but it could make sense if the user doesn't know how to rollback and the or...

@trentcl whats taking so long?
which part, i mean?
@Shepmaster mostly that I keep thinking of better ways to write the evaluator
I was pretty close with a recursive approach relying on the Rust stack, but then I decided to redo it so I couldn't overflow the system stack while evaluating deeply nested Scheme expressions
not that that ever happened
I'm pretty happy with it now, but I'm doing a "pop the stack, do some processing and push it back" dance to work around some issues that might be solved with NLL
@trentcl can't just get a mut reference to the top?
@Shepmaster Nope. The "push it back" part is conditional, but only happens when I don't need to move out of it.
I haven't tried it with nightly to see if I can get rid of it yet.
16:37
there is a way to use memcpy in rust ?
I'm trying some unsafe ;)
16:50
@Stargateur easiest is doc.rust-lang.org/std/…
I do this but it's the same slide ;)
play.rust-lang.org/… This is a model of a mini 3x3 Sudoku in Rust types. It is an error if the Sudoko is unsolved.
3
However, it would be really cool, if the compiler could infer the solution based on a few missed type variables.
The Element trait is actually unnecessary. I was just trying something which didn't work...
17:34
Ok this is better: play.rust-lang.org/…
It can infer that a partially complete puzzle has a unique solution
I'm just not sure how to get the solution out as an error :)
@PeterHall you stop that
@PeterHall stop that
I literally cannot even.
cc @kennytm ^^ Think chalk has any useful errors for this abomination?
18:01
@Shepmaster o_o
I don't think chalk has any diagnostic yet
@kennytm well then, probably not a useful test
could submit it as a test case then ;-)
what is meant by 3x3 sudoku anyway
i think the minimum is 4x4
is it the length of a side of the square? 3^2 big squares each containing 3^2 small squares?
All the sudoku I've done is a grid like that, numbers 1..=9
oh i'd call it 9x9 :p
But its hard to tell from the code because generics
who thought those were a good idea anyway
18:07
lol. looks like the code only checks columns and rows
It is complete
You can only query one missing value at a time
but it will print it out at runtime, using the debug instance. But it is computed at compile time
Edit the closure inside main to query each element
ok this one has the solution as a compile-time error play.rust-lang.org/…
2
oh, nice. Much better!
core_intrinsics huh
just a left over, removing it is fine
18:17
this can't be scaled to a standard sudoku with 9 numbers though, the NE8 trait is going to need 9! (= 362880) impls
Ah, nice use of Option to avoid uninitialized!
@kennytm Yeah... that's a good point
@kennytm build scripts / macros to the rescue
My original approach modelled relationships between rows and columns
I think that might work
You can cut that number right down
I wouldn't count on playpen being able to run it without a timeout though :)
@Shepmaster the compile time is going to be great :p
@kennytm remove all the whitespace to make it go faster
3
18:19
let's just encode the entire algorithm into build.rs :p
Anyway... @Shepmaster, those trait impls are almost equivalent to DataLog rules. Um... I think that was the whole point of why I just wasted 2 hours...
@kennytm the true compile time evaluation
then you can get real nice error messages
@Shepmaster hahahahaha
18:39
@kennytm If you want to build the 4x4 go ahead, but I quit! :P
no thanks (:
I think you're still confused: the question has always stated, "...an iterator over the chars coming from a Reader like stdin"--I'm not sure what about this is confusing to you, but I did update the question to clarify since you seem to have misunderstood. Your downvotes are rude and inappropriate. — maxcountryman 2 mins ago
I made a new friend
I wonder if they think I can downvote multiple times
must be 100k+ privilege :p
The upshot of that Q is that I'm gonna try and submit String::into_chars
Just building all that compiler now
you may try ./x.py test --stage 0 --no-doc src/libstd nowadays
(you'll need to manually delete two outdated rlib every time though)
18:49
@Shepmaster "downvotes are rude and inappropriate." I only see this ;)
@Stargateur I'm not gonna ask, but I wonder when they are appropriate
when it's not his question
the fun is that my previous snipped is what he ask
but I don't know how to fix the error xd
19:40
@Stargateur which snippet
20:35
@kennytm thanks
@kennytm i added a type to libcore::str, but cant see it from libaalloc
Am I hitting a stage based thing?
@Shepmaster check if you have updated liballoc/str.rs?
@kennytm oh 😅
21:27
wew Rust needs some delegation
Wat
@E_net4 WEW RUST NEEDS SOME DELEGATION
@Shepmaster WAT
# WEW
no headers, eh
It wouldn't make sense if that worked.
21:29
    #[inline]
    fn next(&mut self) -> Option<char> {
        CommonChars::new(self.0.by_ref().cloned()).next()
    }

    #[inline]
    fn count(self) -> usize {
        CommonChars::new(self.0.by_ref().cloned()).count()
    }

    #[inline]
    fn size_hint(&self) -> (usize, Option<usize>) {
        CommonChars::new(self.0.by_ref().cloned()).size_hint()
    }

    #[inline]
    fn last(mut self) -> Option<char> {
        CommonChars::new(self.0.by_ref().cloned()).last()
    }
Orite.
delegate syntax
I needs it
Yeah, I would benefit from that too.
Is there any RFC with something similar?
wew lad
wew
21:31
Which OF COURSE has to have drama associated internals.rust-lang.org/t/…
Well, good thing Rust drama doesn't reach "SO blog post" levels of drama.
Tim
Tim
I got a short question:
Considore the signature: fn f2<S: AsRef<str>>(v: Option<S>) {}, you can't call f2(None), since the type cannot be inferred
or, to be more precise, S can't be inferred
Is it possible, to modify it with impl Trait, that it's possible?
like fn f3(v: Option<impl AsRef<str>>) {}?
Or does the compiler internally deduce impl Trait to T: Trait?
@Tim impl Trait and <T: Trait> are the same in argument position, yes.
you could call it like f3(None::<&str>).
Tim
Tim
@kennytm I try to avoid the turbofish syntax
@trentcl too bad, thanks
21:45
@kennytm can you think why iter::Cloned shouldn't have an as_inner method?
and/or an into_inner
@Shepmaster because no one implemented it?
that' why it wouldn't, not shouldn't ;-)
now, do any iterators have these methods
maybe having as_inner/into_inner would leak implementation detail which prevents us from changing the representation?
as_inner on an iterator? :/
that's why we don't have OsStr::as_bytes() on windows for instance
21:53
@kennytm it'd mean we'd have to accept a T but not keep it as such
yeah. can't think of other reasons that we shouldn't add the method (though i'm not in the libs team :p )
@kennytm like that means anything. You got the knowledge
😳
Statically type checked languages are dumb
The compiler keeps telling me I'm wrong
@Shepmaster I'm going to stuff all sorts of objects into my functions or die trying.
I'd rather get RuntimeError than have a compiler tell me what to do.
22:03
Then it's someone elses problem
Yeah, it's my problem. But I'll live with it, because I don't care about compilers
Let it rue the day static typing became popular again!11
error[E0460]: found possibly newer version of crate `std` which `rand` depends on
@kennytm ^ is that the error you warned me about?
Ok, off with the sarcasm.
I recall seeing some relatively new project which adds proper static typing to Python.
Ah, found it.
Me lieky that video. It shows a Rust-like syntax for return types.
@Shepmaster yes. just remove the librand and liblibc to proceed.
22:10
> Show HN: Cannoli – A compiler for a subset of Python written in Rust (github.com)
> 5 hours ago
So old, bro.
..
@E_net4 the syntax has actually been part of Python for quite some time.
They added it in hopes that someone would come up with a use for it.
I guess it was in 3.0 python.org/dev/peps/pep-3107
@trentcl Well, I'd use it if I knew about it in the first place. :( Why does no one seem to use that yet?
@E_net4 It's just syntax. Python itself doesn't ascribe any meaning to them
22:13
@trentcl So.... It's like reserving a keyword but giving no use to it?
Basically.
on that note, proc has been giving me grief in Rust
Imma use the carp out of it. I was fooled to believe that the only reliable way to annotate types was with documentation blocks.
procedure is just too long
Conveniently, it does show up if you define a function like

def run(a: int) -> str

and type help(run) in the REPL
> Imma use the carp out of it
Totally. :D
22:35
@trentcl it's gone.
now to play the waiting game
@trentcl Can also use prok
@E_net4 world is better with static type verification ;)
I made a dream, that one day... github.com/rust-lang/rfcs/pull/1888
"We're not doing postponement issues anymore; just continue discussion over at #1888.
Closing this therefore to reduce the backlog."
damm
22:51
As a Python and ndarray user, I understood the latest question. What else can I do to salvage it?
well, you edit make it better but still far that something acceptable
OP didn't link the numpy doc, what do a = np.zeros((100, 4), dtype=np.float32) ?
The question is "code this plz"
"The following Python code will repeatedly add the vector [1, 2, 3, 4] to each row in the two-dimensional array a, starting only from the 20th row.", this is not clear to me
add to row ?
what is the final result ?
@Stargateur I added that part of the code. Before that, the OP just said "say a is an array of shape (100, 4)".
I could improve that, I guess.
no let the OP with this ugly question
I vote to close
or answer it if you believe this question should be answer
but I don't think that you should do the work of the OP
The truth is, I can answer this one.
I understand the python code too, but there is a infinite way to answer this one
the question was unclear, now it's too broad xd
23:00
@Stargateur Not if you know the idiomatic one.
@E_net4 But the OP want Vec ? want Array ? something else ?
@Stargateur F'in ndarray.
That was already in the question.
I don't believe the OP is thinking about anything else.
there is a crate of ndarray in rust ?
But as I said this is one crate
there could be a lot of other way
23:04
You don't answer a question with "read this ;)".
Although that is an interesting reference.
23:14
> I have substantially edited your question
... pray I do not edit it further
Yeah, this is tricky.
But there would be hardly any honour in closing this question and then making a whole Q&A of my own on the same subject.
@shep What's in your mind? :)
@E_net4 I think if you understand what OP is asking, and you think it's on-topic and all that, then you can answer
Your answer can include additional "rephrasing" ("In order to <clarified wording> ...")
@Shepmaster Nice!
I thought of prok but I ended up with proc_
@trentcl I was mostly thinking of krate from cargo code
@E_net4 like, i appreciate that you used the right terms (broadcast, etc)
@Shepmaster Aye, tech-agnostic terms work well here.
(they're used on both libraries anyway)
Ok, maybe I should stop editing the question.
23:49
@E_net4 and op edits
the question is finally clear and not too broad !

« first day (1311 days earlier)      last day (2406 days later) »