4 ms·
> That code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer. How would it look like with this particular code? Just f
by johnisgood 1y ago
> That code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer.
How would it look like with this particular code? Just for comparison.
> The `idup` makes a copy of its argument in memory, and marks the data is immutable.
How is one supposed to know this? Reading the documentation? I really want to look at the code and be able to know straight away what it does, or have a rough idea.
- zdragnar 1y agoSee https://en.m.wikipedia.org/wiki/Uniform_function_call_syntax https://en.m.wikipedia.org/wiki/Uniform_function_call_syntax - the examples section has two side by side. The Nim language version is also pretty readable even if you're not familiar with it. As for idup... The first several search results for "dlang idup" are all useful. > I really want to look at the code and be able to know straight away what it does, or have a rough idea. I presume you really don't like perl, ML based (ocaml, f sharp, rust) Haskell or K.
- johnisgood 1y agoI love Perl[1] and OCaml. I dislike the rest. It depends on the task. [1] https://news.ycombinator.com/item?id=44359539 https://news.ycombinator.com/item?id=44359539 > As for idup... The first several search results for "dlang idup" are all useful. Yes, I am sure it was, I am sure an LLM would have helped too, but I think that is besides the point here.
- zdragnar 1y agoIs it beside the point? Looking at that perl example: $string =~ s/\d+/NUM/g; I don't have a clue what is going on. Sure, I see the regex, but what is =~ doing? There's only so far you can stretch most languages before you need to actually put in effort to learn them.
- johnisgood 1y ago"=~" is the operator testing a regular expression match. It should be obvious, because on the right side you see regex, and you ought to know what "=" or "==" does. FWIW, I knew this as a kid, too, despite knowing absolutely nothing about the language at the time. Anyways, you should read https://news.ycombinator.com/item?id=44463391 https://news.ycombinator.com/item?id=44463391 if you care about why I dislike the way D does it.
- quietbritishjim 1y ago> > That code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer. > How would it look like with this particular code? Just for comparison. I do not know how to write D, so the following might not compile, but it's not hard to give it a go: copy(sort(array(map!(uniq(byLine(stdin, KeepTerminator.yes)), a => idup(a)))), stdout.lockingTextWriter()) > > The `idup` makes a copy of its argument in memory, and marks the data is immutable. > How is one supposed to know this? Reading the documentation? I really want to look at the code and be able to know straight away what it does, or have a rough idea. Are you serious? You are offended by the idea of reading documentation?This is not helping the credibility of your argument. Again, I'm not a D user, but this is just silly.
- johnisgood 1y ago> Are you serious? You are offended by the idea of reading documentation?This is not helping the credibility of your argument. Again, I'm not a D user, but this is just silly. If you knew me, and you read my comment history, you would have NEVER said that. It is not even a matter of reading the documentation or not. "idup" seems arbitrary, sorry, I meant the whole line sounds arbitrary. Why "a"? Why "a.idup"? Why "map!"? I was asking genuine questions. You do not have to bash me and see ghosts. I was curious as to why it was implemented the way it was. I am an active speaker against people who hate reading the documentation. And FYI, I love Perl[1] and OCaml[2]. [1] https://news.ycombinator.com/item?id=44359539 https://news.ycombinator.com/item?id=44359539 [2] You would have to check the comment history.
- quietbritishjim 1y agoI think perhaps you are not realising the negative tone of your comments. There is no way to read "How is one supposed to know this? Reading the documentation?" except sarcasm. No amount of good faith in unrelated comment threads changes this. I believe that's why you're getting downvoted - not because people are easily offended about D, as you seem to believe.
- johnisgood 1y ago
- spacechild1 1y ago> Reading the documentation? Yes? > I really want to look at the code and be able to know straight away what it does, or have a rough idea. You said elsewhere that you love Perl. Would you say your sentence above applies to Perl?
- johnisgood 1y agoIt does not, but Perl is a much older language, and I have familiarized myself with it through actual discourses regarding its syntax, implementation details, and so forth. But in this thread? All I got was wrongful accusations and down-votes. I am done replying to this thread. Should have just let Walter reply, but that was not enough for you people, was it? Funny though, because most of the things these people accuse me of are dead wrong, and my comment history is proof of that. In fact, I have been down-voted to oblivion for telling people to read the documentation. I guess we may have come full circle. Glad we had this utterly pointless chat.
- spacechild1 1y agoI'm not a D user and I don't have a ball in this game. I just found your critique of D's syntax rather odd because it can be applied to basically any language one is not already familiar with. Maybe I'm wrong, but I don't think my response was particularly rude...
- johnisgood 1y agoI mean, to me it just looks ugly. Perhaps written in a different way, it would have been better. I have seen Haskell and Elixir code, but they were much less ugly. Then again, it is entirely subjective, and we should not argue about taste. To each their own.
- p0nce 1y agoI don't think you're wrong, I have used D for 19 years and don't really use the UFCS dot style, it requires too much context. Just loops are more readable. In D you don't have much decisions forced on you tbh.
- johnisgood 1y agoI appreciate it.
- gallier2 1y agoI just wrote a somewhat bigger program in D and I mostly used UFCS chains for the toString() overrides to have better debug outputs. There are also some idiomatic forms that are frequent like conversion bar = foo.to!int is much more readable than bar = to!int(foo)