Re: About the in expression, Why can't use with array.

2019-10-25 Thread lili via Digitalmars-d-learn
On Friday, 25 October 2019 at 21:06:53 UTC, IGotD- wrote: On Friday, 25 October 2019 at 20:44:18 UTC, Dennis wrote: On Friday, 25 October 2019 at 19:49:05 UTC, Ali Çehreli wrote: I'm still not completely sold on the whole idea though because it's not a clear win. Do others see other

Re: About the in expression, Why can't use with array.

2019-10-25 Thread IGotD- via Digitalmars-d-learn
On Friday, 25 October 2019 at 20:44:18 UTC, Dennis wrote: On Friday, 25 October 2019 at 19:49:05 UTC, Ali Çehreli wrote: I'm still not completely sold on the whole idea though because it's not a clear win. Do others see other advantages in other places like templates? For example, could

Re: About the in expression, Why can't use with array.

2019-10-25 Thread Dennis via Digitalmars-d-learn
On Friday, 25 October 2019 at 19:49:05 UTC, Ali Çehreli wrote: I'm still not completely sold on the whole idea though because it's not a clear win. Do others see other advantages in other places like templates? For example, could templates really be written generically for arrays and

Re: About the in expression, Why can't use with array.

2019-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/2019 02:25 AM, Dennis wrote: > On Friday, 25 October 2019 at 05:17:35 UTC, Ali Çehreli wrote: >> - Big O is different > > No it isn't. Agreed and I've just realized a benefit of the 'in' operator for arrays, which I haven't heard before. (I don't follow all discussions in detail.)

Re: About the in expression, Why can't use with array.

2019-10-25 Thread Paul Backus via Digitalmars-d-learn
On Friday, 25 October 2019 at 16:01:57 UTC, mipri wrote: On Friday, 25 October 2019 at 15:52:50 UTC, Paul Backus wrote: On Friday, 25 October 2019 at 09:25:21 UTC, Dennis wrote: I can overload the 'in' operator on my types to something that takes exponential time if I want, just like "+" can

Re: About the in expression, Why can't use with array.

2019-10-25 Thread IGotD- via Digitalmars-d-learn
On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: Hi: In Dlang where is strange design. The in expression can only use to associative array, why array can not use in expression. I don't see much of a problem why this couldn't be implemented as long as the user understands the

Re: About the in expression, Why can't use with array.

2019-10-25 Thread mipri via Digitalmars-d-learn
On Friday, 25 October 2019 at 15:52:50 UTC, Paul Backus wrote: On Friday, 25 October 2019 at 09:25:21 UTC, Dennis wrote: I can overload the 'in' operator on my types to something that takes exponential time if I want, just like "+" can also be overloaded to a linear time operation on e.g.

Re: About the in expression, Why can't use with array.

2019-10-25 Thread Paul Backus via Digitalmars-d-learn
On Friday, 25 October 2019 at 09:25:21 UTC, Dennis wrote: I can overload the 'in' operator on my types to something that takes exponential time if I want, just like "+" can also be overloaded to a linear time operation on e.g. BigInt. Worth noting that `opIn` is a D1 operator overload, and

Re: About the in expression, Why can't use with array.

2019-10-25 Thread Dennis via Digitalmars-d-learn
On Friday, 25 October 2019 at 05:17:35 UTC, Ali Çehreli wrote: - Big O is different No it isn't. Worst case lookup of an associative array lookup is O(n) too. It can easily be 'achieved' by having a key type with: ``` size_t toHash() const scope pure { return 0; } ``` The fact that

Re: About the in expression, Why can't use with array.

2019-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/24/2019 05:58 AM, lili wrote: > Hi: > In Dlang where is strange design. The in expression can only use to > associative array, why array can not use in expression. In addition to the big O surprise, there is another important issue that may be seen as either for or against supporting

Re: About the in expression, Why can't use with array.

2019-10-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 24, 2019 8:40:59 PM MDT lili via Digitalmars-d-learn wrote: > On Thursday, 24 October 2019 at 22:40:31 UTC, Jonathan M Davis > > wrote: > > On Thursday, October 24, 2019 7:04:56 AM MDT Paul Backus via > > > > Digitalmars-d- learn wrote: > >> On Thursday, 24 October 2019 at

Re: About the in expression, Why can't use with array.

2019-10-24 Thread lili via Digitalmars-d-learn
On Thursday, 24 October 2019 at 22:40:31 UTC, Jonathan M Davis wrote: On Thursday, October 24, 2019 7:04:56 AM MDT Paul Backus via Digitalmars-d- learn wrote: On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: > Hi: >In Dlang where is strange design. The in expression can > only >

Re: About the in expression, Why can't use with array.

2019-10-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 24, 2019 7:04:56 AM MDT Paul Backus via Digitalmars-d- learn wrote: > On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: > > Hi: > >In Dlang where is strange design. The in expression can only > > > > use to associative array, why array can not use in expression. >

Re: About the in expression, Why can't use with array.

2019-10-24 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 24 October 2019 at 12:58:11 UTC, lili wrote: Hi: In Dlang where is strange design. The in expression can only use to associative array, why array can not use in expression. Checking for the presence of an item in an array requires a linear search. You can do it with