February 09, 2016
On Monday, 8 February 2016 at 13:37:19 UTC, Andrei Alexandrescu wrote:
> On 2/7/16 7:11 PM, John Colvin wrote:
>> alias dump = dumpTo!stdout;
>> alias errDump = dumpTo!stderr;
>
> I'm hoping for something with a simpler syntax, a la dump!(stdout, "x") where stdout is optional. -- Andrei

This works:

---

import std.stdio : File;
static import std.ascii;

template dump(symbols...)
{
	import std.stdio : File;

	void dump(Separator, Terminator)(
		File file,
		Separator separator = ", ",
		Terminator terminator = std.ascii.newline)
	{
		foreach(i, symbol; symbols[0 .. $ - 1])
			file.write(__traits(identifier, symbols[i]), " = ", symbol, separator);
		file.write(__traits(identifier, symbols[$ - 1]), " = ", symbols[$ - 1], terminator);
	}

	void dump(Separator, Terminator)(
		Separator separator = ", ",
		Terminator terminator = std.ascii.newline)
		if (!is(Separator == File))
	{
		import std.stdio : stdout;
		.dump!symbols(stdout, separator, terminator);
	}
}

void main()
{
	import std.stdio : stdout;

	int a = 42;
	string b = "foo";
	float c = 3.14;

	dump!(a, b, c)(); // a = 42, b = foo, c = 3.14
	stdout.dump!(a, b, c)(" | "); // a = 42 | b = foo | c = 3.14
}

---

I'm not a fan of non-trivial string mixins except in extenuating circumstances. I tried compressing it to a single call to `write` like your `print` except using staticMap, but like I often do I ran into "template instance foo cannot use local 'bar' as parameter to non-global template baz" errors.
February 09, 2016
On 02/09/2016 06:25 AM, Marc Schütz wrote:
> On Monday, 8 February 2016 at 13:37:19 UTC, Andrei Alexandrescu wrote:
>> On 2/7/16 7:11 PM, John Colvin wrote:
>>> alias dump = dumpTo!stdout;
>>> alias errDump = dumpTo!stderr;
>>
>> I'm hoping for something with a simpler syntax, a la dump!(stdout,
>> "x") where stdout is optional. -- Andrei
>
> Why would `stdout` need to be a template argument?

It needn't! -- Andrei
February 09, 2016
On 02/09/2016 07:46 AM, Jakob Ovrum wrote:
>
>
> void main()
> {
>      import std.stdio : stdout;
>
>      int a = 42;
>      string b = "foo";
>      float c = 3.14;
>
>      dump!(a, b, c)(); // a = 42, b = foo, c = 3.14
>      stdout.dump!(a, b, c)(" | "); // a = 42 | b = foo | c = 3.14
> }

I think this is good stuff and should go in Phobos. Where particularly? -- Andrei
February 09, 2016
On Tuesday, 9 February 2016 at 14:38:23 UTC, Andrei Alexandrescu wrote:
> On 02/09/2016 07:46 AM, Jakob Ovrum wrote:
>>
>>
>> void main()
>> {
>>      import std.stdio : stdout;
>>
>>      int a = 42;
>>      string b = "foo";
>>      float c = 3.14;
>>
>>      dump!(a, b, c)(); // a = 42, b = foo, c = 3.14
>>      stdout.dump!(a, b, c)(" | "); // a = 42 | b = foo | c = 3.14
>> }
>
> I think this is good stuff and should go in Phobos. Where particularly? -- Andrei

I can't really see the applications beyond a role as a simple lowtech debugging aid, but since it uses std.stdio I guess that's an OK place to put it.

February 09, 2016
On Tuesday, 9 February 2016 at 12:46:34 UTC, Jakob Ovrum wrote:
> I'm not a fan of non-trivial string mixins except in extenuating circumstances.

This is something Steven Schveighoffer commented on in these discussions as well. As this is a fundamental D feature and it's currently rather clunky and hard to use it would suggest this needs improvement. What should be done with it if anything and with what methods?
February 09, 2016
On 02/08/2016 02:15 PM, Nick Sabalausky wrote:
>
> I'd wanted to do a non-mixin version, but that hasn't been possible.

Well, wasn't possible at the time, anyway.

February 09, 2016
On 02/09/2016 10:34 AM, ixid wrote:
> On Tuesday, 9 February 2016 at 12:46:34 UTC, Jakob Ovrum wrote:
>> I'm not a fan of non-trivial string mixins except in extenuating
>> circumstances.
>
> This is something Steven Schveighoffer commented on in these discussions
> as well. As this is a fundamental D feature and it's currently rather
> clunky and hard to use it would suggest this needs improvement. What
> should be done with it if anything and with what methods?

An alternate solution is liable to be too clever for its own good. Everybody and their cat understands string concatenation. What we need here is better tactical tools, e.g. a simple string template/interpolation engine. -- Andrei
February 10, 2016
On Tuesday, 9 February 2016 at 18:02:50 UTC, Andrei Alexandrescu wrote:
> On 02/09/2016 10:34 AM, ixid wrote:
> An alternate solution is liable to be too clever for its own good. Everybody and their cat understands string concatenation. What we need here is better tactical tools, e.g. a simple string template/interpolation engine. -- Andrei

I wasn't suggesting throwing the baby out with the bathwater. Library and IDE support to what's there would be great.
February 10, 2016
On Tuesday, 9 February 2016 at 18:02:50 UTC, Andrei Alexandrescu wrote:
> On 02/09/2016 10:34 AM, ixid wrote:
>> On Tuesday, 9 February 2016 at 12:46:34 UTC, Jakob Ovrum wrote:
>>> I'm not a fan of non-trivial string mixins except in extenuating
>>> circumstances.
>>
>> This is something Steven Schveighoffer commented on in these discussions
>> as well. As this is a fundamental D feature and it's currently rather
>> clunky and hard to use it would suggest this needs improvement. What
>> should be done with it if anything and with what methods?
>
> An alternate solution is liable to be too clever for its own good. Everybody and their cat understands string concatenation. What we need here is better tactical tools, e.g. a simple string template/interpolation engine. -- Andrei

Sorry, but where dump! function can be helpful? What's wrong with writeln?
February 10, 2016

Dne 10.2.2016 v 15:06 Suliman via Digitalmars-d napsal(a):
> On Tuesday, 9 February 2016 at 18:02:50 UTC, Andrei Alexandrescu wrote:
>> On 02/09/2016 10:34 AM, ixid wrote:
>>> On Tuesday, 9 February 2016 at 12:46:34 UTC, Jakob Ovrum wrote:
>>>> I'm not a fan of non-trivial string mixins except in extenuating
>>>> circumstances.
>>>
>>> This is something Steven Schveighoffer commented on in these discussions
>>> as well. As this is a fundamental D feature and it's currently rather
>>> clunky and hard to use it would suggest this needs improvement. What
>>> should be done with it if anything and with what methods?
>>
>> An alternate solution is liable to be too clever for its own good. Everybody and their cat understands string concatenation. What we need here is better tactical tools, e.g. a simple string template/interpolation engine. -- Andrei
>
> Sorry, but where dump! function can be helpful? What's wrong with writeln?
It is something else. Same as php has echo and var_dump. writeln just output value of some variable, but dump will print names and values of variables, so you can see structure of your data.