[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 bearophile_h...@eml.cc changed: What|Removed |Added Status|NEW |RESOLVED Resolution||WONTFIX --- Comment #7 from bearophile_h...@eml.cc 2013-04-06 06:37:46 PDT --- Closed down by request by Andrei: http://forum.dlang.org/post/kjp56a$e1s$1...@digitalmars.com Not-nullable reference types have gained appreciation in almost every type-rich recently designed languages, as F#, Scala, Rust, and few Java-Like languages running on the JavaVM. I think all type-rich languages that will be designed in future will have nonnullable typing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #6 from bearophile_h...@eml.cc 2012-10-01 14:26:20 PDT --- A small program that shows three important things std.typecons.Nullable isn't able to do: import std.stdio, std.algorithm, std.typecons; alias Nullable!(int, -1) Position; void foo(int[] a, Position pos) /*nothrow*/ { // allow this to be nothrow if (pos.isNull) { return; } else { a[pos] = 10; // perform no nullness test here, optimization } } void bar(int[] a, Position pos) { a[pos] = 10; // compile-time error here? } void main() { auto data = [1, 2, 3, 4, 5]; auto p = Position(countUntil(data, 7)); foo(data, p); writeln(data); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #5 from bearophile_h...@eml.cc 2011-12-12 05:12:30 PST --- See also: http://eclipseandjazz.blogspot.com/2011/12/inter-procedural-null-analysis-using.html -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #4 from bearophile_h...@eml.cc 2010-11-04 13:41:10 PDT --- This good document explains very the very well though-out design and implementation of nonnullable reference types in Spec#: http://research.microsoft.com/en-us/um/people/leino/papers/krml189.pdf The article shows how to manage the nullable pointers/references with the help of if statements, assertions and casts too. It shows the need for annotations to denote both nullable and nonnullable version of a type. In D the nullable version may use ? and the nonnullable version may use @. So if T is a reference type parameter, then T is type parameter itself (that might be a nullable or not type), T? is the nullable version of T, and T@ is for the nonnullable version of T. The document also suggests a shorter syntax to cast a variable to a nullable or not nullable versione of its type: cast(@)someRef cast(?)someRef -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #3 from bearophile_h...@eml.cc 2010-10-21 17:52:56 PDT --- Another older partial implementation of typestates from Microsoft, in the Vault language: http://web.archive.org/web/20060706065107/research.microsoft.com/vault/learn/typing/typing.htm -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #1 from bearophile_h...@eml.cc 2010-08-26 16:41:58 PDT --- This is just half of a solution. Beside introducing nonnull pointers/references, and a handy syntax to denote them, to have a null-safe language you also need to require explicit tests every time a nullable pointers/references is about to be dereferenced, and then after this test in the else branch the reference type becomes a non-nullable one. This is an application of the idea of TypeState, used by the Mozilla Rust language. The type doesn't actually change, it's just its state that change. More on the concept of TypeState (at the moment it is not present in Wikipedia): http://www.google.com/search?q=typestate -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4571] Non-null class references/pointers
http://d.puremagic.com/issues/show_bug.cgi?id=4571 --- Comment #2 from bearophile_h...@eml.cc 2010-08-26 17:27:34 PDT --- An example implementation of TypeState for Java: http://www.warski.org/blog/?cat=9 http://www.warski.org/typestate.html The original paper about typestates, Typestate: A Programming Language Concept for Enhancing Software Reliability, by Robert E. Strom and Shaula Yemini, 1986: http://www.cs.cmu.edu/~aldrich/papers/classic/tse12-typestate.pdf A version for dotnet, Typestates for Objects, by R. DeLine and M. F�hnrich: http://www.cs.cmu.edu/~aldrich/courses/819/slides/typestates.ppt http://research.microsoft.com/apps/pubs/default.aspx?id=67458 The software: http://research.microsoft.com/en-us/projects/fugue/ (But it says Fugue is no longer supported as a tool. However, check out our related project called CodeContracts.) More on the topic: http://www.cs.cmu.edu/~aldrich/papers/onward2009-state.pdf -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---