Re: Type-Strict Indexes: IndexedBy

2015-02-18 Thread anonymous via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:46:09 UTC, Nordlöw wrote: Superb! I'd like to see this getting into std.typecons. Having this in the language will attract (more) Ada programmers to D. Should I do PR for std.typecons.[iI]ndexedBy? I'm not familiar with Ada, and I don't immediately see

Re: Type-Strict Indexes: IndexedBy

2015-02-18 Thread Nordlöw
On Wednesday, 18 February 2015 at 12:44:22 UTC, anonymous wrote: Should I do PR for std.typecons.[iI]ndexedBy? I'm not familiar with Ada, and I don't immediately see what indexedBy is good for. So maybe gather some examples where it's beneficial, before going for Phobos. Ok, I have a use

Re: Type-Strict Indexes: IndexedBy

2015-02-18 Thread Tobias Pankrath via Digitalmars-d-learn
Having this in the language will attract (more) Ada programmers to D. “Having this or that will attract (XY)-programmers / magically make D successful in niche Z” is an argument too weak for phobos inclusion, IMO.

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread anonymous via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 13:38:41 UTC, Per Nordlöw wrote: This looses most of the meaning of my idea. I still want my range to inherit all the powers of its wrapped range. Is there no way to disable member functions in D? I hadn't thought of @disable. Played around with it a bit. The

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread via Digitalmars-d-learn
On Monday, 16 February 2015 at 20:17:55 UTC, anonymous wrote: Remove that `alias _r this;`. You don't want to forward opIndex, so you can't use alias this which forwards everything that doesn't compile. opDispatch may be an option to forward everything but opIndex. This looses most of the

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread Nordlöw
On Tuesday, 17 February 2015 at 15:02:05 UTC, anonymous wrote: I hadn't thought of @disable. Played around with it a bit. The following code seems to work. I didn't really test it or think very hard about it, though. Superb! I'd like to see this getting into std.typecons. Having this in the

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread Tobias Pankrath via Digitalmars-d-learn
On Monday, 16 February 2015 at 20:09:09 UTC, Nordlöw wrote: I'm trying to figure out how to implement a light-weight wrappr realizing type-safe indexing á lá Ada. Here's my first try: struct Ix(T = size_t) { @safe pure: @nogc nothrow: this(T ix) { this._ix = ix; } alias _ix this;

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread Nordlöw
On Monday, 16 February 2015 at 20:09:09 UTC, Nordlöw wrote: I'm trying to figure out how to implement a light-weight wrappr realizing type-safe indexing á lá Ada. Here's my first try: See also: https://github.com/nordlow/justd/blob/master/typecons_ex.d#L83

Type-Strict Indexes: IndexedBy

2015-02-16 Thread Nordlöw
I'm trying to figure out how to implement a light-weight wrappr realizing type-safe indexing á lá Ada. Here's my first try: struct Ix(T = size_t) { @safe pure: @nogc nothrow: this(T ix) { this._ix = ix; } alias _ix this; private T _ix = 0; } struct IndexedBy(R, I) { auto

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread anonymous via Digitalmars-d-learn
On Monday, 16 February 2015 at 20:09:09 UTC, Nordlöw wrote: How can I prevent jx[0] = 11; from compiling? Remove that `alias _r this;`. You don't want to forward opIndex, so you can't use alias this which forwards everything that doesn't compile. opDispatch may be an option to forward

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread Nordlöw
On Monday, 16 February 2015 at 20:48:29 UTC, Nordlöw wrote: Thanks! See also: http://forum.dlang.org/thread/akibggljgcmmacsba...@forum.dlang.org

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread Nordlöw
On Monday, 16 February 2015 at 20:17:55 UTC, anonymous wrote: Remove that `alias _r this;`. You don't want to forward opIndex, so you can't use alias this which forwards everything that doesn't compile. opDispatch may be an option to forward everything but opIndex. Thanks!

Re: Type-Strict Indexes: IndexedBy

2015-02-16 Thread Nordlöw
On Monday, 16 February 2015 at 20:17:55 UTC, anonymous wrote: that doesn't compile. opDispatch may be an option to forward everything but opIndex. What about disable?