January 30, 2015
On 1/30/15 1:29 AM, Foo wrote:
>
> @nogc
> @safe
> T[n] s(T = Args[0], size_t n = Args.length, Args...)(auto ref Args args)
> pure nothrow {
>      return [args];
> }
>
> @nogc
> @safe
> T[n] s(T, size_t n)(auto ref T[n] values) pure nothrow {
>      return values;
> }
>
> void main() {
>      pragma(msg, typeof(s(1, 2, 3)));
>      pragma(msg, typeof([1, 2, 3].s));
> }
> ----
>
> Compilation output:
> int[3]
> int[3]
>
> You only have to type a dot between the array and the 's'.
> Because of pure and nothrow and the low cost of the function call even
> such a lousy thing like the DMD optimizer should be capable of inlining
> such a function every time.

Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei

January 30, 2015
On 1/30/2015 6:54 AM, Andrei Alexandrescu wrote:
> On 1/30/15 1:29 AM, Foo wrote:
> Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei


I'm going to swipe this for an upcoming presentation I'm doing. Thanks, Foo!
January 30, 2015
On Friday, 30 January 2015 at 22:21:15 UTC, Walter Bright wrote:
> On 1/30/2015 6:54 AM, Andrei Alexandrescu wrote:
>> On 1/30/15 1:29 AM, Foo wrote:
>> Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei
>
>
> I'm going to swipe this for an upcoming presentation I'm doing. Thanks, Foo!

My pleasure.
January 31, 2015
> Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei

So, pull request for std.array and reverting the dollar thingie?
Problem solved?
January 31, 2015
On 1/31/15 1:10 AM, Martin Nowak wrote:
>> Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei
>
> So, pull request for std.array and reverting the dollar thingie?
> Problem solved?

This looks like the way to go. I apologize to the community for the indecision shown. -- Andrei
January 31, 2015
On 1/31/2015 8:08 AM, Andrei Alexandrescu wrote:
> On 1/31/15 1:10 AM, Martin Nowak wrote:
>>> Thanks for this code, it's a lot nicer and simpler than mine. -- Andrei
>>
>> So, pull request for std.array and reverting the dollar thingie?
>> Problem solved?
>
> This looks like the way to go. I apologize to the community for the indecision
> shown. -- Andrei

I'm on board with this, too.
1 2
Next ›   Last »