Re: Safe Navigation Operator “?.” for D2 ?

2014-03-03 Thread Bienlein
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? AFAIKS

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-03 Thread Tofu Ninja
On Sunday, 2 March 2014 at 09:12:08 UTC, deadalnix wrote: No. Gotta love the well thought out responses...

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-03 Thread Bienlein
On Saturday, 1 March 2014 at 13:54:49 UTC, Araq wrote: Araq: could you list the problems you see in the OO world? I could list the problems, but that would fill books. So, I'll focus on a single aspect instead here: Favour composition over inheritance. This is commonly regarded as the better

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-03 Thread Jesse Phillips
On Sunday, 2 March 2014 at 01:28:32 UTC, deadalnix wrote: So, to make refactoring easier, you refactor. I knew the functional crowd liked recursence, but I just learnt that tail recusrion can also be used to crate circular logic. I can't find what I'm thinking of, but Conditional Proof seems

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-03 Thread Bienlein
On Saturday, 1 March 2014 at 16:27:45 UTC, Araq wrote: That's an ADT then, not OOP. (I follow Cook's definition of OO here.) 2. Encapsulation and information hiding That's a module system, not OOP. Can you create an instance of a module? Then it's not an object in the sense of OOP.

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-02 Thread Araq
The anti OO world don't need that, as they know all future evolution at day one. Probably because they do not have users. The idea that *more* code makes your code easier to evolve only comes from OO people, makes no sense and has largely been proven not to work. Even the OO people realized

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-02 Thread deadalnix
On Sunday, 2 March 2014 at 08:16:43 UTC, Araq wrote: The anti OO world don't need that, as they know all future evolution at day one. Probably because they do not have users. The idea that *more* code makes your code easier to evolve only comes from OO people, makes no sense and has largely

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-02 Thread Timon Gehr
On 02/27/2014 02:27 PM, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? auto foo = bar?.baz?.fun:hun;

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-02 Thread Boyd
While at the moment it may seem like a must have feature. If D is going to get better nullability handling, like the proposed @nullable or Nullable!X, then the safe navigation operator is not really needed. The explicit nullability would provide the needed safety. auto x =

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread Marc Schütz
I sometimes come across situations like this: writeln_or_whatever(person ? person.name : ); (This is a case of means something.) Using `person?.name` is a bit shorter and DRYer. But it would be more useful if I could specify the default value it returns. With an explicit `maybe` this would

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread Ary Borenszweig
On 3/1/14, 4:10 AM, Araq wrote: Even if that would be true, the refactoring über alles OO crowd couldn't care less... You refactor. Problem solved. Massive code restructuring is embraced in the OO world because OO encourages bad design like no other paradigm. Araq: could you list the problems

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread Araq
Even if that would be true, the refactoring über alles OO crowd couldn't care less... You refactor. Problem solved. Massive code restructuring is embraced in the OO world because OO encourages bad design like no other paradigm. Araq: could you list the problems you see in the OO world? I

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread Jacob Carlborg
On 2014-03-01 14:54, Araq wrote: I could list the problems, but that would fill books. So, I'll focus on a single aspect instead here: Favour composition over inheritance. This is commonly regarded as the better solution (and I agree with it btw). Ok, fine, so we favour composition and don't

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread Araq
You have other parts of the OO paradigm as well, which I would consider more important: 1. Combining data (instance variables) and behavior (methods) as a single entity (object) That's an ADT then, not OOP. (I follow Cook's definition of OO here.) 2. Encapsulation and information

Re: Safe Navigation Operator “?.” for D2 ?

2014-03-01 Thread deadalnix
On Saturday, 1 March 2014 at 07:10:56 UTC, Araq wrote: The problem when you chain is that you make a lot of code dependent on the structure of the project, which makes it hard to evolve or maintain the project, as any change in the structure will impact more code than it should. Even if

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread John Colvin
On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Gary Willoughby
On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Dicebot
On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: Chaining . operation is a code smell to begin with It is? Why? If a system is well-designed, then null state either means something (and needs to be explicitly handled) or is not possible. ?. provides simple and easy way to

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Marc Schütz
On Friday, 28 February 2014 at 11:11:28 UTC, Dicebot wrote: On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: Chaining . operation is a code smell to begin with It is? Why? If a system is well-designed, then null state either means something (and needs to be explicitly

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread John Colvin
On Friday, 28 February 2014 at 11:11:28 UTC, Dicebot wrote: On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: Chaining . operation is a code smell to begin with It is? Why? If a system is well-designed, then null state either means something (and needs to be explicitly

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Kapps
On Friday, 28 February 2014 at 11:21:47 UTC, Marc Schütz wrote: I sometimes come across situations like this: writeln_or_whatever(person ? person.name : ); (This is a case of means something.) Using `person?.name` is a bit shorter and DRYer. But it would be more useful if I could specify

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Dicebot
On Friday, 28 February 2014 at 12:28:22 UTC, John Colvin wrote: Do you mean: Chaining operations that can return null (or some other known-to-be-invalid state) is a code-smell. That's quite different to saying: Chaining operations using . is a code-smell. which is what deadalnix said.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread deadalnix
On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread deadalnix
On Friday, 28 February 2014 at 12:28:22 UTC, John Colvin wrote: Do you mean: Chaining operations that can return null (or some other known-to-be-invalid state) is a code-smell. That is the worse. That's quite different to saying: Chaining operations using . is a code-smell. which is

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread SomeDude
On Friday, 28 February 2014 at 11:21:47 UTC, Marc Schütz wrote: On Friday, 28 February 2014 at 11:11:28 UTC, Dicebot wrote: On Friday, 28 February 2014 at 09:24:23 UTC, John Colvin wrote: Chaining . operation is a code smell to begin with It is? Why? If a system is well-designed, then null

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-28 Thread Araq
Yes. That must not be understood as a hard rule, but something that is true most of the time. You want to look up Law of Demeter. No, it's not true most of the time. It's just another piece of arbitrary crap from the object oriented cargo cult that has no scientific basis. The problem when

Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Remo
Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ?

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Asman01
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I was

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I like

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Jesse Phillips
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Wish I

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Robert Clipsham
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? D doesn't

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence I don't need D.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Robert Clipsham
On Thursday, 27 February 2014 at 16:32:18 UTC, Chris Williams wrote: On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 17:02:02 UTC, Robert Clipsham wrote: On Thursday, 27 February 2014 at 16:32:18 UTC, Chris Williams wrote: On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Robert Clipsham
On Thursday, 27 February 2014 at 17:25:22 UTC, Chris Williams wrote: just(myObject).method1().method2().method3() You can't do that. You're reducing your example code - which was several dozen lines and only applied to objects for which you had added the special handler code - to the end

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread deadalnix
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? Chaining

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Jacob Carlborg
On 2014-02-27 14:27, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I like it. -- /Jacob Carlborg

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Peter Alexander
On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Steven Schveighoffer
On Thu, 27 Feb 2014 16:20:47 -0500, Peter Alexander peter.alexander...@gmail.com wrote: On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Steven Schveighoffer
On Thu, 27 Feb 2014 16:45:11 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: ifnull(parent).child.child.child brain fart... ifvalid(parent).child.child.child -Steve

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Araq
On Thursday, 27 February 2014 at 20:49:59 UTC, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread deadalnix
On Thursday, 27 February 2014 at 21:49:20 UTC, Steven Schveighoffer wrote: On Thu, 27 Feb 2014 16:45:11 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: ifnull(parent).child.child.child brain fart... ifvalid(parent).child.child.child -Steve What you want is a maybe monad, and we

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Russel Winder
On Thu, 2014-02-27 at 20:49 +, deadalnix wrote: On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx