« first day (2003 days earlier)      last day (1473 days later) » 

1:41 AM
^ Make str into a library type, not a special compiler internal type
 
 
7 hours later…
8:54 AM
@Shepmaster I already hear breaking sound xd
 
..and the age old debate continues: "We should have ok-wrapping!", and then "No, no, we definitely shouldn't"..
3
 
9:22 AM
I will never ever like "usize throws io::Error"
> Panicking is actually faster in many cases than using Result, because the happy path is cheaper.
citation needed
I don't see in anyway how this could be true
> If there are many function calls between where an error is raised and where it is handled, it can result in faster code to not have to check the result value for fallibility at all of those calls during the happy path.
hahahaha
TL;DR without a boats want to push exception in Rust
> I don’t like exception terminology .... But I personally do like the exception terminology
Ok I'm done
The tone of the blog is very bad
either you are open minded either you are a hater
 
This is the key:
> We have seen with Future, and will someday see with Iterator and Stream, a syntactic pattern for dealing with “being in the monad” in Rust
So basically he's advocating that there be a handful of "blessed" monads that behave differently. This really would backfire unless there is a general-purpose way to express monadic effects
stackoverflow.com/questions/61097606/… - "asked 1 min ago", already downvoted. Zero comments.
 
9:43 AM
@PeterHall problem is that he himself push for this feature and the actual form like ? .await etc
So that easy to say "we already do that in Rust" when it's you who introduce it
that not very neutral
and even if I like ? await & co.
it doesn't mean add throw is good
 
@Stargateur To me, the "ideal" solution is not possible without a Rust 2.0
@Stargateur Throw would only be good if it was genuinely monadic
 
@PeterHall comment is not mandatory...
@PeterHall I don't have theorical skill I'm the "pratical" dev so "genuinely monadic" is ????
 
@Stargateur Yep. But I was surprised that someone could assess this question within 1 minute. i couldn't even read the question in that time
 
@PeterHall strange question have pop several minute ago for me like 2-3 minute :p before your message
 
10:33 AM
@PeterHall Users can revert the vote within 5 minutes IIRC. So it is common for some to vote when they are somewhat confident in it.
Also, what Stargateur said.
There are many alarm trigger'ers in this one: "Best practices", and lacking a complete example.
 
10:47 AM
This is a bit of a mind-bending article if you're not familiar with functors and monads
but I highly recommend reading it -- there are just so many food for thoughts in there
 
@PeterVaro well, not familliar is not correct, let's say "I think monads and functors are bullshit thing that people invented instead of saying simple word"
but I'm probably wrong
I still wait for a clear and concise explanation of it so I will read it for sure
but that lost not concise :p
 
It's like, a burrito.
(says guy who only ate a burrito once in 2017)
 
each time I read about functor I just read it's a function why you try to make thing complicated
 
@Stargateur And what is a function?
 
so my brain erase it and I forget what is a functor
 
10:55 AM
@PeterVaro To be recorded: that post contains GATs
 
@PeterVaro well I tried
 
@E_net4iscleaningup it just has to be as Good As That.
 
The article is boring, I mean I don't want to read extending work using generic everywhere to try to implement a thing I don't even know is used for
 
Granted, we often work with more concrete realizations of monads (e.g. Option)
 
In functional programming, a monad is a design pattern that allows structuring programs generically while automating away boilerplate code needed by the program logic. Monads achieve this by providing their own data type (a particular type for each type of monad), which represents a specific form of computation, along with one procedure to wrap values of any basic type within the monad (yielding a monadic value) and another to compose functions that output monadic values (called monadic functions).This allows monads to simplify a wide range of problems, like handling potential undefined values...
 
10:59 AM
I want GATs because I see situation where I need it. I don't see why I need functor or monad except to give me a headstache
 
However, thinking at this level is useful to grasp more complicated abstractions, or those which cannot be represented properly without GATs.
 
surprisingly the "Non-Technical Explanation" on Wikipedia is quite good
 
> A monad is a common pattern (a piece of code that is often repeated) with a special goal - to reduce the amount of repeating code, make some incompatible pieces of code compatible and to improve readability, allowing to focus on important parts of an algorithm.
a function ?
> There are many types of monads, each one solves a particularly common issue.
darkness my old friend
@PeterVaro still non sense to me
I still maintain my "I think monads and functors are bullshit thing that people invented instead of saying simple word"
 
Well, if you think about it that's how human communication works, right? We make up words, associate them with certain meanings and then we use them instead of explaining the meanings and concepts every time..
We could've call Monads Burritos instead, if such a thing qualifies as "simple word" for you
 
well, yes and no, yes you right but the monad case people seem to be incapable of explaining what is it clearly
 
11:09 AM
I agree on this, most articles just put some Haskell code there
 
at some point I'm starting to think they don't understand themself what they are trying to explain.
 
which barely means anything for the reader
when I first tried to understand what a monad is, I searched for 'implement monads in Python'
 
if Option from rust is a monad so a monad is a generic struct / enum / whatever with function link to it. and it's make sense if you thing at what mean GATs that are incomplete higher thing bound
 
because for me an actual implementation meant more than the abstract articles
 
problem with rust implementing "full" monad is just genericity with lifetime
so if I understand correctly monad is bullshit and it's just the concept of generic function
but again I'm probably wrong
 
11:13 AM
Except traits are a thing.
 
that where rust have trouble I guess
 
11:49 AM
Every time I use an Option<usize> I'm tempted to use an usize with usize::MAX being the "None". Sometimes I don't even resist the temptation.
 
@DenysSéguret don't please
 
(next step, use an u16 because in fact it's enough)
@Stargateur too late!
 
@DenysSéguret with all due respect, that's a horrible, horrible habbit.. discipline yourself, mate!
 
(it's wrapped so it's not really as bad as it looks... but it's probably useless)
 
@DenysSéguret expect if you have memory constraint I don't see the point
 
11:59 AM
Alas, we still can't represent a {integral} - {~0} type so that it requires the same bit width as the same {integral}.
 
you should at least to some proper encapsulate thing
(never mind you did)
 
@Stargateur I don't remember for this particular change but I benchmark all the time and I know the actor_map is sensitive. I never do this kind of change without having some kind a measurable impact
(on performances, not on used memory)
@E_net4iscleaningup I'd really really like to have constrained integral types, both to let the compiler do optimization and for having invisible assertions done in debug builds
Any non null usize is so frequent...
(I'd also like a "vector with at least one element" type)
 
@DenysSéguret that would be nice
 
@E_net4iscleaningup I hope this not true.
@Stargateur I believe that most people either do not know what a Monad is our cannot explain it. One or the other but not both.
@DenysSéguret hopefully you use doc.rust-lang.org/std/num/struct.NonZeroUsize.html with a shift?
 
12:20 PM
in fact it's the same without the need to shift
But I'll use this type in other places because I also often need a NonZeroUsize and I hadn't found it before. Thanks @Shepmaster
 
Does anyone remember a question about using tokio futures inside actix?
I'm sure I have seen something like that
 
12:36 PM
@PeterHall there was a recent one about streams. Reqwest and actix IIRC
 
@Shepmaster Yes I found that - not a great question, and no answers :/
I think I've found the cause of my issue anyway. github.com/actix/actix/pull/363
 
@Shepmaster Why is that?
 
12:55 PM
@E_net4iscleaningup because good burritos are tasty.
 
@Shepmaster Mexican food isn't my thing.
 
@E_net4iscleaningup oh dear :-(
You could always try Americanized Mexican food or authentic Mexican food, depending on what you've had ;-)
 
mmm, brussels sprouts
If you haven't had brussels sprouts in a few years, it's worth trying them again
 
@Shepmaster Madness yet so brave
 
I got a bag of them in my fridge right now :-) I like them slightly charred.
 
@Shepmaster FWIW there is no problem with Portuguese food.
 
1:38 PM
I don't understand why I keep getting upvotes for stackoverflow.com/q/57259126/155423. Why do people keep stumbling on that Q / A?
 
"Why the upvote?" :+1:
 
To clarify, I know the answer is good and upvote-worthy :-) I just can't understand why people keep getting to the question.
I got 4 updoots on it overnight.
 
I asked the same thing whenever I got updoots in my most updooted Q.
 
My best guess is that people go to [rust] and sort by highest votes
 
But this one might be a pertinent question to new Rustaceans: they expect Rust to take advantage of aliasing.
Or that
 
1:42 PM
@E_net4iscleaningup it's such a low-level detail though, so only a small subset of Rustaceans
 
C++ borne-agains? :)
(there definitely ought to be a better term)
 
picture the scene from the matrix where neo comes out of the goo
 
It's been a long time since I watched The Matrix.
 
@Shepmaster I'm remember when this question become HOT
 
@Stargateur yeah, that's where most of the upvotes come from. I think it also got linked on sites like HN / reddit
 
2:14 PM
> so I can now successfully run some async [Rust] code within Wind Waker.
woah
 
2:40 PM
ding
 
@Shepmaster Dude people love Q&As with disassembly. They're such crowd pleasers.
I got a billion upvotes for some answer where I decompiled JVM bytecode. Super niche question with no real world applicability. Folks ate it up.
 
nom nom nom
 
@JohnKugelman and this disassembly is relatively easy to grasp, so that could be a thing.
 
Reminds me of a cutting remark I heard someone threw at a nerdy but not very smart friend: "Just because you read Slashdot doesn't make you smart."
"You can be a dumb nerd."
Reading about assembly makes people feel like they're smart ;)
I'm gonna upvote shepmaster to show how smart I am!
That's my theory anyways...
 
Under common circumstances, I wouldn't have called that a smart move. But it's Shep we're speaking of.
 
Or the master of which.
 
I'm at my 4 week of doing sip parser in nom
 
@Stargateur I'm sorry.
 
I'm starting to become crazy
 
upvotes ⊂(▀¯▀⊂)
 
2:47 PM
To be fair, it's also my thought process when I upvote stuff about instruction pipelining or CPU caches. I don't actually know anything about processors... but I like to pretend I do...
 
Gotta know enough to know you don't know that much about it.
Try to say that ten times in a row. :)
 
BTW your answer is so smart dude. Have another upvote.
 
@Shepmaster unfortunately I can't make it open source (but that was raise by one of associate of the company, so boss are not fundamentally counter it) ^^ but if we don't success I will probably release it
 
@JohnKugelman it's also possible that they don't know assembly but that the Q/A helps them know a bit more, so they upvote for the learning. I often upvote when I learn something
which means I rarely upvote (I kid, I kid)
 
@Shepmaster Fair interpretation if you're not a misanthrope.
 
2:52 PM
@JohnKugelman jokes on you
 
Yeah, I expected the second half of that sentence to be: it's also possible that they don't know assembly so they upvote on it because it looks cool.
 
Oh I get revenge downvote xd
 
Huh. I've never noticed a chat infobox on the main site before
 
3:00 PM
@Shepmaster we're famous!
:see_no_evil:
 
I am unsafe Ferris
@Stargateur Friendship is magic
 
3:18 PM
How can I do some post-processing on a whole bunch of Results? I had code like this:
fn stuff() -> Result<Quux, io::Error> {
    let a = foo().context("stuff() failed")?;
    let b = bar().context("stuff() failed")?;
    let c = baz().context("stuff() failed")?;
    quux(&a, &b, &c).context("stuff() failed")
}
I wanted to get rid of the repetitive calls to context() and kludged my way to this:
fn stuff() -> Result<Quux, io::Error> {
    (|| {
        let a = foo()?;
        let b = bar()?;
        let c = baz()?;
        quux(&a, &b, &c)?
    })()
    .context("stuff() failed")
}
What's a better way to do this? My googling didn't turn up a good answer.
(Pardon any syntax errors, I just whipped this up in a text editor.)
(I could post a question. But I'm guessing there's a dupe I missed?)
 
There isn't right now. The IIFE is it. You can also make a separate function.
fn stuff() {
    fn stuff_() {}

    stuff_().context()
}
 
IIFE? OMG it has a name?
 
An immediately invoked function expression (or IIFE, pronounced "iffy") is a JavaScript programming language idiom which produces a lexical scope using JavaScript's function scoping. Immediately invoked function expressions can be used to avoid variable hoisting from within blocks, protect against polluting the global environment and simultaneously allow public access to methods while retaining privacy for variables defined within the function. == Usage == Immediately invoked function expressions may be written in a number of different ways. A common convention is to enclose the function...
in the future, try blocks will be stable
would look something like
fn stuff() -> Result<Quux, io::Error> {
    try {
        let a = foo()?;
        let b = bar()?;
        let c = baz()?;
        quux(&a, &b, &c)?
    }
    .context("stuff() failed")
}
although I think they do automatic Ok wrapping now which I disagree with
 
Have you answered this before? Should I post a question?
 
I don't recall answering it
 
3:28 PM
I'm not finding a dupe but I'm flailing around with the search terms.
 
I'll post it. You'll probably find a dupe a minute later and close it. ¯\_(ツ)_/¯
 
3:55 PM
when returning a small number of values with the same type from a function (e.g. four f32's). what's the preferred way to wrap them? tuple, vec or struct? could there be any noticeable differences in performance?
 
@zeawoas depends on what level of information hiding and/or abstraction you want there
[f32; 4] is also a possibility
I wouldn't use a vec though; no need for heap allocation
I'd expect tuple, array and structs containing the values (directly or as a tuple struct or whatever)
to all be the same performance
 
thanks! I'm only interested in performance in my particular case.
 
4:38 PM
People have been talking a lot about Ok-wrapping these days.
 
4:52 PM
@JohnKugelman FWIW, I have ideological arguments with this concept as a whole.
such that I wrote a library to avoid it docs.rs/snafu/0.6.6/snafu
 
5:10 PM
@Shepmaster Your example involves two conceptually different errors:
let config = fs::read(filename).context(OpenConfig { filename })?;
// Perform updates to config
fs::write(filename, config).context(SaveConfig { filename })?;
 
@JohnKugelman yes, exactly.
And knowing which of a / b / c failed isn't important?
 
In my case, an example of what I'm doing is parsing /proc/partitions. I could get an error opening it, an I/O error reading any particular line, an error splitting a line into tokens, or an error converting a string field to an integer.
 
yep; and to me, each of those deserves to be different.
 
I consider them all the same error -- can't parse /proc/partitions.
 
So, what I'd do is
enum ParseProcError {
    Open { source: io::Error },
    Read { source: io::Error },
    Malformed { source: io::Error },
}

fn stuff() -> Result<Quux, ParseProcError> {
    let a = foo().context(Open)?;
    let b = bar().context(Read)?;
    let c = baz().context(Malformed)?;
}
Then then whatever calls stuff would have
enum Error {
    UnableToReadProcThing { source: ParseProcError },
    MaybeAnotherUnableToReadProcThing { source: ParseProcError },
}
(the second one being if there were multiple calls to stuff in different contexts
 
5:16 PM
My thinking is... the std::io::Error or ParseIntError I'm getting back already has the detailed error info. I just want to add a higher-level error message. I don't need to break it into all kinds of sub-cases cause the caller doesn't care about the different between open() failing or read() failing or whatever.
Oops that was wrong. This is actually library code come to think of it.
But yeah I don't want to pass that level of granularity up to the caller. If they want it they can look at the error's source().
Yes? No?
Cause also this is one of say 40 different methods. One to read /proc/partitions, one to read /proc/devices, one for /sys/mapper/control, a half dozen to look things up in /sys, a couple dozen to do different kinds of ioctl() calls. If I were to have custom error types for every method I feel like it'd be overwhelming and low ROI.
Versus, say, just attaching a string to every error and calling it a day.
Sorry if I'm being argumentative. I'm predisposed to simple error handling -- I never liked creating complicated exception class hierarchies in Java.
For your example use case snafu looks quite nice and I support differentiating the different errors log_in_user() can encounter.
They are meaningfully different.
 
5:38 PM
I don't think you're being argumentative - this is something of a core disagreement in the rust community about how errors should exist and be handled, what level of granularity is enough, where, and how we can/should/shouldn't/don't make it easier to evaluate or re-evaluate that tradeoff.
Point being, it's a great thing for discussion, but not somewhere there's broad consensus
 
6:28 PM
Nah, not argumentative. I mostly think about how actionable a given error is when presented to the user + how useful it is when the user tells the dev an error
so an error message that says "couldnt {open,read,parse} {/proc/devices,/sys/mapper/control,/another/file}"
would be painful for a user to address
so many times people will stick in the file name
so then you have "couldnt {open,read,parse} /proc/devices"
but there's still the step of "which of those do I need to fix"
 

« first day (2003 days earlier)      last day (1473 days later) »