Jump to page: 1 24  
Page
Thread overview
Option!T
Dec 10, 2013
JR
Dec 11, 2013
JR
Dec 11, 2013
qznc
Jul 01, 2014
Nick Sabalausky
Jul 01, 2014
Sebastian Graf
Dec 10, 2013
Max Klyga
Dec 10, 2013
Yota
Dec 10, 2013
Paulo Pinto
Dec 10, 2013
Paulo Pinto
Dec 10, 2013
bearophile
Dec 10, 2013
Max Klyga
Dec 10, 2013
monarch_dodra
Dec 10, 2013
deadalnix
Dec 10, 2013
monarch_dodra
Dec 10, 2013
Jesse Phillips
Dec 11, 2013
Idan Arye
Dec 11, 2013
Idan Arye
Jul 01, 2014
Shammah Chancellor
Jul 01, 2014
Sebastian Graf
Jul 01, 2014
Timon Gehr
Jul 01, 2014
Meta
Jul 01, 2014
Sebastian Graf
Jul 01, 2014
bearophile
Jul 01, 2014
Sebastian Graf
Jul 01, 2014
w0rp
Jul 01, 2014
Shammah Chancellor
Jul 02, 2014
Wanderer
Jul 02, 2014
Meta
Jul 02, 2014
w0rp
Jul 02, 2014
Shammah Chancellor
Jul 02, 2014
Dicebot
Jul 02, 2014
Shammah Chancellor
December 10, 2013
I talked to a programmer who knows Scala (among others) and he mentioned the usefulness of the Option type - a zero or one element collection (range in D terminology). Here's an article discussing it: http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html

We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a collection of exactly one value, but not a type for "a value of type T or nothing at all". Should we follow Scala's example and add it?


Andrei
December 10, 2013
On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
> We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a collection of exactly one value, but not a type for "a value of type T or nothing at all".

Is this not what Nullable!T is?
December 10, 2013
On 2013-12-10 17:28:26 +0000, Andrei Alexandrescu said:

> I talked to a programmer who knows Scala (among others) and he mentioned the usefulness of the Option type - a zero or one element collection (range in D terminology). Here's an article discussing it: http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html 
> 
> 
> We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a collection of exactly one value, but not a type for "a value of type T or nothing at all". Should we follow Scala's example and add it?
> 
> 
> Andrei

Yes! Option is super useful. Use it all the time in Scala and Java (via Guava library).
I suppose it will be defined as a range, so map will work on it?
One of the useful things about options are the ability to chain them via flatMap, will this usecase be handled?

December 10, 2013
On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
> I talked to a programmer who knows Scala (among others) and he mentioned the usefulness of the Option type - a zero or one element collection (range in D terminology). Here's an article discussing it: http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html

I really came to love Option when I was working in F#.  One of the things I love about F# is how the language strongly discourages nulls.  Even Anders went on video saying that he regretted making reference types nullable in C#.

Of course, there's no way to remove the nullable-by-default nature of reference types in D2, but a guy can dream. =]
December 10, 2013
On 12/10/13 9:40 AM, JR wrote:
> On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
>> We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a
>> collection of exactly one value, but not a type for "a value of type T
>> or nothing at all".
>
> Is this not what Nullable!T is?

Nullable is not a range.

Andrei
December 10, 2013
On 12/10/13 9:47 AM, Max Klyga wrote:
> On 2013-12-10 17:28:26 +0000, Andrei Alexandrescu said:
>
>> I talked to a programmer who knows Scala (among others) and he
>> mentioned the usefulness of the Option type - a zero or one element
>> collection (range in D terminology). Here's an article discussing it:
>> http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
>>
>>
>> We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a
>> collection of exactly one value, but not a type for "a value of type T
>> or nothing at all". Should we follow Scala's example and add it?
>>
>>
>> Andrei
>
> Yes! Option is super useful. Use it all the time in Scala and Java (via
> Guava library).
> I suppose it will be defined as a range, so map will work on it?
> One of the useful things about options are the ability to chain them via
> flatMap, will this usecase be handled?

Yah, looks like flatMap is also useful (independently from Option). Should actually be flatMap!(R, uint depth = uint.max).

Andrei

December 10, 2013
Am 10.12.2013 18:54, schrieb Yota:
> On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
>> I talked to a programmer who knows Scala (among others) and he
>> mentioned the usefulness of the Option type - a zero or one element
>> collection (range in D terminology). Here's an article discussing it:
>> http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
>>
>
> I really came to love Option when I was working in F#.  One of the
> things I love about F# is how the language strongly discourages nulls.
> Even Anders went on video saying that he regretted making reference
> types nullable in C#.
>
> Of course, there's no way to remove the nullable-by-default nature of
> reference types in D2, but a guy can dream. =]

It would probably break a lot of code, but the Eiffel, Kottlin's approach could be used.

In those languages, unless it is proven that a reference type is valid you cannot make use of its value.

Eiffel
http://docs.eiffel.com/sites/default/files/void-safe-eiffel.pdf

Kotlin
http://confluence.jetbrains.com/display/Kotlin/Null-safety

--
Paulo
December 10, 2013
On 12/10/13 10:21 AM, Paulo Pinto wrote:
> Am 10.12.2013 18:54, schrieb Yota:
>> On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
>>> I talked to a programmer who knows Scala (among others) and he
>>> mentioned the usefulness of the Option type - a zero or one element
>>> collection (range in D terminology). Here's an article discussing it:
>>> http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
>>>
>>>
>>
>> I really came to love Option when I was working in F#.  One of the
>> things I love about F# is how the language strongly discourages nulls.
>> Even Anders went on video saying that he regretted making reference
>> types nullable in C#.
>>
>> Of course, there's no way to remove the nullable-by-default nature of
>> reference types in D2, but a guy can dream. =]
>
> It would probably break a lot of code, but the Eiffel, Kottlin's
> approach could be used.
>
> In those languages, unless it is proven that a reference type is valid
> you cannot make use of its value.
>
> Eiffel
> http://docs.eiffel.com/sites/default/files/void-safe-eiffel.pdf
>
> Kotlin
> http://confluence.jetbrains.com/display/Kotlin/Null-safety

Not that this is not worth discussing, but this is a different topic. I'm talking about ranges of zero or one elements.

Andrei


December 10, 2013
Andrei Alexandrescu:

>Should we follow Scala's example and add it?

Making an Option a D Range means it becomes a Mondad :-) There's then a need for more awareness of Option!T in map/filter/zip.

Related:
https://d.puremagic.com/issues/show_bug.cgi?id=9086

Bye,
bearophile
December 10, 2013
Am 10.12.2013 19:34, schrieb Andrei Alexandrescu:
> On 12/10/13 10:21 AM, Paulo Pinto wrote:
>> Am 10.12.2013 18:54, schrieb Yota:
>>> On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
>>>> I talked to a programmer who knows Scala (among others) and he
>>>> mentioned the usefulness of the Option type - a zero or one element
>>>> collection (range in D terminology). Here's an article discussing it:
>>>> http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
>>>>
>>>>
>>>>
>>>
>>> I really came to love Option when I was working in F#.  One of the
>>> things I love about F# is how the language strongly discourages nulls.
>>> Even Anders went on video saying that he regretted making reference
>>> types nullable in C#.
>>>
>>> Of course, there's no way to remove the nullable-by-default nature of
>>> reference types in D2, but a guy can dream. =]
>>
>> It would probably break a lot of code, but the Eiffel, Kottlin's
>> approach could be used.
>>
>> In those languages, unless it is proven that a reference type is valid
>> you cannot make use of its value.
>>
>> Eiffel
>> http://docs.eiffel.com/sites/default/files/void-safe-eiffel.pdf
>>
>> Kotlin
>> http://confluence.jetbrains.com/display/Kotlin/Null-safety
>
> Not that this is not worth discussing, but this is a different topic.
> I'm talking about ranges of zero or one elements.
>
> Andrei
>
>

Ah ok
« First   ‹ Prev
1 2 3 4