4 ms·
Does anyone actually call it "Stringify"? I would call it "to string".
by seaish 6y ago
Does anyone actually call it "Stringify"? I would call it "to string".
- smabie 6y agoProbably not. If they wanted people to call it Stringify then just name it stringify. Though personally, I like how instead of toString, Haskell calls it 'show'. Clear, to the point, and one word.
- carlmr 6y agoHow is "show" clear for string conversion? You could just as well expect a GUI popup just going from that word.
- smabie 6y agoHow is toString, you just might expect your object to turn into a ball of yarn.
- carlmr 6y agoString is a very common but specific word in programming for a string of characters. Show is a very common but generic word in programming, for showing plots, showing message boxes, showing anything really. Not knowing Haskell I would not have expected it to convert an object to a string.
- couchand 6y agoI suppose Rust's direct analog to Show is Display. There's a blanket implementation of ToString for any type implementing Display, so ToString can be thought of as a super-type. "Display" is nice because it is usually uttered in the same breath as Debug.
- simias 6y agoRust has Display: https://doc.rust-lang.org/std/fmt/trait.Display.html https://doc.rust-lang.org/std/fmt/trait.Display.html On the doc of ToString you can find the following note: >This trait is automatically implemented for any type which implements the Display trait. As such, ToString shouldn't be implemented directly: Display should be implemented instead, and you get the ToString implementation for free. I think ToString exists mostly in order to have a more convenient API to get a String out of a display-able type, otherwise if you used Display directly you'd have to use a variant of that boilerplate every time: https://doc.rust-lang.org/src/alloc/string.rs.html#2185-2192 https://doc.rust-lang.org/src/alloc/string.rs.html#2185-2192