July 25, 2020
On Sat, Jul 25, 2020 at 01:28:34PM +0000, Adam D. Ruppe via Digitalmars-d-announce wrote:
> On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
> > Oop! Chaining the writeln too could have increased the wow factor. I didn't see that.
> 
> oh I hate it when people do that though, it just looks off to me at that point.

Me too.  It gives me the same creepie-feelies as when people write
writeln(x) as:

	writeln = x;

Actually, D's lax syntax surrounding the = operator gives rise to the following reverse-UFCS nastiness:

	// Cover your eyes (unless you're reverse-Polish :-P)! and don't
	// do this at home, it will corrupt your sense of good coding
	// style!
	import std;
	void main() {
		writeln = filter!(x => x % 3 == 1)
			= map!(x => x*2)
			= [ 1, 2, 3, 4, 5, 6 ];
	}

	// Output: [4, 10]


T

-- 
Winners never quit, quitters never win. But those who never quit AND never win are idiots.
July 25, 2020
On Saturday, 25 July 2020 at 14:47:01 UTC, aberba wrote:
> On Saturday, 25 July 2020 at 13:28:34 UTC, Adam D. Ruppe wrote:
>> On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
>>> Oop! Chaining the writeln too could have increased the wow factor. I didn't see that.
>>
>> oh I hate it when people do that though, it just looks off to me at that point.
>
> Ha ha. If you're writing idiomatic D code, why not not all in on it?

It bugs me too, though I have done it.

I think the right answer of why it is odd is because writeln is void. As soon as it is placed on the end the chain is broken and you can't expand on it.
July 25, 2020
On 7/25/20 7:47 AM, aberba wrote:
> On Saturday, 25 July 2020 at 13:28:34 UTC, Adam D. Ruppe wrote:
>> oh I hate it when people do that though, it just looks off to me at
>> that point.
>
> Ha ha. If you're writing idiomatic D code, why not not all in on it?

I agree with Adam and others on this. My reasoning is, writeln's first parameter is not special compared to its other parameters. In other words, I can't see writeln as a special operation on its first argument. Except, when there is just one thing... Meh... I don't like it. :)

Ali

July 26, 2020
On Saturday, 25 July 2020 at 18:24:22 UTC, Jesse Phillips wrote:
> On Saturday, 25 July 2020 at 14:47:01 UTC, aberba wrote:
>> On Saturday, 25 July 2020 at 13:28:34 UTC, Adam D. Ruppe wrote:
>>> On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
>>>> Oop! Chaining the writeln too could have increased the wow factor. I didn't see that.
>>>
>>> oh I hate it when people do that though, it just looks off to me at that point.
>>
>> Ha ha. If you're writing idiomatic D code, why not not all in on it?
>
> It bugs me too, though I have done it.
>
> I think the right answer of why it is odd is because writeln is void. As soon as it is placed on the end the chain is broken and you can't expand on it.

This is no different from any other "sink" that consumes a range:

someSource
    .map!foo
    .filter!bar
    .splitter(baz)
    .each!quux;

`each` returns void [1], so using it ends the chain. But that's not a problem, because the whole *point* of using `each` is to consume the range.

[1] Not exactly, but close enough.
July 26, 2020
On Sunday, 26 July 2020 at 01:14:53 UTC, Paul Backus wrote:
> On Saturday, 25 July 2020 at 18:24:22 UTC, Jesse Phillips wrote:
>> On Saturday, 25 July 2020 at 14:47:01 UTC, aberba wrote:
>>> [...]
>>
>> It bugs me too, though I have done it.
>>
>> I think the right answer of why it is odd is because writeln is void. As soon as it is placed on the end the chain is broken and you can't expand on it.
>
> This is no different from any other "sink" that consumes a range:
>
> someSource
>     .map!foo
>     .filter!bar
>     .splitter(baz)
>     .each!quux;
>
> `each` returns void [1], so using it ends the chain. But that's not a problem, because the whole *point* of using `each` is to consume the range.
>
> [1] Not exactly, but close enough.

I believe one can use tee!(writeln) to avoid consuming the range.
July 26, 2020
I find something like writable.writeTo(stdout) nicer
July 27, 2020
On Saturday, 25 July 2020 at 16:22:52 UTC, H. S. Teoh wrote:
> On Sat, Jul 25, 2020 at 01:28:34PM +0000, Adam D. Ruppe via Digitalmars-d-announce wrote:
>> On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
>> > Oop! Chaining the writeln too could have increased the wow factor. I didn't see that.
>> 
>> oh I hate it when people do that though, it just looks off to me at that point.
>
> Me too.  It gives me the same creepie-feelies as when people write
> writeln(x) as:
>
> 	writeln = x;
>
> Actually, D's lax syntax surrounding the = operator gives rise to the following reverse-UFCS nastiness:
>
> 	// Cover your eyes (unless you're reverse-Polish :-P)! and don't
> 	// do this at home, it will corrupt your sense of good coding
> 	// style!
> 	import std;
> 	void main() {
> 		writeln = filter!(x => x % 3 == 1)
> 			= map!(x => x*2)
> 			= [ 1, 2, 3, 4, 5, 6 ];
> 	}
>
> 	// Output: [4, 10]
>
>
> T

Oh my god ... it’s like haskells $ 🤔

Why is this allowed?

I mean, ok, it was probably done to allow property syntax. But how did this end up being applied to every function?

Can this be fixed?


1 2
Next ›   Last »