Re: foo => "bar" key/value literals in D!

2016-06-11 Thread ArturG via Digitalmars-d-announce
On Saturday, 11 June 2016 at 15:46:59 UTC, Vladimir Panteleev wrote: Taking an address creates a function pointer, which loses the argument names. (Doesn't it?) unfortunatly yes, but it works as a struct or class initializer https://dpaste.dzfl.pl/6aad852aea90

Re: foo => "bar" key/value literals in D!

2016-06-11 Thread Vladimir Panteleev via Digitalmars-d-announce
On Saturday, 11 June 2016 at 11:15:43 UTC, ArturG wrote: On Saturday, 11 June 2016 at 09:07:43 UTC, Andrei Alexandrescu wrote: No, both are nice to have. If one name is needed for both, "args" is indeed a good commonality. "Invoke function f with these args" and "Construct an object of type

Re: foo => "bar" key/value literals in D!

2016-06-11 Thread ArturG via Digitalmars-d-announce
On Saturday, 11 June 2016 at 09:07:43 UTC, Andrei Alexandrescu wrote: No, both are nice to have. If one name is needed for both, "args" is indeed a good commonality. "Invoke function f with these args" and "Construct an object of type T with these args". The problem is it's not very

Re: foo => "bar" key/value literals in D!

2016-06-11 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 6/11/16 3:57 AM, Vladimir Panteleev wrote: On Tuesday, 31 May 2016 at 06:21:03 UTC, Andrei Alexandrescu wrote: On 5/27/16 10:17 PM, Taylor Hillegeist wrote: On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have

Re: foo => "bar" key/value literals in D!

2016-06-10 Thread Vladimir Panteleev via Digitalmars-d-announce
On Tuesday, 31 May 2016 at 06:21:03 UTC, Andrei Alexandrescu wrote: On 5/27/16 10:17 PM, Taylor Hillegeist wrote: On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! Yes, though what

Re: foo => "bar" key/value literals in D!

2016-06-10 Thread Vladimir Panteleev via Digitalmars-d-announce
On Wednesday, 8 June 2016 at 09:19:46 UTC, John wrote: On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: This is by far the most appealing way to implement named arguments that I've seen so far: https://github.com/CyberShadow/ae/blob/master/utils/meta/args.d Another cool

Re: foo => "bar" key/value literals in D!

2016-06-08 Thread John via Digitalmars-d-announce
On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: This is by far the most appealing way to implement named arguments that I've seen so far: https://github.com/CyberShadow/ae/blob/master/utils/meta/args.d Another cool thing this enables: object initializers. T init(T,

Re: foo => "bar" key/value literals in D!

2016-05-31 Thread Era Scarecrow via Digitalmars-d-announce
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- Prints out: { foo: bar baz: 12 } Pretty

Re: foo => "bar" key/value literals in D!

2016-05-31 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 5/27/16 10:17 PM, Taylor Hillegeist wrote: On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! Yes, though what does it have to do with this thread? :D This is by far the most

Re: foo => "bar" key/value literals in D!

2016-05-27 Thread Taylor Hillegeist via Digitalmars-d-announce
On Friday, 27 May 2016 at 18:10:59 UTC, Vladimir Panteleev wrote: On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! Yes, though what does it have to do with this thread? :D This is by far the most appealing way to implement named arguments that I've

Re: foo => "bar" key/value literals in D!

2016-05-27 Thread Vladimir Panteleev via Digitalmars-d-announce
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! Yes, though what does it have to do with this thread? :D This is by far the most appealing way to implement named arguments that I've seen so far:

Re: foo => "bar" key/value literals in D!

2016-05-26 Thread Jacob Carlborg via Digitalmars-d-announce
On 2016-05-25 20:55, Meta wrote: Is that true? I don't claim to know exactly how the compiler works, but given a template lambda: foo => 3 Doesn't it generate something like the following? template __lambda10293(T) { __lambda10293(T foo) { return 3; } } In that

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Meta via Digitalmars-d-announce
On Wednesday, 25 May 2016 at 11:22:41 UTC, Jacob Carlborg wrote: I don't think this is the right approach. I think the correct approach is to allow introspection of template parameters [1]. That would allow to get the parameter names without having to instantiate the template. Is that true?

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Jacob Carlborg via Digitalmars-d-announce
On 2016-05-25 13:57, Daniel N wrote: Issue9608 is good too, but insufficient. import std.traits; static assert(__traits(isTemplate, a => 0)); static assert(!__traits(isTemplate, (int a) => 0)); The 2nd case can't be solved by 9608 since it's about introspecting templates and "(int a) => 0)"

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Adam D. Ruppe via Digitalmars-d-announce
On Wednesday, 25 May 2016 at 09:24:31 UTC, Daniel N wrote: From an end-user perspective I find it reasonable to expect that an API which takes lambda:s works consistently for both below examples. i.e. if we support one we should support the other. [1] fun!( x => y) [2] fun!((int x) =>

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 24 May 2016 at 16:00:32 UTC, Andrei Alexandrescu wrote: Apparently it can be made to work with non-templates as well, see https://dpaste.dzfl.pl/c4b7a8b6978b. Oh, that's the buggy area. The compiler keeps parameter names for runtime delegates... but it also reuses the structures.

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Daniel N via Digitalmars-d-announce
On Wednesday, 25 May 2016 at 11:22:41 UTC, Jacob Carlborg wrote: On 2016-05-25 11:24, Daniel N wrote: ParameterIdentifierTuple can hopefully be updated to take advantage of this feature when it's available in compiler without requiring to change the API of ParameterIdentifierTuple. [1]

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Jacob Carlborg via Digitalmars-d-announce
On 2016-05-25 11:24, Daniel N wrote: From an end-user perspective I find it reasonable to expect that an API which takes lambda:s works consistently for both below examples. i.e. if we support one we should support the other. [1] fun!( x => y) [2] fun!((int x) => y) Currently I just

Re: foo => "bar" key/value literals in D!

2016-05-25 Thread Daniel N via Digitalmars-d-announce
On Tuesday, 24 May 2016 at 01:33:40 UTC, Adam D. Ruppe wrote: On Monday, 23 May 2016 at 20:08:11 UTC, Daniel N wrote: This pull request just removes an intentional restriction and make this feature more easily accessible for meta-programming, so that not everyone has to reinvent the wheel in

Re: foo => "bar" key/value literals in D!

2016-05-24 Thread Andrei Alexandrescu via Digitalmars-d-announce
On 5/23/16 3:00 PM, Adam D. Ruppe wrote: Have I gone completely mad?!?! This is very creative, thanks. Definitely make it part of TWID :o). Apparently it can be made to work with non-templates as well, see https://dpaste.dzfl.pl/c4b7a8b6978b. Regarding applying a hack/ingenious label, I'd

Re: foo => "bar" key/value literals in D!

2016-05-24 Thread Jacob Carlborg via Digitalmars-d-announce
On 2016-05-23 21:00, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- Prints out: { foo: bar baz: 12 } A few tweaks would

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Bauss via Digitalmars-d-announce
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- [...] This is a pretty amazing find! It's like a better

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 24 May 2016 at 01:11:39 UTC, Meta wrote: Clever and terrible. Now just modify the code to generate a struct or class and you've invented new anonymous struct/object syntax. Indeed. Also, I think this has revealed a bug (or deficiency) in the compiler. If you put this inside the

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 23 May 2016 at 20:08:11 UTC, Daniel N wrote: This pull request just removes an intentional restriction and make this feature more easily accessible for meta-programming, so that not everyone has to reinvent the wheel in their own libraries. S I'm actually not entirely

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Meta via Digitalmars-d-announce
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- Prints out: { foo: bar baz: 12 } A few

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Meta via Digitalmars-d-announce
On Tuesday, 24 May 2016 at 01:11:39 UTC, Meta wrote: Clever and terrible. Now just modify the code to generate a struct or class and you've invented new anonymous struct/object syntax. Also, I think this has revealed a bug (or deficiency) in the compiler. If you put this inside the foreach

Re: foo => "bar" key/value literals in D!

2016-05-23 Thread Daniel N via Digitalmars-d-announce
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! That makes two of us, I also use similar techniques. Please help argue in favour of pulling this: https://github.com/dlang/phobos/pull/3620/files https://issues.dlang.org/show_bug.cgi?id=13780 This