Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-29 Thread Nick Treleaven via Digitalmars-d
On Sunday, 19 November 2017 at 22:54:38 UTC, Walter Bright wrote: I can't see the problem. You go from nullable to non-nullable by checking for null, and the other direction happens implicitly. Implicit conversions have their problems with overloading, The C# implementation doesn't affect

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Ola Fosheim Grostad via Digitalmars-d
On Saturday, 25 November 2017 at 01:23:03 UTC, codephantom wrote: And thankyou. This a much more constructive option for users that disagree with something I say. i.e. Now they can just hide me, instead of attacking me. Dont worry, both Walter and Andrei have done far worse in these fora

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Saturday, 25 November 2017 at 01:00:43 UTC, Timon Gehr wrote: Given that it can be accomplished on the client side, it is actually easy to not display posts from specific users. Civility returns. Horray... And thankyou. This a much more constructive option for users that disagree with

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Timon Gehr via Digitalmars-d
On 24.11.2017 13:10, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: ... not being able to edit posts. ... It's not as much of a problem as not being able to hide all posts by a user ... Given that it can be accomplished on the client side, it is

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not being able to hide all posts by a user who repeats arguments,

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 23:36:08 UTC, Bobb wrote: On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts.

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 23:55:58 UTC, lobo wrote: On Friday, 24 November 2017 at 23:36:08 UTC, Bobb wrote: On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC,

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 23:01:04 UTC, Meta wrote: On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts.

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread lobo via Digitalmars-d
On Friday, 24 November 2017 at 23:36:08 UTC, Bobb wrote: On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts.

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Bobb via Digitalmars-d
On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Meta via Digitalmars-d
On Friday, 24 November 2017 at 20:29:23 UTC, codephantom wrote: On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not being able to hide all posts by a user who repeats arguments,

Re: [OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread codephantom via Digitalmars-d
On Friday, 24 November 2017 at 12:10:28 UTC, Nick Treleaven wrote: On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not being able to hide all posts by a user who repeats arguments,

[OT] Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-24 Thread Nick Treleaven via Digitalmars-d
On Thursday, 23 November 2017 at 06:35:17 UTC, codephantom wrote: I love not being able to edit posts. It's so convenient. It's not as much of a problem as not being able to hide all posts by a user who repeats arguments, derails the conversation onto irrelevant side discussions and judges

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 10:20:49 UTC, Jonathan M Davis wrote: LOL. I assumed that you were legitimately asking what the name of his compiler was, because I knew that he was writing a D compiler, whereas you were questioning his knowledge/credentials. Timon is a very smart guy. He

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 18:16:16 UTC, Wyatt wrote: Perhaps that's why I've never considered nulls to be an issue. I take proactive steps to protect my code, before the compiler ever sees it. And actually, I cannot recall any null related error in any code I've deployed. It's just

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread Ola Fosheim Grøstad via Digitalmars-d
On Thursday, 23 November 2017 at 08:47:43 UTC, codephantom wrote: Many high level languages let you use 'unsafe' code, where you can write erroneous operations - and then you're back in the world of undefined behaviour. Not many, but many allow interfacing with C, then it is up to those user

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread rjframe via Digitalmars-d
On Thu, 23 Nov 2017 01:08:45 +, codephantom wrote: > So yeah, you can change the language.. or you can change the way people > think about their code. When they think differently, their code will > change accordingly. > > My point about sophisticated IDE's and AI like compilers, is that they

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 07:20:41 UTC, Ola Fosheim Grostad wrote: On Thursday, 23 November 2017 at 01:16:59 UTC, codephantom wrote: That's why we have the concept of 'undefined behaviour'. Errr, no. High level programming languages don't have undefined behaviour. That is a C concept

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-23 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 07:13:37 UTC, Ola Fosheim Grostad wrote: Heh, has the Goldbach conjecture been proven undecidable? Not to my knowledge ;-) At best, it's a possiblity - which can go either way. No human or computer will ever make it anything more than that. Ever. Someone

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Ola Fosheim Grostad via Digitalmars-d
On Thursday, 23 November 2017 at 01:16:59 UTC, codephantom wrote: That's why we have the concept of 'undefined behaviour'. Errr, no. High level programming languages don't have undefined behaviour. That is a C concept related to the performance of the executable. C tries to get as close to

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Ola Fosheim Grostad via Digitalmars-d
On Thursday, 23 November 2017 at 01:33:39 UTC, codephantom wrote: On Thursday, 23 November 2017 at 00:15:56 UTC, Ola Fosheim Grostad wrote: By what proof? And what do you mean by mathematics? A mathematical claim, that cannot be proven or disproven, is neither true or false. What you are

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 06:32:30 UTC, codephantom wrote: Here is another demonstation of why you can trust your compiler: Why you "can't" ... is what i meant to say. I love not being able to edit posts. It's so convenient.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:39:21 UTC, codephantom wrote: On Wednesday, 22 November 2017 at 00:19:51 UTC, codephantom wrote: Its seems to be, that you prefer to rely on the type system, during compilation, for safety. This is very unwise. To demonstrate my point, using code from a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 00:15:56 UTC, Ola Fosheim Grostad wrote: By what proof? And what do you mean by mathematics? A mathematical claim, that cannot be proven or disproven, is neither true or false. What you are left with, is just a possibility. Thus, it will always remain an

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Thursday, 23 November 2017 at 00:15:56 UTC, Ola Fosheim Grostad wrote: On Thursday, 23 November 2017 at 00:06:49 UTC, codephantom wrote: true up to a number < n ... does not address the conjecture correctly. So what? We only need to a proof up to N for regular programming, if at all.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 18:16:16 UTC, Wyatt wrote: "Need"? Perhaps not. But so far, I haven't seen any arguments that refute the utility of mitigating patterns of human error. Ok. that's a good point. But there is more than one way to address human error without having to

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Ola Fosheim Grostad via Digitalmars-d
On Thursday, 23 November 2017 at 00:06:49 UTC, codephantom wrote: true up to a number < n ... does not address the conjecture correctly. So what? We only need to a proof up to N for regular programming, if at all. hint. It's not a problem that mathmatics can solve. By what proof? And

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 22:02:11 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 November 2017 at 04:55:39 UTC, codephantom wrote: Consider the Goldbach Conjecture, that every even positive integer greater than 2 is the sum of two (not necessarily distinct) primes. According to the

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 22 November 2017 at 04:55:39 UTC, codephantom wrote: Consider the Goldbach Conjecture, that every even positive integer greater than 2 is the sum of two (not necessarily distinct) primes. According to the principle of bivalence, this should be either true or false. «The

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 22 November 2017 at 17:17:07 UTC, Mark wrote: On Tuesday, 21 November 2017 at 09:12:25 UTC, Ola Fosheim Grostad wrote: Runtime checks are part of the type system though I wouldn't say that, particularly if we are talking about a statically typed language (which Java is). Very

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Wyatt via Digitalmars-d
On Wednesday, 22 November 2017 at 14:51:02 UTC, codephantom wrote: The core language of D does NOT need what C# is proposing - that is my view. "Need"? Perhaps not. But so far, I haven't seen any arguments that refute the utility of mitigating patterns of human error. If, over time, a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Mark via Digitalmars-d
On Tuesday, 21 November 2017 at 09:12:25 UTC, Ola Fosheim Grostad wrote: Runtime checks are part of the type system though I wouldn't say that, particularly if we are talking about a statically typed language (which Java is).

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 13:21:05 UTC, Timon Gehr wrote: BTW of course you must realize that you can make the compiler brutally obsolete by just quickly writing down the most efficient possible correct machine code in a hex editor, so I'm not too sure why you participate in a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 13:21:05 UTC, Timon Gehr wrote: You do realise, that all of the issues you mention can just be handled by coding correctly in the first place. ... Yes, just like everyone else, I realize that if correct code is written, we end up with correct code, but

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 13:21:05 UTC, Timon Gehr wrote: On 22.11.2017 01:19, codephantom wrote: No, I ideally want the type system to point out when the code is not obviously correct. That does not mean I assume that the code is correct when it compiles (given that I'm using a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 13:47:19 UTC, Timon Gehr wrote: On 22.11.2017 05:55, codephantom wrote: No, the question should be, what can the compiler prove to be true/false, correct/incorrect about your code, and what effort have you made in your code to assist the compiler to make that

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Timon Gehr via Digitalmars-d
On 22.11.2017 05:55, codephantom wrote: ... >> The question isn't whether we should use the type system to prevent bugs. The question is which set of problems really make sense to prevent with the type system. No, the question should be, what can the compiler prove to be true/false,

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Timon Gehr via Digitalmars-d
On 22.11.2017 02:09, codephantom wrote: On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis wrote: While I definitely don't think that it's generally very hard to avoid bugs with null pointers/references, telling someone to code correctly in the first place isn't very useful.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Timon Gehr via Digitalmars-d
On 22.11.2017 01:19, codephantom wrote: On Tuesday, 21 November 2017 at 20:02:06 UTC, Timon Gehr wrote: I'm confident that you would be able to use null safe languages properly if that is what had been available for most of your career. You do realise, that all of the issues you mention

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, November 22, 2017 09:28:47 codephantom via Digitalmars-d wrote: > On Wednesday, 22 November 2017 at 08:55:03 UTC, Petar Kirov > > [ZombineDev] wrote: > > On Wednesday, 22 November 2017 at 00:19:51 UTC, codephantom > > > > wrote: > >> btw. what was the last compiler you wrote? > > >

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 08:55:03 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 22 November 2017 at 00:19:51 UTC, codephantom wrote: btw. what was the last compiler you wrote? https://github.com/eth-srl/psi https://github.com/tgehr/d-compiler touché ;-) nonetheless. I stand

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-22 Thread Petar via Digitalmars-d
On Wednesday, 22 November 2017 at 00:19:51 UTC, codephantom wrote: btw. what was the last compiler you wrote? https://github.com/eth-srl/psi https://github.com/tgehr/d-compiler

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis wrote: Any time the type system can prevent a bug, it's useful. I don't see why that would be a problem or unwise. That is not unwise. What is 'unwise' is what I said was unwise..that is, putting your trust in the compiler's

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 01:48:55 UTC, Jonathan M Davis wrote: In the case of null, you _can_ prove it if you have non-nullable types. True (well...you can at least 'assert' it anyway). But if the intention is to 'assist the compiler towards knowing the truth/correctness about your

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, November 22, 2017 01:25:48 codephantom via Digitalmars-d wrote: > On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis > > wrote: > > The question isn't whether we should use the type system to > > prevent bugs. The question is which set of problems really make > > sense

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis wrote: While I definitely don't think that it's generally very hard to avoid bugs with null pointers/references, telling someone to code correctly in the first place isn't very useful. By 'correct code', I mean code that assists

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis wrote: The question isn't whether we should use the type system to prevent bugs. The question is which set of problems really make sense to prevent with the type system. - Jonathan M Davis Those that can be proven.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:49:02 UTC, Jonathan M Davis wrote: While I definitely don't think that it's generally very hard to avoid bugs with null pointers/references, telling someone to code correctly in the first place isn't very useful. Fair enough...perhaps I'm being too

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, November 22, 2017 00:19:51 codephantom via Digitalmars-d wrote: > On Tuesday, 21 November 2017 at 20:02:06 UTC, Timon Gehr wrote: > > I'm confident that you would be able to use null safe languages > > properly if that is what had been available for most of your > > career. > > You

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Wednesday, 22 November 2017 at 00:19:51 UTC, codephantom wrote: Its seems to be, that you prefer to rely on the type system, during compilation, for safety. This is very unwise. To demonstrate my point, using code from a 'safe' language (C#): (i.e. should this compile?) //

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread codephantom via Digitalmars-d
On Tuesday, 21 November 2017 at 20:02:06 UTC, Timon Gehr wrote: I'm confident that you would be able to use null safe languages properly if that is what had been available for most of your career. You do realise, that all of the issues you mention can just be handled by coding correctly

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Timon Gehr via Digitalmars-d
On 21.11.2017 07:46, Dmitry Olshansky wrote: The spec describes unsound language, the hole in type-system are plugged at VM level by run-time checks. Also this jawel: Cat[] cats = new Cat[3]; ... Animals[] animals = cats; // the same array animals[0] = new Dog(); cats[0].smth(); //

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Timon Gehr via Digitalmars-d
On 19.11.2017 23:54, Walter Bright wrote: ... > There's also an issue of how to derive a class from a base class. ... How so? While we are talking applicability to D: The main issue is to ensure that fields of objects are initialized properly before being accessed. D already needs to do

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Ola Fosheim Grøstad via Digitalmars-d
On Tuesday, 21 November 2017 at 18:00:37 UTC, Meta wrote: I don't quite understand the logic here, because it seems to be backwards reasoning. Constrain is a valid type because null inhabits it? That doesn't make sense to me. He also cites the "implicit constraint" that X extends

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Meta via Digitalmars-d
On Tuesday, 21 November 2017 at 09:12:25 UTC, Ola Fosheim Grostad wrote: On Tuesday, 21 November 2017 at 06:03:33 UTC, Meta wrote: I'm not clear on whether he means that Java's type system is unsound, or that the type checking algorithm is unsound. From what I can tell, he's asserting the

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-21 Thread Ola Fosheim Grostad via Digitalmars-d
On Tuesday, 21 November 2017 at 06:03:33 UTC, Meta wrote: I'm not clear on whether he means that Java's type system is unsound, or that the type checking algorithm is unsound. From what I can tell, he's asserting the former but describing the latter. He claims that type systems with

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Dmitry Olshansky via Digitalmars-d
On Tuesday, 21 November 2017 at 06:03:33 UTC, Meta wrote: On Tuesday, 21 November 2017 at 01:03:36 UTC, Mark wrote: On Monday, 20 November 2017 at 22:56:44 UTC, Walter Bright wrote: On 11/20/2017 3:27 AM, Timon Gehr wrote: This blog post seems to summarize the paper he linked to:

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Meta via Digitalmars-d
On Tuesday, 21 November 2017 at 01:03:36 UTC, Mark wrote: On Monday, 20 November 2017 at 22:56:44 UTC, Walter Bright wrote: On 11/20/2017 3:27 AM, Timon Gehr wrote: On 20.11.2017 11:07, Atila Neves wrote: The problem with null as seen in C++/Java/D is that it's a magical value that different

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Walter Bright via Digitalmars-d
On 11/20/2017 5:03 PM, Mark wrote: On Monday, 20 November 2017 at 22:56:44 UTC, Walter Bright wrote: On 11/20/2017 3:27 AM, Timon Gehr wrote: On 20.11.2017 11:07, Atila Neves wrote: The problem with null as seen in C++/Java/D is that it's a magical value that different types may have. It

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Mark via Digitalmars-d
On Monday, 20 November 2017 at 22:56:44 UTC, Walter Bright wrote: On 11/20/2017 3:27 AM, Timon Gehr wrote: On 20.11.2017 11:07, Atila Neves wrote: The problem with null as seen in C++/Java/D is that it's a magical value that different types may have. It breaks the type system. In Java,

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Walter Bright via Digitalmars-d
On 11/20/2017 3:27 AM, Timon Gehr wrote: On 20.11.2017 11:07, Atila Neves wrote: The problem with null as seen in C++/Java/D is that it's a magical value that different types may have. It breaks the type system. In Java, quite literally so. The Java type system is /unsound/ because of null.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Nick Treleaven via Digitalmars-d
On Sunday, 19 November 2017 at 22:54:38 UTC, Walter Bright wrote: There's also an issue of how to derive a class from a base class. If you want null, use a nullable type: Base b = ...; Derived? d = cast(Derived?) base; if (d !is null) d.method; This implies one must know all the use cases of

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Ola Fosheim Grøstad via Digitalmars-d
On Monday, 20 November 2017 at 11:27:15 UTC, Timon Gehr wrote: On 20.11.2017 11:07, Atila Neves wrote: As you can guess, I happen to like null, because there are no hidden bugs from pretending it is a valid value - you get an immediate program halt - rather than subtly corrupted results.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Timon Gehr via Digitalmars-d
On 20.11.2017 11:07, Atila Neves wrote: As you can guess, I happen to like null, because there are no hidden bugs from pretending it is a valid value - you get an immediate program halt - rather than subtly corrupted results. The problem with null as seen in C++/Java/D is that it's a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Dukc via Digitalmars-d
On Monday, 20 November 2017 at 10:45:20 UTC, Dukc wrote: A type that wraps a reference type behaving like a value type. Default initialized value and what to do on copy would be passed as template parameters. Perhaps I should try... Just realized Unique!T is already pretty close. A few

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Ola Fosheim Grøstad via Digitalmars-d
On Monday, 20 November 2017 at 10:07:08 UTC, Atila Neves wrote: The problem with null as seen in C++/Java/D is that it's a magical value that different types may have. It breaks the type system. Not sure if it breaks the type system, but it would be cleaner to construct types with null

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Dukc via Digitalmars-d
On Sunday, 19 November 2017 at 04:04:04 UTC, Walter Bright wrote: Interestingly, `int` isn't nullable, and we routinely use rather ugly hacks to fake it being nullable, like reserving a bit pattern like 0, -1 or 0xDEADBEEF and calling it INVALID_VALUE, or carrying around some other separate

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Atila Neves via Digitalmars-d
On Sunday, 19 November 2017 at 04:04:04 UTC, Walter Bright wrote: On 11/18/2017 6:25 PM, Timon Gehr wrote: I.e., baseClass should have type Nullable!ClassDeclaration. This does not in any form imply that ClassDeclaration itself needs to have a null value. Converting back and forth between

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread codephantom via Digitalmars-d
On Monday, 20 November 2017 at 08:55:54 UTC, Biotronic wrote: On Monday, 20 November 2017 at 08:49:41 UTC, rumbu wrote: In fact, this is the introduction of a new operator "!", probably named "I know better" operator. It's called the "bang" operator, because of how things blow up when you're

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread Biotronic via Digitalmars-d
On Monday, 20 November 2017 at 08:49:41 UTC, rumbu wrote: In fact, this is the introduction of a new operator "!", probably named "I know better" operator. It's called the "bang" operator, because of how things blow up when you're wrong.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-20 Thread rumbu via Digitalmars-d
On Monday, 20 November 2017 at 06:24:31 UTC, Tobias Müller wrote: Timon Gehr wrote: I wish there was a null for int types. AFAIU, C# will now have 'int?'. C# had 'int?' (nullable value types) for ages. The new thing is explicitly nullable classes (reference types). I'm

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-19 Thread Tobias Müller via Digitalmars-d
Timon Gehr wrote: >> I wish there was a null >> for int types. > > AFAIU, C# will now have 'int?'. C# had 'int?' (nullable value types) for ages. The new thing is explicitly nullable classes (reference types). I'm really looking forward to use those.

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-19 Thread Walter Bright via Digitalmars-d
On 11/19/2017 11:36 AM, Timon Gehr wrote: On 19.11.2017 05:04, Walter Bright wrote: On 11/18/2017 6:25 PM, Timon Gehr wrote: I.e., baseClass should have type Nullable!ClassDeclaration. This does not in any form imply that ClassDeclaration itself needs to have a null value. Converting back

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-19 Thread Timon Gehr via Digitalmars-d
On 19.11.2017 05:04, Walter Bright wrote: On 11/18/2017 6:25 PM, Timon Gehr wrote: I.e., baseClass should have type Nullable!ClassDeclaration. This does not in any form imply that ClassDeclaration itself needs to have a null value. Converting back and forth between the two types doesn't

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-19 Thread Patrick Schluter via Digitalmars-d
On Sunday, 19 November 2017 at 04:19:32 UTC, codephantom wrote: On Sunday, 19 November 2017 at 04:04:04 UTC, Walter Bright wrote: I wish there was a null for int types. At least we sort of have one for char types, 0xFF. And there's that lovely NaN for floating point! Too bad it's woefully

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread codephantom via Digitalmars-d
On Sunday, 19 November 2017 at 04:04:04 UTC, Walter Bright wrote: I wish there was a null for int types. At least we sort of have one for char types, 0xFF. And there's that lovely NaN for floating point! Too bad it's woefully underused. "I wish there was a null for int types." +1000

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Walter Bright via Digitalmars-d
On 11/18/2017 6:25 PM, Timon Gehr wrote: I.e., baseClass should have type Nullable!ClassDeclaration. This does not in any form imply that ClassDeclaration itself needs to have a null value. Converting back and forth between the two types doesn't sound appealing. What should the default

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread RomanZ via Digitalmars-d
Is it possible to somehow change the concept of uninitialized values to something like 'zeroOrOne' instead of 'null'? Instrument instrument1 = new Instrument(); Instrument instrument2 = new Instrument(); zeroOrOne!Instrument getInstrument() { zeroOrOne!Instrument instrument;

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Timon Gehr via Digitalmars-d
On 19.11.2017 01:07, Walter Bright wrote: On 11/18/2017 6:16 AM, Timon Gehr wrote: On 18.11.2017 05:05, Walter Bright wrote: On 11/17/2017 6:05 AM, Timon Gehr wrote: There are type systems that do that, which is what is being proposed for C#. It's pretty straightforward: If I have a variable

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Jonathan M Davis via Digitalmars-d
On Saturday, November 18, 2017 15:24:49 Timon Gehr via Digitalmars-d wrote: > On 17.11.2017 15:53, Jonathan M Davis wrote: > > On Friday, November 17, 2017 15:05:48 Timon Gehr via Digitalmars-d wrote: > >> On 17.11.2017 12:22, Jonathan M Davis wrote: > >>> On Friday, November 17, 2017 09:44:01

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Walter Bright via Digitalmars-d
On 11/18/2017 6:16 AM, Timon Gehr wrote: On 18.11.2017 05:05, Walter Bright wrote: On 11/17/2017 6:05 AM, Timon Gehr wrote: There are type systems that do that, which is what is being proposed for C#. It's pretty straightforward: If I have a variable of class reference type C, it actually

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Timon Gehr via Digitalmars-d
On 17.11.2017 15:53, Jonathan M Davis wrote: On Friday, November 17, 2017 15:05:48 Timon Gehr via Digitalmars-d wrote: On 17.11.2017 12:22, Jonathan M Davis wrote: On Friday, November 17, 2017 09:44:01 rumbu via Digitalmars-d wrote: I know your aversion towards C#, but this not about C#, it's

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-18 Thread Timon Gehr via Digitalmars-d
On 18.11.2017 05:05, Walter Bright wrote: On 11/17/2017 6:05 AM, Timon Gehr wrote: There are type systems that do that, which is what is being proposed for C#. It's pretty straightforward: If I have a variable of class reference type C, it actually contains a reference to a class instance of

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread codephantom via Digitalmars-d
On Saturday, 18 November 2017 at 04:56:19 UTC, codephantom wrote: First semester, programming course. Write a life-essential system in C, and simulate it. If patient dies, you fail. Second semester. Find vulnerability in another students semester 1 project. If you succeed, they fail the

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread codephantom via Digitalmars-d
On Saturday, 18 November 2017 at 03:39:50 UTC, Adam D. Ruppe wrote: If you have a life-essential system that can't survive a single part randomly failing, including a process terminating abnormally, you're an incompetent engineer. First semester, programming course. Write a life-essential

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Walter Bright via Digitalmars-d
On 11/16/2017 5:47 PM, Michael V. Franklin wrote: the lack of any warning or error for this trivial case surprised me. Consider the following code: void test() { int* p; *p = 3; } Compiling it with -O gives: Error: null dereference in function _D5test54testFNaZv The -O is

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Walter Bright via Digitalmars-d
On 11/17/2017 6:05 AM, Timon Gehr wrote: There are type systems that do that, which is what is being proposed for C#. It's pretty straightforward: If I have a variable of class reference type C, it actually contains a reference to a class instance of type C. One of the difficulties with this

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread codephantom via Digitalmars-d
On Friday, 17 November 2017 at 15:27:06 UTC, Jesse Phillips wrote: It is interesting that you mention this. Our product manager was talking to our senior developer about this very thing. He explained that it was a method of development that an employee at his previous company came up with at

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 18 November 2017 at 03:33:00 UTC, codephantom wrote: If your code dereferences a null pointer, and the program segfaults, and that program is supplying me with the oxygen i need to survive...then its probably not safe ;-) If you have a life-essential system that can't survive a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread codephantom via Digitalmars-d
On Friday, 17 November 2017 at 14:53:40 UTC, Jonathan M Davis wrote: Regardless, given that dereferencing null will segfault, it does not present an @safety problem. "A notion of safety is always relative to some criterion". If your code dereferences a null pointer, and the program

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread codephantom via Digitalmars-d
On Friday, 17 November 2017 at 12:18:47 UTC, Atila Neves wrote: That's the whole point of using a safe language, otherwise we'd be fine with C. Personally, I would prefer to teach new students to program in C first - precisely because it's an unsafe language - or at least, can be used

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread jmh530 via Digitalmars-d
On Friday, 17 November 2017 at 14:53:40 UTC, Jonathan M Davis wrote: [snip] Regardless, given that dereferencing null will segfault, it does not present an @safety problem. @safe is really more of @memorysafe. Null safety is orthogonal to memory safety. I don't really use null much in D

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Jesse Phillips via Digitalmars-d
On Friday, 17 November 2017 at 10:45:13 UTC, codephantom wrote: I've always thought writing the correct code was the better option anyway. It is interesting that you mention this. Our product manager was talking to our senior developer about this very thing. He explained that it was a

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Jonathan M Davis via Digitalmars-d
On Friday, November 17, 2017 15:05:48 Timon Gehr via Digitalmars-d wrote: > On 17.11.2017 12:22, Jonathan M Davis wrote: > > On Friday, November 17, 2017 09:44:01 rumbu via Digitalmars-d wrote: > >> I know your aversion towards C#, but this not about C#, it's > >> about safety. And safety is one

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Timon Gehr via Digitalmars-d
On 17.11.2017 03:25, codephantom wrote: On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: It peeked my interested, because when I first started studying D, the lack of any warning or error for this trivial case surprised me. // Example A class Test {     int Value; }

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Timon Gehr via Digitalmars-d
On 17.11.2017 11:19, Jonathan M Davis wrote: If the compiler can't guarantee that your code is wrong, then that check should be left up to a linter. I.e., you think the following code should compile: class C{} void main(){ size_t a = 2; C b = a; size_t c = b; import

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Timon Gehr via Digitalmars-d
On 17.11.2017 12:22, Jonathan M Davis wrote: On Friday, November 17, 2017 09:44:01 rumbu via Digitalmars-d wrote: I know your aversion towards C#, but this not about C#, it's about safety. And safety is one of the D taglines. Completely aside from whether having the compile-time checks would

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Adam D. Ruppe via Digitalmars-d
On Friday, 17 November 2017 at 01:47:01 UTC, Michael V. Franklin wrote: It peeked my interested, because when I first started studying D, the lack of any warning or error for this trivial case surprised me. You wanna get freaked out? Try that very same trivial example with the `-O` option to

Re: Introducing Nullable Reference Types in C#. Is there hope for D, too?

2017-11-17 Thread Atila Neves via Digitalmars-d
On Friday, 17 November 2017 at 10:45:13 UTC, codephantom wrote: Sounds to me, like too many people are writing incorrect code in the first place, Also known as "writing code". and want to offload responsibility onto something other than themself. That's the whole point of using a safe

  1   2   >