Re: LDC cross-module-inlining
On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote: I am not sure but last time I checked ldc does not do cross module inlinig by default, and LTO only help if your ldc(druntime+phobos) are built with enabled LTO[1] [1] https://github.com/ldc-developers/ldc/issues/2182#issuecomment-343166633 Are the official LDC-releases builtin with or without LTO?
Re: LDC cross-module-inlining
On Mon, Aug 10, 2020 at 1:15 PM Per Nordlöw via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote: > > I am not sure but last time I checked ldc does not do cross > > module inlinig by default, and LTO only help if your > > ldc(druntime+phobos) are built with enabled LTO[1] > > > > [1] > > https://github.com/ldc-developers/ldc/issues/2182#issuecomment-343166633 > > Are the official LDC-releases builtin with or without LTO? > AFAIK only for OSX, but Arch linux ldc package is now build with LTO enabled
Re: LDC cross-module-inlining
On Monday, 10 August 2020 at 11:11:57 UTC, Per Nordlöw wrote: Are the official LDC-releases builtin with or without LTO? Most of them are, but not sure why that matters here (the gain is almost negligible and mainly interesting for the C++ parts - as all D files are compiled to a single object file anyway). On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote: I am not sure but last time I checked ldc does not do cross module inlinig by default, Right, it's still experimental and has issues. and LTO only help if your ldc(druntime+phobos) are built with enabled LTO That's only true if (mostly non-templated) functions in druntime/Phobos are to be cross-module inlined, just like any other library. In that case, you can simply use `-flto= -defaultlib=phobos2-ldc-lto,druntime-ldc-lto` with LDC builds shipping with LTO druntime/Phobos and don't have to recompile druntime/Phobos manually anymore.
Re: generating random numbers
On 8/10/20 1:51 AM, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me answer two simple questions: How to generate a random floating number in range [0,1) ? How to set a seed value, prior to generating random values ? Tangential: I also find mir-random [0] a very nice library that is easy to use and has no deps on D runtime, so can be used in Das Better C mode. I think it is also a better random engine than phobos [0] https://code.dlang.org/packages/mir-random
Re: __vector(ubyte[32]) misalignment
On 8/9/20 8:46 AM, Steven Schveighoffer wrote: On 8/9/20 8:37 AM, Steven Schveighoffer wrote: I think this has come up before, there may even be a bug report on it. Found one, I'll see if I can fix the array runtime: https://issues.dlang.org/show_bug.cgi?id=10826 Bruce, I have a PR to hopefully fix these issues, if you want to test against it: https://github.com/dlang/druntime/pull/3192 -Steve
Re: generating random numbers
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me answer two simple questions: How to generate a random floating number in range [0,1) ? How to set a seed value, prior to generating random values ? Strange example for sure. I'd recommend checking out the examples on the landing page for std.random: https://dlang.org/library/std/random.html
Re: generating random numbers
On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote: On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me answer two simple questions: How to generate a random floating number in range [0,1) ? How to set a seed value, prior to generating random values ? Strange example for sure. I'd recommend checking out the examples on the landing page for std.random: https://dlang.org/library/std/random.html I created a PR with a hopefully clearer example: https://github.com/dlang/phobos/pull/7588
Re: Factory pattern for classes
On Sunday, 9 August 2020 at 15:56:31 UTC, Ali Çehreli wrote: On 8/9/20 7:27 AM, lexxn wrote: I getClassById(uint id) { if (id == 0) { return cast(A)Object.factory("deneme.A"); } else if(id == 1) { return cast(B)Object.factory("deneme.B"); } else { return cast(C)Object.factory("deneme.C"); } } void main() { auto o = getClassById(1); o.methodName(); } Ali Btw is it possible to pass a property to the constructor, if I've one declared, in the factory? I'm talking about this piece cast(A)Object.factory("deneme.A")
Re: generating random numbers
On Monday, 10 August 2020 at 15:13:51 UTC, bachmeier wrote: On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote: On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote: generating random numbers using https://dlang.org/library/std/random/uniform01.html I find the example given in this section totally incomprehensible .. Can any help me answer two simple questions: How to generate a random floating number in range [0,1) ? How to set a seed value, prior to generating random values ? Strange example for sure. I'd recommend checking out the examples on the landing page for std.random: https://dlang.org/library/std/random.html I created a PR with a hopefully clearer example: https://github.com/dlang/phobos/pull/7588 Ahhh yes, yes .. this is the way to write Dlang example code : https://dlang.org/library/std/random.html
Re: Factory pattern for classes
On 8/10/20 8:38 AM, lexxn wrote: Btw is it possible to pass a property to the constructor, if I've one declared, in the factory? I'm talking about this piece cast(A)Object.factory("deneme.A") I think you mean "parameter". No, Object.factory creates the object with its default constructor. Ali
Re: __vector(ubyte[32]) misalignment
On Monday, 10 August 2020 at 13:52:46 UTC, Steven Schveighoffer wrote: On 8/9/20 8:46 AM, Steven Schveighoffer wrote: On 8/9/20 8:37 AM, Steven Schveighoffer wrote: I think this has come up before, there may even be a bug report on it. Found one, I'll see if I can fix the array runtime: https://issues.dlang.org/show_bug.cgi?id=10826 Bruce, I have a PR to hopefully fix these issues, if you want to test against it: https://github.com/dlang/druntime/pull/3192 -Steve The "fix issue 10826" reading was interesting. Thanks for pushing this one through.
Re: Factory pattern for classes
On Sunday, 9 August 2020 at 15:56:31 UTC, Ali Çehreli wrote: module deneme; import std.stdio; interface I { void methodName(); } ... I getClassById(uint id) { if (id == 0) { return cast(A)Object.factory("deneme.A"); } else if(id == 1) { return cast(B)Object.factory("deneme.B"); } else { return cast(C)Object.factory("deneme.C"); } } void main() { auto o = getClassById(1); o.methodName(); } Why not simply do? I getClassById(uint id) { if (id == 0) { return new A(); } else if(id == 1) { return new B(); } else { return new C(); } } Then you can also pass parameters to the constructors or call further factories to create them, as long as they return a `I`-compatible type.
Re: __vector(ubyte[32]) misalignment
On Monday, 10 August 2020 at 13:52:46 UTC, Steven Schveighoffer wrote: On 8/9/20 8:46 AM, Steven Schveighoffer wrote: On 8/9/20 8:37 AM, Steven Schveighoffer wrote: I think this has come up before, there may even be a bug report on it. Found one, I'll see if I can fix the array runtime: https://issues.dlang.org/show_bug.cgi?id=10826 Bruce, I have a PR to hopefully fix these issues, if you want to test against it: https://github.com/dlang/druntime/pull/3192 -Steve No biggee but it looks like there is some duplicate code at the end of the __alignPad unittest.
Re: __vector(ubyte[32]) misalignment
On 8/10/20 2:53 PM, Bruce Carneal wrote: No biggee but it looks like there is some duplicate code at the end of the __alignPad unittest. Hah! I think I copy-pasted that intending to write a new test, but then tried it separately and found another issue (typeid(__vector(ubyte[32])).talign returned 16!) So I forgot to go back in and delete that case. Thanks -Steve