Why exceptions for error handling is so important
Russel Winder via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jan 13 02:56:45 PST 2015
On Mon, 2015-01-12 at 11:32 -0800, Andrei Alexandrescu via Digitalmars-d wrote:
> On 1/12/15 11:30 AM, Russel Winder via Digitalmars-d wrote:
> >
> > On Mon, 2015-01-12 at 10:43 -0800, H. S. Teoh via Digitalmars-d
> > wrote:
> > >
> > […]
> > > And what exactly should operator[] return if a key wasn't found?
> > >
> > […]
> >
> > Go has an interesting solution, key lookup in a map return a pair
> > (result, ok), if lookup succeeded then result is the associated
> > value, if ok is false then result is undefined. I quite like this.
>
> How can you like undefined? That's a terrible solution again
> underlining
> Go's conflation of union and product types. -- Andrei
They may be fiddling with type systems, but I was wrong about
undefined: if the key is not found then lookup returns the zero value
for the value type. Given this is useless to me, I think in terms of
it being undefined, which is technically wrong, but good for my code.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
More information about the Digitalmars-d
mailing list