Re: OptionalT equivalent in D?

2013-11-16 Thread Michael
On Friday, 15 November 2013 at 22:39:40 UTC, Jacek Furmankiewicz wrote: Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an OptionalT like in Scala:

Re: OptionalT equivalent in D?

2013-11-16 Thread Meta
On Saturday, 16 November 2013 at 05:04:42 UTC, Jonathan M Davis wrote: I really don't understand this. OptionalT is one of the most useless ideas that I've ever seen in Java. Just use null. It's built into the language. It works just fine. And wrapping it in a class isn't going to make it go

Re: OptionalT equivalent in D?

2013-11-16 Thread Max Klyga
On 2013-11-16 05:04:20 +, Jonathan M Davis said: I really don't understand this. OptionalT is one of the most useless ideas that I've ever seen in Java. Just use null. Optional specifies explicitly that value can be absent and forces client to check before using the value. Also, if

Re: OptionalT equivalent in D?

2013-11-16 Thread Russel Winder
On Sat, 2013-11-16 at 00:04 -0500, Jonathan M Davis wrote: […] I really don't understand this. OptionalT is one of the most useless ideas that I've ever seen in Java. Just use null. It's built into the language. It works just fine. And wrapping it in a class isn't going to make it go away.

Re: OptionalT equivalent in D?

2013-11-16 Thread Ary Borenszweig
On 11/16/13 7:41 AM, Max Klyga wrote: On 2013-11-16 05:04:20 +, Jonathan M Davis said: I really don't understand this. OptionalT is one of the most useless ideas that I've ever seen in Java. Just use null. Optional specifies explicitly that value can be absent and forces client to check

Re: OptionalT equivalent in D?

2013-11-16 Thread Jonathan M Davis
On Saturday, November 16, 2013 11:18:38 Meta wrote: On Saturday, 16 November 2013 at 05:04:42 UTC, Jonathan M Davis wrote: I really don't understand this. OptionalT is one of the most useless ideas that I've ever seen in Java. Just use null. It's built into the language. It works

Re: OptionalT equivalent in D?

2013-11-16 Thread Meta
On Saturday, 16 November 2013 at 23:34:55 UTC, Jonathan M Davis wrote: If you want to use the type system to try and protect against dereferencing null, then having wrapper which guarantees that the object _isn't_ null makes a lot more sense, particularly when just because you used OptionalT

OptionalT equivalent in D?

2013-11-15 Thread Jacek Furmankiewicz
Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an OptionalT like in Scala: http://blog.danielwellman.com/2008/03/using-scalas-op.html Google Guava for Java: (now rolled into the base JDK

Re: OptionalT equivalent in D?

2013-11-15 Thread Brad Anderson
On Friday, 15 November 2013 at 22:39:40 UTC, Jacek Furmankiewicz wrote: Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an OptionalT like in Scala:

Re: OptionalT equivalent in D?

2013-11-15 Thread Jacek Furmankiewicz
Thanks! std.typecons definitely looks like something I need to dig into.

Re: OptionalT equivalent in D?

2013-11-15 Thread Brad Anderson
On Friday, 15 November 2013 at 22:41:40 UTC, Brad Anderson wrote: On Friday, 15 November 2013 at 22:39:40 UTC, Jacek Furmankiewicz wrote: Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an

Re: OptionalT equivalent in D?

2013-11-15 Thread Justin Whear
On Fri, 15 Nov 2013 23:41:38 +0100, Brad Anderson wrote: On Friday, 15 November 2013 at 22:39:40 UTC, Jacek Furmankiewicz wrote: Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an OptionalT

Re: OptionalT equivalent in D?

2013-11-15 Thread bearophile
Justin Whear: No, Nullable adds a potential null state to value types, e.g. it allows you to null an int. In std.typecons there is another version of Nullable, that uses a state as null. So you can use it as nullable class reference. Is that good enough for the OP? Bye, bearophile

Re: OptionalT equivalent in D?

2013-11-15 Thread Jonathan M Davis
On Friday, November 15, 2013 23:39:38 Jacek Furmankiewicz wrote: Many other languages are starting to frown on returning null values from methods (due to NullPointerException risks, etc) and wrapping them instead in an OptionalT like in Scala: