February 24, 2022
On Thursday, 24 February 2022 at 21:05:49 UTC, H. S. Teoh wrote:
> On Thu, Feb 24, 2022 at 08:57:02PM +0000, forkit via Digitalmars-d wrote: [...]
>> e.g.
>> 
>> i < 4 < n
>> 
>> once you know what the above means, it will take less cognitive effort than
>> 
>> i < 4 && 4 < n
>> 
>> not to mention less typing.
>> 
>> so everyone's a winner when you remove 'unncessary' verbosity.
>
> There's std.algorithm.ordered which lets you write:
>
> 	ordered(i, 4, n)
>
> which isn't too bad, it just needs to be promoted more so that people are more aware of it.

No short circuit though. Not that I suddenly changed my mind about the pythonese, but if we're offering alternatives, might as well be thorough.
February 24, 2022
On Thu, Feb 24, 2022 at 09:19:38PM +0000, Stanislav Blinov via Digitalmars-d wrote:
> On Thursday, 24 February 2022 at 21:05:49 UTC, H. S. Teoh wrote:
[...]
> > There's std.algorithm.ordered which lets you write:
> > 
> > 	ordered(i, 4, n)
> > 
> > which isn't too bad, it just needs to be promoted more so that people are more aware of it.
> 
> No short circuit though.
[...]

The docs don't say it, but it *does* in fact short-circuit if you look at the implementation.


T

-- 
Written on the window of a clothing store: No shirt, no shoes, no service.
February 24, 2022
On Thursday, 24 February 2022 at 21:26:04 UTC, H. S. Teoh wrote:
> On Thu, Feb 24, 2022 at 09:19:38PM +0000, Stanislav Blinov via Digitalmars-d wrote:
>> On Thursday, 24 February 2022 at 21:05:49 UTC, H. S. Teoh wrote:
> [...]
>> > There's std.algorithm.ordered which lets you write:
>> > 
>> > 	ordered(i, 4, n)
>> > 
>> > which isn't too bad, it just needs to be promoted more so that people are more aware of it.
>> 
>> No short circuit though.
> [...]
>
> The docs don't say it, but it *does* in fact short-circuit if you look at the implementation.

Yes, but after evaluating all the arguments :)

February 24, 2022
On Thu, Feb 24, 2022 at 09:51:09PM +0000, Stanislav Blinov via Digitalmars-d wrote:
> On Thursday, 24 February 2022 at 21:26:04 UTC, H. S. Teoh wrote:
> > On Thu, Feb 24, 2022 at 09:19:38PM +0000, Stanislav Blinov via Digitalmars-d wrote:
> > > On Thursday, 24 February 2022 at 21:05:49 UTC, H. S. Teoh wrote:
> > [...]
> > > > There's std.algorithm.ordered which lets you write:
> > > > > 	ordered(i, 4, n)
> > > > > which isn't too bad, it just needs to be promoted more so >
> > > > > that people are more aware of it.
> > > 
> > > No short circuit though.
> > [...]
> > 
> > The docs don't say it, but it *does* in fact short-circuit if you look at the implementation.
> 
> Yes, but after evaluating all the arguments :)

Hmm, you're right.

Make the arguments lazy?  But then you have the @nogc problem.


T

-- 
Error: Keyboard not attached. Press F1 to continue. -- Yoon Ha Lee, CONLANG
February 25, 2022
On Monday, 21 February 2022 at 09:29:56 UTC, forkit wrote:
> It seems to me, that D is a language where python like chaining would be right at home.
>
> writeln(1 < 2 < 3 < 4 > 3 == 3); // true
>
>
> So why doesn't D have it already ;-)

I agree there should be something to mean `1<n<3`; but further seems like a meme

there's a "in" keyword maybe `n in 1..3` or sometin
February 25, 2022
On Tuesday, 22 February 2022 at 08:45:53 UTC, Abdulhaq wrote:
> It seems you (and most of the people in this thread) have misunderstood what this is doing in python. 1 < 2 always returns a boolean, except in the case of operator overloading.
>
> 2 < x < 5 is implemented as ```(2 < x) and (x < 5)```, not as ```(2 < x) < 5```

So this is whole thing is super ambiguous.
Glad we don’t have that footgun.

- Elias
February 27, 2022
On 25.02.22 15:02, 0xEAB wrote:
> On Tuesday, 22 February 2022 at 08:45:53 UTC, Abdulhaq wrote:
>> It seems you (and most of the people in this thread) have misunderstood what this is doing in python. 1 < 2 always returns a boolean, except in the case of operator overloading.
>>
>> 2 < x < 5 is implemented as ```(2 < x) and (x < 5)```, not as ```(2 < x) < 5```
> 
> So this is whole thing is super ambiguous.
> Glad we don’t have that footgun.
> 
> - Elias

Not ambiguous at all. Not every expression has to be parsed as a binary or unary operator...
February 27, 2022
On Monday, 21 February 2022 at 09:29:56 UTC, forkit wrote:
> It seems to me, that D is a language where python like chaining would be right at home.
>
> writeln(1 < 2 < 3 < 4 > 3 == 3); // true
>
>
> So why doesn't D have it already ;-)

writeln(mixin(chainCmp("1 < 2 < 3 < 4 > 3 == 3"))); // true

Implementation is left as an exercise to the reader. :)
1 2 3 4 5 6
Next ›   Last »