Re: compile-time opIndex

2015-01-02 Thread Steven Schveighoffer via Digitalmars-d
On 1/2/15 8:24 AM, Martin Nowak wrote: On Friday, 2 January 2015 at 12:40:41 UTC, Daniel Murphy wrote: You should wrap, unless we want to make _aaRange part of the stable api. Yep, please don't rely on runtime internals. Wrapping front can be inlined and optimized. Well, as I said, I

Re: compile-time opIndex

2015-01-02 Thread Steven Schveighoffer via Digitalmars-d
On 1/2/15 12:37 PM, Daniel Murphy wrote: Steven Schveighoffer wrote in message news:m86645$26iu$1...@digitalmars.com... Why, because phobos developers aren't aware of druntime's activities? Ideally, yes. Nobody from phobos or druntime can commit changes that break the other accidentally.

Re: compile-time opIndex

2015-01-02 Thread Daniel Murphy via Digitalmars-d
Steven Schveighoffer wrote in message news:m86645$26iu$1...@digitalmars.com... Why, because phobos developers aren't aware of druntime's activities? Ideally, yes.

Re: compile-time opIndex

2015-01-02 Thread Daniel Murphy via Digitalmars-d
H. S. Teoh via Digitalmars-d wrote in message news:mailman.3979.1420139660.9932.digitalmar...@puremagic.com... The way I see it, this is an acceptable compromise: 1) Have .byKeyValue in druntime, which returns a struct with .key and .value; 2) Have .byPair in Phobos (via UFCS), which wraps

Re: compile-time opIndex

2015-01-02 Thread Martin Nowak via Digitalmars-d
On Friday, 2 January 2015 at 12:40:41 UTC, Daniel Murphy wrote: You should wrap, unless we want to make _aaRange part of the stable api. Yep, please don't rely on runtime internals. Wrapping front can be inlined and optimized.

Re: compile-time opIndex

2015-01-02 Thread Steven Schveighoffer via Digitalmars-d
On 1/2/15 7:40 AM, Daniel Murphy wrote: Steven Schveighoffer wrote in message news:m862b3$230o$1...@digitalmars.com... You don't need to wrap, just reimplement (The _aaRange primitives are accessible, I tried it). I don't see any reason to nest these, and they can be unrelated. As I said

Re: compile-time opIndex

2015-01-02 Thread Steven Schveighoffer via Digitalmars-d
On 1/1/15 2:12 PM, H. S. Teoh via Digitalmars-d wrote: On Thu, Jan 01, 2015 at 01:42:45PM -0500, Steven Schveighoffer via Digitalmars-d wrote: And I'm also with you that if you don't have .key .value support, this isn't worth having. [...] The way I see it, this is an acceptable compromise:

Re: compile-time opIndex

2015-01-02 Thread Daniel Murphy via Digitalmars-d
Steven Schveighoffer wrote in message news:m862b3$230o$1...@digitalmars.com... You don't need to wrap, just reimplement (The _aaRange primitives are accessible, I tried it). I don't see any reason to nest these, and they can be unrelated. As I said before, you can shoehorn the primitives

Re: compile-time opIndex

2015-01-01 Thread Artur Skawina via Digitalmars-d
On 12/31/14 22:35, H. S. Teoh via Digitalmars-d wrote: On Wed, Dec 31, 2014 at 10:34:07PM +0100, Artur Skawina via Digitalmars-d wrote: On 12/18/14 16:43, Steven Schveighoffer via Digitalmars-d wrote: We currently have the ability to do opIndex for simulating an array or other type indexed

Re: compile-time opIndex

2015-01-01 Thread Steven Schveighoffer via Digitalmars-d
On 12/31/14 6:05 PM, Dicebot wrote: On Wednesday, 31 December 2014 at 22:58:57 UTC, H. S. Teoh via Digitalmars-d wrote: people demanded Tuple support. Was it bearophile? :P I can't stop feeling that it is simply not recognized enough how bad D tuples are if such request arises. I'd personally

Re: compile-time opIndex

2015-01-01 Thread H. S. Teoh via Digitalmars-d
On Thu, Jan 01, 2015 at 01:42:45PM -0500, Steven Schveighoffer via Digitalmars-d wrote: On 12/31/14 6:05 PM, Dicebot wrote: On Wednesday, 31 December 2014 at 22:58:57 UTC, H. S. Teoh via Digitalmars-d wrote: people demanded Tuple support. Was it bearophile? :P I can't stop feeling that it

Re: compile-time opIndex

2014-12-31 Thread Dicebot via Digitalmars-d
On Tuesday, 30 December 2014 at 16:25:05 UTC, Steven Schveighoffer wrote: On 12/30/14 10:51 AM, Dicebot wrote: On Tuesday, 30 December 2014 at 15:48:03 UTC, Steven Schveighoffer wrote: On 12/18/14 11:54 AM, Dicebot wrote: I wasn't subscribed to druntime changes thus missed this discussion.

Re: compile-time opIndex

2014-12-31 Thread Artur Skawina via Digitalmars-d
On 12/18/14 16:43, Steven Schveighoffer via Digitalmars-d wrote: We currently have the ability to do opIndex for simulating an array or other type indexed at runtime. But we have no way to simulate the ability of tuple indexing. Such an ability would unleash a huge amount of possibilities,

Re: compile-time opIndex

2014-12-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 31, 2014 at 10:34:07PM +0100, Artur Skawina via Digitalmars-d wrote: On 12/18/14 16:43, Steven Schveighoffer via Digitalmars-d wrote: We currently have the ability to do opIndex for simulating an array or other type indexed at runtime. But we have no way to simulate the

Re: compile-time opIndex

2014-12-31 Thread Dicebot via Digitalmars-d
On Wednesday, 31 December 2014 at 21:37:37 UTC, H. S. Teoh via Digitalmars-d wrote: Very nice! Now make it work for int* and string*, but indexing the tuple returns (non-pointer) int and string. This is the original use case that prompted this ER, btw, so if it can't be achieved, then we

Re: compile-time opIndex

2014-12-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 31, 2014 at 09:41:18PM +, Dicebot via Digitalmars-d wrote: On Wednesday, 31 December 2014 at 21:37:37 UTC, H. S. Teoh via Digitalmars-d wrote: Very nice! Now make it work for int* and string*, but indexing the tuple returns (non-pointer) int and string. This is the original use

Re: compile-time opIndex

2014-12-31 Thread Dicebot via Digitalmars-d
On Wednesday, 31 December 2014 at 22:05:37 UTC, H. S. Teoh via Digitalmars-d wrote: Point. But that means we've gone nowhere with AA .byPair(). If I wanted to stir up controversy, I'd say that the ultimate cause of this issue was the fact that struct fields can't be ref; otherwise it would be

Re: compile-time opIndex

2014-12-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 31, 2014 at 10:35:18PM +, Dicebot via Digitalmars-d wrote: On Wednesday, 31 December 2014 at 22:05:37 UTC, H. S. Teoh via Digitalmars-d wrote: Point. But that means we've gone nowhere with AA .byPair(). If I wanted to stir up controversy, I'd say that the ultimate cause of

Re: compile-time opIndex

2014-12-31 Thread Dicebot via Digitalmars-d
On Wednesday, 31 December 2014 at 22:47:05 UTC, H. S. Teoh via Digitalmars-d wrote: That's what I have right now. The catch is how to make S behave like a tuple. I don't know why it was considered an important/worthy goal. Trying to provide API based on tuples just hides the fact that there

Re: compile-time opIndex

2014-12-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 31, 2014 at 10:53:37PM +, Dicebot via Digitalmars-d wrote: On Wednesday, 31 December 2014 at 22:47:05 UTC, H. S. Teoh via Digitalmars-d wrote: That's what I have right now. The catch is how to make S behave like a tuple. I don't know why it was considered an important/worthy

Re: compile-time opIndex

2014-12-31 Thread Dicebot via Digitalmars-d
On Wednesday, 31 December 2014 at 22:58:57 UTC, H. S. Teoh via Digitalmars-d wrote: people demanded Tuple support. Was it bearophile? :P I can't stop feeling that it is simply not recognized enough how bad D tuples are if such request arises. I'd personally try to avoid those in almost all

Re: compile-time opIndex

2014-12-30 Thread Steven Schveighoffer via Digitalmars-d
On 12/18/14 11:54 AM, Dicebot wrote: I wasn't subscribed to druntime changes thus missed this discussion. Will chime in there soon. Ping, still waiting on this :) -Steve

Re: compile-time opIndex

2014-12-30 Thread Dicebot via Digitalmars-d
On Tuesday, 30 December 2014 at 15:48:03 UTC, Steven Schveighoffer wrote: On 12/18/14 11:54 AM, Dicebot wrote: I wasn't subscribed to druntime changes thus missed this discussion. Will chime in there soon. Ping, still waiting on this :) -Steve *blush*

Re: compile-time opIndex

2014-12-30 Thread Steven Schveighoffer via Digitalmars-d
On 12/30/14 10:51 AM, Dicebot wrote: On Tuesday, 30 December 2014 at 15:48:03 UTC, Steven Schveighoffer wrote: On 12/18/14 11:54 AM, Dicebot wrote: I wasn't subscribed to druntime changes thus missed this discussion. Will chime in there soon. Ping, still waiting on this :) *blush* OK, I

compile-time opIndex

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d
We currently have the ability to do opIndex for simulating an array or other type indexed at runtime. But we have no way to simulate the ability of tuple indexing. Such an ability would unleash a huge amount of possibilities, including user-defined tuple types. Let's designate a straw man

Re: compile-time opIndex

2014-12-18 Thread Dicebot via Digitalmars-d
Have you seen my http://wiki.dlang.org/DIP63 ?

Re: compile-time opIndex

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d
On 12/18/14 10:43 AM, Steven Schveighoffer wrote: struct KeyValuePair(K, V) { K key; V value; enum length = 2; ref K opTupleIndex(int x) if(x == 0) { return key;} ref V opTupleIndex(int x) if(x == 1) { return value;} } Or with more recent changes to the compiler:

Re: compile-time opIndex

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d
On 12/18/14 10:44 AM, Dicebot wrote: Have you seen my http://wiki.dlang.org/DIP63 ? I admit this is somewhat over my head, but it seems to be more focused on types. I will note that your example: struct Pack(T...) { alias expand = T; alias expand this; } I don't think this would

Re: compile-time opIndex

2014-12-18 Thread Dicebot via Digitalmars-d
On Thursday, 18 December 2014 at 16:15:09 UTC, Steven Schveighoffer wrote: On 12/18/14 10:44 AM, Dicebot wrote: Have you seen my http://wiki.dlang.org/DIP63 ? I admit this is somewhat over my head, but it seems to be more focused on types. In D there is no special built-in value tuple

Re: compile-time opIndex

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d
On 12/18/14 11:34 AM, Dicebot wrote: On Thursday, 18 December 2014 at 16:15:09 UTC, Steven Schveighoffer wrote: I don't disagree with the idea of having operators inside templates, I just don't know if it solves the problem I was looking at. Your original snippet seems to implementable

Re: compile-time opIndex

2014-12-18 Thread Dicebot via Digitalmars-d
I wasn't subscribed to druntime changes thus missed this discussion. Will chime in there soon.

Re: compile-time opIndex

2014-12-18 Thread H. S. Teoh via Digitalmars-d
On Thu, Dec 18, 2014 at 03:44:18PM +, Dicebot via Digitalmars-d wrote: Have you seen my http://wiki.dlang.org/DIP63 ? Ahhh, finally I understand what this DIP is all about. :-D I like it. +1. T -- If blunt statements had a point, they wouldn't be blunt...

Re: compile-time opIndex

2014-12-18 Thread Dicebot via Digitalmars-d
On Thursday, 18 December 2014 at 18:04:10 UTC, H. S. Teoh via Digitalmars-d wrote: On Thu, Dec 18, 2014 at 03:44:18PM +, Dicebot via Digitalmars-d wrote: Have you seen my http://wiki.dlang.org/DIP63 ? Ahhh, finally I understand what this DIP is all about. :-D I like it. +1. T