Re: I think Associative Array should throw Exception

2020-09-04 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:20:17 UTC, Jesse Phillips wrote: This is going to be a hard one for me to argue but I'm going to give it a try. Today if you attempt to access a key from an associative array (AA) that does not exist inside the array, a RangeError is thrown. This is similar

Re: I think Associative Array should throw Exception

2020-09-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/20 1:48 AM, Jesse Phillips wrote: On Thursday, 3 September 2020 at 15:12:14 UTC, Steven Schveighoffer wrote: int[int] aa; aa[4] = 5; auto b = aa[4]; How is this code broken? It's valid, will never throw, and there's no reason that we should break it by adding an exception into the mix.

Re: I think Associative Array should throw Exception

2020-09-03 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 3 September 2020 at 15:12:14 UTC, Steven Schveighoffer wrote: int[int] aa; aa[4] = 5; auto b = aa[4]; How is this code broken? It's valid, will never throw, and there's no reason that we should break it by adding an exception into the mix. int foo() nothrow { return "1".to

Re: I think Associative Array should throw Exception

2020-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/3/20 10:43 AM, Jesse Phillips wrote: On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow

Re: I think Associative Array should throw Exception

2020-09-03 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It mak

Re: I think Associative Array should throw Exception

2020-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 10:46 PM, James Blachly wrote: On 9/1/20 2:55 PM, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to

Re: I think Associative Array should throw Exception

2020-09-01 Thread James Blachly via Digitalmars-d-learn
On 9/1/20 2:55 PM, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately,

Re: I think Associative Array should throw Exception

2020-09-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. You could always catch it though. But I kinda like things the way they are exac

Re: I think Associative Array should throw Exception

2020-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. What is wrong with using `in`?

I think Associative Array should throw Exception

2020-09-01 Thread Jesse Phillips via Digitalmars-d-learn
This is going to be a hard one for me to argue but I'm going to give it a try. Today if you attempt to access a key from an associative array (AA) that does not exist inside the array, a RangeError is thrown. This is similar to when an array is accessed outside the bounds. ``` string[string