Re: DIP58: .. as a Binary Operator

2014-03-18 Thread Rainer Schuetze
On 17.03.2014 23:33, Robert Schadek wrote: On 03/17/2014 11:24 PM, H. S. Teoh wrote: On Mon, Mar 17, 2014 at 11:16:12PM +0100, Robert Schadek wrote: replace .. with : to make lexing easier, please auto b = arr[(someCondition) ? w:x : y:z]; :-( T Thats a parsing problem. 1..1

Re: DIP58: .. as a Binary Operator

2014-03-18 Thread Ola Fosheim Grøstad
On Monday, 17 March 2014 at 23:03:14 UTC, Robert Schadek wrote: On 03/17/2014 11:43 PM, Timon Gehr wrote: No, it does not. The lexer does not need to change. you're right, but at some distant future I would like .. to be replaced by : Yes. I also like the .. notation in Dart where you keep

DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
I just wrote a DIP aimed at improving slicing and range construction syntax while maintaining backwards compatibility, and I'd like to hear your opinions! http://wiki.dlang.org/DIP58 It can be thought of as an elaboration on the approach discussed here:

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread bearophile
Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. But the syntax a..b..step is not very nice. Bye, bearophile

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote: Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. Thanks. There are a few awkward parts to maintain compatibility, but that seems to be the only way to go. But the syntax a..b..step is not very nice. Do you not like the

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Chris Williams
On Monday, 17 March 2014 at 19:07:45 UTC, Mason McGill wrote: On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote: Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. Thanks. There are a few awkward parts to maintain compatibility, but that seems to be the only way to go.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread H. S. Teoh
On Mon, Mar 17, 2014 at 07:07:44PM +, Mason McGill wrote: On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote: Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. Thanks. There are a few awkward parts to maintain compatibility, but that seems to be the only way to go.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
Random thought, but treating step as a template argument would allow for some more interesting changes to the iterations, though I can't think of any particular syntax that would look good. And if you did add such a thing, then other operators would want it as well. Interesting, though I

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Asman01
On Monday, 17 March 2014 at 07:56:20 UTC, Mason McGill wrote: I just wrote a DIP aimed at improving slicing and range construction syntax while maintaining backwards compatibility, and I'd like to hear your opinions! http://wiki.dlang.org/DIP58 It can be thought of as an elaboration on the

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
On Monday, 17 March 2014 at 19:58:40 UTC, H. S. Teoh wrote: On Mon, Mar 17, 2014 at 07:07:44PM +, Mason McGill wrote: On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote: Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. Thanks. There are a few awkward parts to maintain

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Meta
On Monday, 17 March 2014 at 07:56:20 UTC, Mason McGill wrote: I just wrote a DIP aimed at improving slicing and range construction syntax while maintaining backwards compatibility, and I'd like to hear your opinions! http://wiki.dlang.org/DIP58 It can be thought of as an elaboration on the

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Chris Williams
On Monday, 17 March 2014 at 20:13:20 UTC, Mason McGill wrote: Interesting, though I feel like operator syntax really shines when either 1) It's significantly shorter/simpler than the equivalent function calls. 2) It appeals to domain-specific intuitions. In general, I agree. Though I

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
It's a nice proposal, but what happens if you want a range of floats, e.g., 1.0..2.0? Correct me if I'm wrong, parsing would look like: 1.0..2.0 === Found a literal. 1.0..2.0 ==Found a binary operator. 1.0..2.0 === Found a literal.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Robert Schadek
replace .. with : to make lexing easier, please

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread H. S. Teoh
On Mon, Mar 17, 2014 at 11:16:12PM +0100, Robert Schadek wrote: replace .. with : to make lexing easier, please auto b = arr[(someCondition) ? w:x : y:z]; :-( T -- Computers aren't intelligent; they only think they are.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Robert Schadek
On 03/17/2014 11:24 PM, H. S. Teoh wrote: On Mon, Mar 17, 2014 at 11:16:12PM +0100, Robert Schadek wrote: replace .. with : to make lexing easier, please auto b = arr[(someCondition) ? w:x : y:z]; :-( T Thats a parsing problem. 1..1 makes you think you got a prefix of a float 1.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread H. S. Teoh
On Mon, Mar 17, 2014 at 11:33:38PM +0100, Robert Schadek wrote: On 03/17/2014 11:24 PM, H. S. Teoh wrote: On Mon, Mar 17, 2014 at 11:16:12PM +0100, Robert Schadek wrote: replace .. with : to make lexing easier, please auto b = arr[(someCondition) ? w:x : y:z]; :-( T Thats a

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Timon Gehr
On 03/17/2014 11:37 PM, H. S. Teoh wrote: 1..1 makes you think you got a prefix of a float 1. but actually you got an int slice_operator int. If there where no .. flex like generator could handle D, at least as far as I can see it. Point. But still, syntax that makes lexing or parsing hard --

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread deadalnix
On Monday, 17 March 2014 at 22:21:46 UTC, Robert Schadek wrote: replace .. with : to make lexing easier, please +1

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Robert Schadek
On 03/17/2014 11:43 PM, Timon Gehr wrote: No, it does not. The lexer does not need to change. you're right, but at some distant future I would like .. to be replaced by :

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Mason McGill
On Monday, 17 March 2014 at 22:26:05 UTC, H. S. Teoh wrote: On Mon, Mar 17, 2014 at 11:16:12PM +0100, Robert Schadek wrote: replace .. with : to make lexing easier, please auto b = arr[(someCondition) ? w:x : y:z]; :-( T Julia has both the ternary conditional and : as an