Re: Function template argument deduction

2018-04-07 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 7 April 2018 at 05:46:07 UTC, Uknown wrote: I don't see the error you are talking about: https://run.dlang.io/is/XWPIc1 Are you using the latest compiler? Compile with -unittest. And yes; I'm using DMD 2.079.0.

Re: Function template argument deduction

2018-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 04/06/2018 11:26 PM, Uknown wrote: > On Saturday, 7 April 2018 at 05:58:10 UTC, Paul Backus wrote: >> On Saturday, 7 April 2018 at 05:46:07 UTC, Uknown wrote: >>> I don't see the error you are talking about: >>> https://run.dlang.io/is/XWPIc1 >>> >>> Are you using the latest compiler? >> >>

Re: How to destruct class instances allocated by a Region-allocator over a single GC block

2018-04-07 Thread Eduard Staniloiu via Digitalmars-d-learn
On Friday, 6 April 2018 at 21:49:37 UTC, Per Nordlöw wrote: On Tuesday, 3 April 2018 at 09:14:28 UTC, Eduard Staniloiu wrote: So, say `reg` is your allocator, your workflow would be auto obj = reg.make!Type(args); /* do stuff */ reg.dispose(obj); // If Type has a __dtor, it will call

Re: Function template argument deduction

2018-04-07 Thread Uknown via Digitalmars-d-learn
On Saturday, 7 April 2018 at 05:58:10 UTC, Paul Backus wrote: On Saturday, 7 April 2018 at 05:46:07 UTC, Uknown wrote: I don't see the error you are talking about: https://run.dlang.io/is/XWPIc1 Are you using the latest compiler? Compile with -unittest. And yes; I'm using DMD 2.079.0.

Re: Game and GC

2018-04-07 Thread Danni Coy via Digitalmars-d-learn
gc causes unpredictabilities in performance*. With games it tends to be worst case performance that matters. I would reccomend using std.experimental.allocator (even if you still use the default GC backed allocator). This will allow you to swap out your allocator for a more specialised one as

std.datetime.systime: days Deprecation message

2018-04-07 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below Deprecation message. import std.datetime.systime: Clock, days, SysTime; void main (int AgeSize) { int AgeSize = 1 auto ct2 = Clock.currTime(), st2 = ct2 + days(-AgeSize); } test.d(30): Deprecation: Symbol core.time.days is not visible from module

Benchmarking sigmoid function between C and D

2018-04-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
What am I doing wrong here that makes the D equivalent 2.5 times slower than it's C equivalent? Compilers used: LDC2: LDC - the LLVM D compiler (1.8.0) GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 11:36:39 ~/code/c/test2$ ldc2 sigmoid.d -O5 && ./sigmoid Max deviation is 0.001664

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Daniel N via Digitalmars-d-learn
On Saturday, 7 April 2018 at 18:53:57 UTC, Arun Chandrasekaran wrote: What am I doing wrong here that makes the D equivalent 2.5 times slower than it's C equivalent? Compilers used: LDC2: LDC - the LLVM D compiler (1.8.0) GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 11:36:39

Re: dustmite watch shell script (.test vs .lookahead.*)

2018-04-07 Thread Anonymouse via Digitalmars-d-learn
On Friday, 6 April 2018 at 15:42:04 UTC, Vladimir Panteleev wrote: On Friday, 6 April 2018 at 15:35:59 UTC, Anonymouse wrote: The dustmite wiki[0] lists the following example script for use to monitor the reduction progress: Here's a more complete version that also works with -j:

Re: Function template argument deduction

2018-04-07 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 7 April 2018 at 06:26:24 UTC, Uknown wrote: What I did notice though is that when `string list2string(T)(List!T list)` was changed to `string list2string(T)(VariantN!(16LU, Nil, Tuple!(T, "head", This*, "tail")) list)` The compiler correctly deduce `T` to be `int` Interesting.

Re: Function template argument deduction

2018-04-07 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 7 April 2018 at 14:02:55 UTC, Paul Backus wrote: Interesting. Looks like this is an issue with aliases, because I get the error with this code too: --- test.d import std.typecons: Tuple, tuple; alias Pair(T) = Tuple!(T, T); void foo(T)(Pair!T p) { return; } unittest {

Re: How to destruct class instances allocated by a Region-allocator over a single GC block

2018-04-07 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 7 April 2018 at 07:50:37 UTC, Eduard Staniloiu wrote: On Friday, 6 April 2018 at 21:49:37 UTC, Per Nordlöw wrote: On Tuesday, 3 April 2018 at 09:14:28 UTC, Eduard Staniloiu wrote: So, say `reg` is your allocator, your workflow would be auto obj = reg.make!Type(args); /* do stuff

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Daniel Kozak via Digitalmars-d-learn
can you try it with c math functions? instead of std.math, try to use core.stdc.math On Sat, Apr 7, 2018 at 8:53 PM, Arun Chandrasekaran via Digitalmars-d-learn wrote: > What am I doing wrong here that makes the D equivalent 2.5 times slower > than it's C

Re: std.datetime.systime: days Deprecation message

2018-04-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 April 2018 at 17:25:07 UTC, Vino wrote: Hi All, Request your help on the below Deprecation message. import std.datetime.systime: Clock, days, SysTime; void main (int AgeSize) { int AgeSize = 1 auto ct2 = Clock.currTime(), st2 = ct2 + days(-AgeSize); } test.d(30): Deprecation:

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Daniel Kozak via Digitalmars-d-learn
or for ldc http://docs.algorithm.dlang.io/latest/mir_math_common.html On Sat, Apr 7, 2018 at 9:10 PM, Daniel Kozak wrote: > can you try it with c math functions? > > instead of std.math, try to use core.stdc.math > > On Sat, Apr 7, 2018 at 8:53 PM, Arun Chandrasekaran via >

Re: Store struct tuple of alias and access members through it?

2018-04-07 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 7 April 2018 at 13:31:01 UTC, Timoses wrote: In the end I would like to accomplish the following: Provide access to contained bitfields and members of a struct in the order they appear in the struct via an index. The behavior of Type.tupleof in D seems a bit unfinished - they

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 7 April 2018 at 23:48:36 UTC, kinke wrote: On Saturday, 7 April 2018 at 20:33:13 UTC, Arun Chandrasekaran wrote: [...] As this appears to be benchmarking mostly the std.math.exp(float) performance - some/many basic algos in std.math, incl. exp(), are currently using the x87 FPU

Store struct tuple of alias and access members through it?

2018-04-07 Thread Timoses via Digitalmars-d-learn
(Please read at the very bottom what I'd like to achieve) Is it possible to return the member of a struct by its .tupleof index? I know that it would work on a struct value, but I'd like it to work on the type's tupleof: ``` struct S { int i;} S s; // below leads to: Error: need this for

HTTP-methods and encoding

2018-04-07 Thread Vindex via Digitalmars-d-learn
There is an error on some sites when using HTTP-methods (std.net.curl.get, std.net.curl.post): std.encoding.EncodingException@std/encoding.d(2505): Unrecognized Encoding: utf8 Is there a beautiful way around it? For the GET-method I use the download() and readText(). But for the POST-method I

Re: HTTP-methods and encoding

2018-04-07 Thread Seb via Digitalmars-d-learn
On Saturday, 7 April 2018 at 13:02:39 UTC, Vindex wrote: There is an error on some sites when using HTTP-methods (std.net.curl.get, std.net.curl.post): std.encoding.EncodingException@std/encoding.d(2505): Unrecognized Encoding: utf8 Is there a beautiful way around it? For the GET-method I use

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 7 April 2018 at 19:14:27 UTC, Daniel Kozak wrote: or for ldc http://docs.algorithm.dlang.io/latest/mir_math_common.html On Sat, Apr 7, 2018 at 9:10 PM, Daniel Kozak wrote: can you try it with c math functions? instead of std.math, try to use core.stdc.math

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread Guillaume Piolat via Digitalmars-d-learn
On Saturday, 7 April 2018 at 20:33:13 UTC, Arun Chandrasekaran wrote: On Saturday, 7 April 2018 at 19:14:27 UTC, Daniel Kozak wrote: or for ldc http://docs.algorithm.dlang.io/latest/mir_math_common.html On Sat, Apr 7, 2018 at 9:10 PM, Daniel Kozak wrote: can you try it

Re: HTTP-methods and encoding

2018-04-07 Thread Vindex via Digitalmars-d-learn
On Saturday, 7 April 2018 at 15:58:14 UTC, Seb wrote: On Saturday, 7 April 2018 at 13:02:39 UTC, Vindex wrote: There is an error on some sites when using HTTP-methods (std.net.curl.get, std.net.curl.post): std.encoding.EncodingException@std/encoding.d(2505): Unrecognized Encoding: utf8 Is

Re: Store struct tuple of alias and access members through it?

2018-04-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 April 2018 at 13:31:01 UTC, Timoses wrote: Simen was faster :) In my solution I simply ignore such things as functions... But there is the cool delegate creation approach in Simen's solution for this. I can handle arrays instead. :) And I got rid of tupelof acting on an

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread kinke via Digitalmars-d-learn
On Saturday, 7 April 2018 at 20:33:13 UTC, Arun Chandrasekaran wrote: Much better with mir.math.common, still a bit slower than C (even with larger loops): As this appears to be benchmarking mostly the std.math.exp(float) performance - some/many basic algos in std.math, incl. exp(), are