Account Options

  1. Anmelden
Das alte Google Groups wird demnächst nicht mehr unterstützt. Die neue Version ist jedoch nicht kompatibel mit Ihrem Browser.
Google Groups-Startseite
« Google Groups-Startseite
Nachricht von Diskussion Non-null reference types
Bei der Gruppe, für die Sie eine Mitteilung verfassen, handelt es sich um eine Usenet-Gruppe. Wenn Sie in dieser Gruppe Nachrichten posten, ist Ihre E-Mail-Adresse für jeden im Internet sichtbar
Ihre Antwort wurde nicht gesendet.
Die Nachricht wurde übermittelt.
 
Von:
An:
Cc:
Nachtrag zu:
Cc hinzufügen | Nachtrag hinzufügen zu | Betreff bearbeiten
Betreff:
Bestätigung:
Geben Sie zur Bestätigung die im folgenden Bild angezeigten Zeichen ein bzw. die Zahlen, die durchgesagt werden, wenn Sie auf das Barrierefreiheitssymbol klicken. Hören Sie zu und geben Sie die gehörten Zahlen ein
 
Justin du coeur  
Profil anzeigen   Übersetzen in die Sprache: Übersetzt (Original anzeigen)
 Weitere Optionen 26 Aug. 2012, 11:43
Von: Justin du coeur <jduco...@gmail.com>
Datum: Sun, 26 Aug 2012 11:43:29 -0400
Lokal: So 26 Aug. 2012 11:43
Betreff: Re: [scala-debate] Non-null reference types

On Sat, Aug 25, 2012 at 4:46 PM, Matthew Pocock <

turingatemyhams...@gmail.com> wrote:
> I think everyone can agree that nulls are from the devil and null pointer
> exceptions are his spawn. However, doing anything about it is complicated
> by Java interop and legacy. If I had the choice, I'd make every type T be
> disjoint from null except for  `Nullable[T]`. It would be a compilation
> error to assign null to anything except Nullable[T], and un-annotated code
> from outside scala would be presumed to be Nullable types.

+1 -- I suspect getting there from here is difficult in practice (due to
scads of existing code), but this makes oodles of sense in principle.  If
the only real reason Scala supports null is interop (and I think that's
true of good idiomatic Scala), it should be treated as such and made
explicit.  And changing the *default* behaviour from with-null to
without-null would lead folks to better and safer code pretty efficiently.
 Programmers are lazy, so we really should avoid having an easy, lazy path
to using nulls.

I'm rather conscious of this at the moment.  I'm finally doing Scala
full-time for the time being, and caught myself last week initializing a
variable with null because it saved me a line.  I did a double-take an hour
later and Optioned it, but it did drive home that most folks will sometimes
take the lazy road if it's available.  The beauty of Scala is largely that
the most concise approach is typically the most *correct* one -- this is a
rare exception currently.  Making null *inconvenient* would likely be a
boon in the long run.

Has anybody written a compiler plugin to do this?  Adding a plugin, then a
switch, and encouraging folks to use it, seems like a safe and sensible
step here.  (I'd require usage of it in my startup...)


 
Sie müssen sich anmelden, bevor Sie Nachrichten veröffentlichen können.
Bevor Sie eine Nachricht posten können, müssen Sie zunächst dieser Gruppe beitreten.
Bitte aktualisieren Sie vor dem Posten in den Abonnementeinstellungen Ihren Spitznamen.
Sie haben nicht die erforderliche Berechtigung zum Posten.