View mode: basic / threaded / horizontal-split · Log in · Help
March 17, 2009
Re: eliminate writeln et comp?
On Tue, Mar 17, 2009 at 4:58 PM, Andrei Alexandrescu
<SeeWebsiteForEmail@erdani.org> wrote:
>
> (Not in the upcoming Phobos.)
>

It's a little difficult to have a style discussion with you about
Phobos when you're envisioning an entirely different library than what
we have now ;)
March 18, 2009
Re: eliminate writeln et comp?
Denis Koroskin wrote:
> That's not a very frequent operation. In most cases you should use 
> Cout("Hello"); instead. An ideal design solution, imo (fast, short and 
> clear).

Interesting. Should I do the same in phobos?

stdout("wyda");

I'd like that particularly because write() is too common a name to place 
at namespace level for my taste. So then we'd have:

stdout("wyda"); // no newline
stdout("wyda\n"); // newline but no flushing on binary stream
stdout("wyda", newline); // write'n'flush
stdout.writeln("wyda"); // same

If we go that route I'll even drop writeln and rely on passing newline. 
For formatting there'd be stdout.format and stdout.formatln or something.

> Back on topic, in most cases I use:
> 
> debug writefln("hello");
> 
> because I have no console in release version (and it throws when there 
> is no stdout, look in the bugzilla for a bug report). It is already long 
> enough, so I wouldn't like it to be even longer:
> 
> debug stdio.writefln("hello");
> 
> My 0.02 rubles.
> 

Got them.


Andrei
March 18, 2009
Re: eliminate writeln et comp?
On Wed, 18 Mar 2009 03:26:16 +0300, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:

> Denis Koroskin wrote:
>> That's not a very frequent operation. In most cases you should use  
>> Cout("Hello"); instead. An ideal design solution, imo (fast, short and  
>> clear).
>
> Interesting. Should I do the same in phobos?
>
> stdout("wyda");
>
> I'd like that particularly because write() is too common a name to place  
> at namespace level for my taste. So then we'd have:
>
> stdout("wyda"); // no newline
> stdout("wyda\n"); // newline but no flushing on binary stream
> stdout("wyda", newline); // write'n'flush
> stdout.writeln("wyda"); // same
>
> If we go that route I'll even drop writeln and rely on passing newline.  
> For formatting there'd be stdout.format and stdout.formatln or something.
>

This is funny because Tango has adopted exactly the same design.
The only difference is that Stdout is written in upper case:

import tango.io.Stdout;

void main() {
   Stdout("Hello, World\n"); // no flushing
   Stdout("Hello, World").newline; // new line appended, flushs
   Stdout.format("Hello, {}!", "Andrei").newline; // formatting
   Stdout.formatln("Hello, {}!", "Kris");
}

It would be great if the two libraries share the same interface.

BTW, since you are in process of redesigning of Phobos IO/stream system, it would be great if you take a look at the Tango IO system, first. I recall you telling that you didn't give a good look at Tango, so now is the time. I particularly insist on talking to Kris about it; perhaps, he has some ideas on the topic. He may also share experience with you (errors he made etc). I'll give you a few ideas of mine in a separate post.

You shouldn't avoid looking on someone's code, especially if it may help D get better standard library. There's nothing wrong with borrowing ideas from others, too, especially if they give you a permission for that. Tango is dual-licensed under Academic Free License v3.0 and BSD License, so there might not be a need to, but anyway.

>> Back on topic, in most cases I use:
>>  debug writefln("hello");
>>  because I have no console in release version (and it throws when there  
>> is no stdout, look in the bugzilla for a bug report). It is already  
>> long enough, so I wouldn't like it to be even longer:
>>  debug stdio.writefln("hello");
>>  My 0.02 rubles.
>>
>
> Got them.
>
>
> Andrei
March 18, 2009
Re: eliminate writeln et comp?
Andrei Alexandrescu:
> Interesting. Should I do the same in phobos?
> stdout("wyda");

Generally I suggest to put a short & easy way useful for most situations, plus something more complex (and generally with a more complex syntax) for the special situations. For the general basic printing I like put()/putr() (r = add a final newline).

Bye,
bearophile
March 18, 2009
Re: eliminate writeln et comp?
Denis Koroskin wrote:
> On Wed, 18 Mar 2009 03:26:16 +0300, Andrei Alexandrescu 
> <SeeWebsiteForEmail@erdani.org> wrote:
> 
>> Denis Koroskin wrote:
>>> That's not a very frequent operation. In most cases you should use 
>>> Cout("Hello"); instead. An ideal design solution, imo (fast, short 
>>> and clear).
>>
>> Interesting. Should I do the same in phobos?
>>
>> stdout("wyda");
>>
>> I'd like that particularly because write() is too common a name to 
>> place at namespace level for my taste. So then we'd have:
>>
>> stdout("wyda"); // no newline
>> stdout("wyda\n"); // newline but no flushing on binary stream
>> stdout("wyda", newline); // write'n'flush
>> stdout.writeln("wyda"); // same
>>
>> If we go that route I'll even drop writeln and rely on passing 
>> newline. For formatting there'd be stdout.format and stdout.formatln 
>> or something.
>>
> 
> This is funny because Tango has adopted exactly the same design.

Well it isn't funny. It's obvious: you just told me about it! :o)

> The only difference is that Stdout is written in upper case:
> 
> import tango.io.Stdout;
> 
> void main() {
>    Stdout("Hello, World\n"); // no flushing
>    Stdout("Hello, World").newline; // new line appended, flushs
>    Stdout.format("Hello, {}!", "Andrei").newline; // formatting
>    Stdout.formatln("Hello, {}!", "Kris");
> }
> 
> It would be great if the two libraries share the same interface.

Ionno. In Phobos, types are Capitalized, values are camelCase or 
justminuscules.

> BTW, since you are in process of redesigning of Phobos IO/stream system, 
> it would be great if you take a look at the Tango IO system, first. I 
> recall you telling that you didn't give a good look at Tango, so now is 
> the time. I particularly insist on talking to Kris about it; perhaps, he 
> has some ideas on the topic. He may also share experience with you 
> (errors he made etc). I'll give you a few ideas of mine in a separate post.

I don't know about licensing issues, and last thing I need would be to 
be accused of stealing from Tango.

> You shouldn't avoid looking on someone's code, especially if it may help 
> D get better standard library. There's nothing wrong with borrowing 
> ideas from others, too, especially if they give you a permission for 
> that. Tango is dual-licensed under Academic Free License v3.0 and BSD 
> License, so there might not be a need to, but anyway.

I have zero knowledge of licensing stuff, but I understand Walter does. 
He's not looking at Tango so nor should I. I'm sure it has some cool 
ideas, but so do other libraries.


Andrei
March 18, 2009
Re: eliminate writeln et comp?
Andrei Alexandrescu Wrote:

> Hey all y'all,
> 
> 
> Here's another nice bicycle shed discussion. During the recent 
> discussion about globals being harmful, Walter told me something that 
> made me think. I said, hey, there are things that are global - look at 
> stdout. He said, well, that's a bad thing. He then argued that it would 
> be better and cleaner to write:
> 
> stdout.writeln("Hello, world");
> 
> instead of the current:
> 
> writeln("Hello, world");
> 
> On one hand, I agree with Walter. On the other, I want to avoid the 
> phenomenon of the all-too-long "Hello, world" example.
> 
> What do you think?
> 
> 
> Andrei

A lot of people have enjoyed the simplicity of using Phobos and it'd be a shame to ruin that.  writeln is extremely common, especially with gdb support broken ;)
March 18, 2009
Re: eliminate writeln et comp?
On Wed, Mar 18, 2009 at 12:24 PM, Jason House
<jason.james.house@gmail.com> wrote:
> Andrei Alexandrescu Wrote:
>
>> Hey all y'all,
>>
>>
>> Here's another nice bicycle shed discussion. During the recent
>> discussion about globals being harmful, Walter told me something that
>> made me think. I said, hey, there are things that are global - look at
>> stdout. He said, well, that's a bad thing. He then argued that it would
>> be better and cleaner to write:
>>
>> stdout.writeln("Hello, world");
>>
>> instead of the current:
>>
>> writeln("Hello, world");
>>
>> On one hand, I agree with Walter. On the other, I want to avoid the
>> phenomenon of the all-too-long "Hello, world" example.
>>
>> What do you think?
>>
>>
>> Andrei
>
> A lot of people have enjoyed the simplicity of using Phobos and it'd be a shame to ruin that.  writeln is extremely common, especially with gdb support broken ;)

I think if you're going to change it at all it should be made shorter,
not longer.
And for heaven's sake, don't remove the version of the function that
automatically appends a newline!  I always forget to put the dang \n
at the end of all my printfs in C, so from the very beginning I though
writefln was a godsend for that one thing alone.

--bb
March 18, 2009
Re: eliminate writeln et comp?
On 2009-03-17 20:26:16 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail@erdani.org> said:

> Interesting. Should I do the same in phobos?
> 
> stdout("wyda");
> 
> I'd like that particularly because write() is too common a name to 
> place at namespace level for my taste. So then we'd have:
> 
> stdout("wyda"); // no newline
> stdout("wyda\n"); // newline but no flushing on binary stream
> stdout("wyda", newline); // write'n'flush
> stdout.writeln("wyda"); // same
> 
> If we go that route I'll even drop writeln and rely on passing newline. 
> For formatting there'd be stdout.format and stdout.formatln or 
> something.

Seems nice. Can this work symmetrically for stdin?

	int i;
	stdin(i); // reads an integer and place it in i.

That would make things interesting, as with some streams you could use 
the same code to serialize and unserialize a data structures.

	stream(x, y, z); // either write or read the values depending on the stream.

This reminds me of boost serialization which use a similar trick 
allowing you to have a single function template to both serialize and 
unserialize a given data type.

But that probably couldn't work with the standard text stream types.

-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/
March 18, 2009
Re: eliminate writeln et comp?
Andrei Alexandrescu wrote:
> Hey all y'all,
> 
> 
> Here's another nice bicycle shed discussion. During the recent 
> discussion about globals being harmful, Walter told me something that 
> made me think. I said, hey, there are things that are global - look at 
> stdout. He said, well, that's a bad thing. He then argued that it would 
> be better and cleaner to write:
> 
> stdout.writeln("Hello, world");
> 
> instead of the current:
> 
> writeln("Hello, world");
> 
> On one hand, I agree with Walter. On the other, I want to avoid the 
> phenomenon of the all-too-long "Hello, world" example.
> 
> What do you think?
> 
> 
> Andrei

I have always thought of writefln as the flagship function of Phobos. 
It's now looking as though the connection between Phobos2 and Phobos1 is 
not really any stronger than between Tango1 and Phobos1.
(This is an observation, not intended to be critical in any way).
March 19, 2009
Re: eliminate writeln et comp?
Andrei Alexandrescu wrote:
> Denis Koroskin wrote:
>> On Wed, 18 Mar 2009 03:26:16 +0300, Andrei Alexandrescu 
>> <SeeWebsiteForEmail@erdani.org> wrote:
>>
>>> Denis Koroskin wrote:
>>>> That's not a very frequent operation. In most cases you should use 
>>>> Cout("Hello"); instead. An ideal design solution, imo (fast, short 
>>>> and clear).
>>>
>>> Interesting. Should I do the same in phobos?
>>>
>>> stdout("wyda");
>>>
>>> I'd like that particularly because write() is too common a name to 
>>> place at namespace level for my taste. So then we'd have:
>>>
>>> stdout("wyda"); // no newline
>>> stdout("wyda\n"); // newline but no flushing on binary stream
>>> stdout("wyda", newline); // write'n'flush
>>> stdout.writeln("wyda"); // same
>>>
>>> If we go that route I'll even drop writeln and rely on passing 
>>> newline. For formatting there'd be stdout.format and stdout.formatln 
>>> or something.
>>>
>>
>> This is funny because Tango has adopted exactly the same design.
> 
> Well it isn't funny. It's obvious: you just told me about it! :o)
> 
>> The only difference is that Stdout is written in upper case:
>>
>> import tango.io.Stdout;
>>
>> void main() {
>>    Stdout("Hello, World\n"); // no flushing
>>    Stdout("Hello, World").newline; // new line appended, flushs
>>    Stdout.format("Hello, {}!", "Andrei").newline; // formatting
>>    Stdout.formatln("Hello, {}!", "Kris");
>> }
>>
>> It would be great if the two libraries share the same interface.
> 
> Ionno. In Phobos, types are Capitalized, values are camelCase or 
> justminuscules.
> 
>> BTW, since you are in process of redesigning of Phobos IO/stream 
>> system, it would be great if you take a look at the Tango IO system, 
>> first. I recall you telling that you didn't give a good look at Tango, 
>> so now is the time. I particularly insist on talking to Kris about it; 
>> perhaps, he has some ideas on the topic. He may also share experience 
>> with you (errors he made etc). I'll give you a few ideas of mine in a 
>> separate post.
> 
> I don't know about licensing issues, and last thing I need would be to 
> be accused of stealing from Tango.
> 
>> You shouldn't avoid looking on someone's code, especially if it may 
>> help D get better standard library. There's nothing wrong with 
>> borrowing ideas from others, too, especially if they give you a 
>> permission for that. Tango is dual-licensed under Academic Free 
>> License v3.0 and BSD License, so there might not be a need to, but 
>> anyway.
> 
> I have zero knowledge of licensing stuff, but I understand Walter does. 
> He's not looking at Tango so nor should I. I'm sure it has some cool 
> ideas, but so do other libraries.

You know, this is just counter-productive. There are several people - 
all of them very valuable members of the D community, with countless 
contributions - who have put forth a library with its goals being mainly 
the success of D and especially a vital, alive development process. This 
library is available licensed under BSD, which basically means you can 
do whatever you please with it, as long as you don’t remove the 
copyright of the original authors.

Now, what you’re doing is despite the fact that the Tango sources are 
completely free and available to you, deny any kind of insight you might 
be able to gather in there. Why? If you’re responsible for the standard 
library and you *do* take ideas from Tango and integrate them into the 
official standard library, you’re doing every Tango dev a big favour. 
Because, you know, that’s why there is Tango. You didn’t forget that, 
did you?

No offense intended, of course. I just think you should really 
reconsider your decision to not look at Tango, based on facts. Not based 
on “I  might step on someone’s toes because of I don’t know why.”

Kind regards,
Alex

PS: Pretty please, don’t get me wrong, I really appreciate your 
contributions to D! :)
1 2 3 4 5 6
Top | Discussion index | About this forum | D home