News for hackers. Stuff that matters.
Re:A simple UI framework for Rust by skj on Tuesday May 19, 2015 @10:59AM (#9570514)
Why wouldn't I want to do

dialog.set_title("blah");

dialog.set_size_piels(100, 100);

on two lines?

Re:A simple UI framework for Rust by kedean on Tuesday May 19, 2015 @02:26PM (#9572122)
Different strokes. It's a common idiom in JavaScript, for instance. You can do multiple lines if you want, nothing stops you.
Re:A simple UI framework for Rust by tedunangst on Tuesday May 19, 2015 @11:03AM (#9570560)
Because functional programming.
Re:A simple UI framework for Rust by sp332 on Tuesday May 19, 2015 @11:14AM (#9570695)
To expand a bit: Sometimes, instead of thinking about nouns all the time, you want to think about verbs. Instead of saying "mutate this noun by applying verb1" and then "mutate this noun by applying verb2" etc, you are creating a new verb. The new verb is "verb1 then verb2 then...." And then when you have the verb defined, you apply it to your object.
Re:A simple UI framework for Rust by Jweb_Guru on Tuesday May 19, 2015 @12:02PM (#9571094)
I feel APIs like that are a bit misleading in Rust in many cases, though, since they're also mutating the original. In Rust, if you want to perform a functional update like that you should take the type by move, but almost everyone just uses mutating APIs because mutation is explicit in the signature anyway. I think that's one of the biggest differences in practice between Rust and other MLs (with which it otherwise has a lot in common): in most MLs, mutation is treated as a last resort, while in Rust it's extremely common because it (generally) doesn't have nonlocal effects.