in reply to Re^3: Is // a "Null coalescing operator" ?
in thread Is // a "Null coalescing operator" ?

> So you ask "what does nullable type mean?" see? :)

no I don't see. My question was Is // a "Null coalescing operator" ? (look at the title...)

These C#-docs produce a knot in my brain, and I'm not sure if it makes sense to compare to a dynamically typed language like Perl.

Anyway in the meantime I found something clear in C# docs:

There is no value that signifies "undefined". In many programming applications, most notably database interactions, variables can exist in an undefined state. For example, a field in a database may contain the values true or false, but it may also contain no value at all. Similarly, reference types can be set to null to indicate that they are not initialized.

Perl (and JS and the others ...) has undef, e.g. whenever one declares a variable without initializing it.

my $is_undef;

IMHO the wikipedia article should have the name of Perl's operator, since it seems to be mainly a feature of dynamically typed languages.

Cheers Rolf

Replies are listed 'Best First'.
Re^5: Is // a "Null coalescing operator" ?
by JavaFan (Canon) on Aug 09, 2010 at 23:49 UTC
    I don't know C#, but what you quote refers to a database NULL. The term "coalesc" is something I associate with databases as well.

    A (relational) database NULL is certainly not equivalent to a Perl undef. Ignoring lots of details, the basic difference is:

    undef binary-OP defined-value -> defined-value NULL binary-OP not-NULL -> NULL
    In other words, once you have a NULL, if you apply operations to it (except a few special ones), you remain having a NULL. undef is quite different - it happily behaves like a defined value (0, or the empty string), and once you start applying (most) operations on it, it becomes defined.
    NULL + 1 == NULL undef + 1 == 1