Sent from my iPhone

On Dec 23, 2011, at 6:32 PM, "André Rømcke" <a...@ez.no> wrote:

2011/12/23 John Crenshaw <johncrens...@priacta.com>

> > From: Will Fitch [mailto:will.fi...@gmail.com]
> >
> > I would like to take this opportunity to query on a consensus:
> >
> > Would you prefer to allow methods with type hinted return values to
> return null at will, or add a marker noting that it *may* return null?
> >
> > Example: Return null at will
> >
> > public ArrayIterator getIterator()
> > {
> >    // something happened, will return null
> >    return null;
> > }
> >
> > Example: Return only if identified as such
> >
> > public ArrayIterator? getIterator()
> > {
> >     return null;
> > }
>
> I hate the syntax in the second example (using ?).
>


It looks strange, but easy to get used to. Two examples from C#:

public decimal? Grade { get; set; }

public Nullable<System.DateTime> Time { get; set; }



If it is decided that we continue down the road of limiting nullable
returns, and want to add an indicator, what about something like this:

public nullable ArrayIterator getIterator()

If the nullable token isn't declared, it can't return null.



>
> IMO allowing null should be the default unless specifically disallowed.


I disagree for the reasons mentioned by for instance Robert.
Type hints should be strict/explicit or not done at all.

Reply via email to