Re: Does the CTFE engine reuse variables?

2017-04-08 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 9 April 2017 at 05:42:02 UTC, Jethro wrote: Suppose one has a function that will be used in CTFE and it uses a lot of local variables. Does each call of the function end up allocating space for these without ever releasing them or are they reused? or used on the stack like normal?

Re: Variable Arguments

2017-04-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/04/2017 7:30 AM, Jethro wrote: void foo(A...)(A a) { foreach(aa; a) { for(int i = 0; i < a.length; i++) ... } } A can be strings or char, how can I easily deal with both? (e.g., a.length = 1 for a being a char... and also a[0] = a, so to speak). That is, I

Variable Arguments

2017-04-08 Thread Jethro via Digitalmars-d-learn
void foo(A...)(A a) { foreach(aa; a) { for(int i = 0; i < a.length; i++) ... } } A can be strings or char, how can I easily deal with both? (e.g., a.length = 1 for a being a char... and also a[0] = a, so to speak). That is, I want chars to be treated as strings

Re: Using template mixin, with or without mixin ?

2017-04-08 Thread Meta via Digitalmars-d-learn
On Saturday, 8 April 2017 at 22:37:18 UTC, ag0aep6g wrote: On 04/08/2017 11:59 PM, Meta wrote: enum a = 0; template test1() { enum b1 = a; //Okay, a is in scope at the declaration site //enum c = d1; Error: undefined identifier d1 This line works just fine, actually. There's really no

Does the CTFE engine reuse variables?

2017-04-08 Thread Jethro via Digitalmars-d-learn
Suppose one has a function that will be used in CTFE and it uses a lot of local variables. Does each call of the function end up allocating space for these without ever releasing them or are they reused? or used on the stack like normal?

BinaryHeap crashes upon insertion if heapified with an array of length 1?

2017-04-08 Thread TheGag96 via Digitalmars-d-learn
I'm trying to use a binary heap initialized with one element. However, this always seems to cause a range violation for some reason. This small example will do it: import std.stdio, std.container; void main() { auto pq = heapify([5]); pq.insert(8); } ...And it produces this error: https:/

Re: Time from timestamp?

2017-04-08 Thread timotheecour via Digitalmars-d-learn
Might I suggest that you simply define an enum for UnixEpoch that's a SysTime. Then you can do whatever you want. ping on this.

Re: Using template mixin, with or without mixin ?

2017-04-08 Thread ag0aep6g via Digitalmars-d-learn
On 04/08/2017 11:59 PM, Meta wrote: enum a = 0; template test1() { enum b1 = a; //Okay, a is in scope at the declaration site //enum c = d1; Error: undefined identifier d1 This line works just fine, actually. There's really no difference between a normal template and a mixin template

Re: Using template mixin, with or without mixin ?

2017-04-08 Thread Meta via Digitalmars-d-learn
On Saturday, 8 April 2017 at 09:47:07 UTC, biocyberman wrote: On Friday, 7 April 2017 at 23:53:12 UTC, Ali Çehreli wrote: The difference is that you can't use funcgen as a regular template: funcgen!(void, void); Error: template instance funcgen!(void, void) mixin templates are not regu

Re: GNU Guile D language interop

2017-04-08 Thread bachmeier via Digitalmars-d-learn
On Saturday, 8 April 2017 at 21:29:58 UTC, new2d wrote: Can someone experienced in D port the GNU Guile embedding tutorial over? It would be great if Guile can be used to embed in D Thank you https://www.gnu.org/software/guile/docs/guile-tut/tutorial.html#Fundamentals I have embedded Guile

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread Ali Çehreli via Digitalmars-d-learn
On 04/08/2017 03:11 AM, biocyberman wrote: > On Saturday, 8 April 2017 at 10:02:01 UTC, Mike Parker wrote: >> >> I would expect if you implement it as a function the compiler will >> inline it. You can always use the pragma(inline, true) [1] with >> -inline to verify. >> >> [1] https://dlang.org/s

-fPIC and 32-bit dmd.conf settings

2017-04-08 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
Hello folks, The default dmd.conf settings for 64-bit environments include the -fPIC flag (for good reason), but the settings for 32-bit environments do not. Any particular reason for this? Thanks & best wishes, -- Joe

GNU Guile D language interop

2017-04-08 Thread new2d via Digitalmars-d-learn
Can someone experienced in D port the GNU Guile embedding tutorial over? It would be great if Guile can be used to embed in D Thank you https://www.gnu.org/software/guile/docs/guile-tut/tutorial.html#Fundamentals

Re: Function names and lambdas

2017-04-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-07 23:05, Ali Çehreli wrote: Main reason for D not supporting the name-to-pointer mapping? I don't think so because as far as I know this has been the case since very early on but UFCS came very much later. More likely due to properties, i.e. calling functions without parentheses.

Re: Is DMD breaking BigInt?

2017-04-08 Thread Meta via Digitalmars-d-learn
On Saturday, 8 April 2017 at 12:14:31 UTC, Russel Winder wrote: On Fri, 2017-04-07 at 22:47 +, Meta via Digitalmars-d-learn wrote: […] Do you have the -dip1000 switch enabled? Not as far as I know. Why would I want to do that? You wouldn't as the std lib doesn't work with it yet.

Re: Is DMD breaking BigInt?

2017-04-08 Thread ag0aep6g via Digitalmars-d-learn
On 04/07/2017 07:06 PM, Russel Winder via Digitalmars-d-learn wrote: factorial.d(71,15): Error: template std.bigint.BigInt.__ctor cannot deduce function from argument types !()(string) immutable On 04/08/2017 02:18 PM, Russel Winder via Digitalmars-d-learn wrote: https://github.com/russel/Fac

Re: Is DMD breaking BigInt?

2017-04-08 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 8 April 2017 at 12:16:10 UTC, Russel Winder wrote: Fedora Rawhide is now on LLVM 4.0 is that going to be a problem building LDC? Of course not! ;-) -Johan

Re: Is DMD breaking BigInt?

2017-04-08 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-04-07 at 20:29 +, Jack Stouffer via Digitalmars-d- learn wrote: > On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote: > > Simple Dub build of a Factorial example using Unit-Threaded for  > > testing. Works fine with ldc2 breaks with dmd. > > Can you post the code your us

Re: Is DMD breaking BigInt?

2017-04-08 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-04-07 at 20:38 +, David Nadlinger via Digitalmars-d- learn wrote: > […] > > You might want to check with LDC from Git master first to see  > whether it is in fact a 2.073-related problem. — David Rats, I thought I'd got away from manually building LDC. Fedora Rawhide is now on L

Re: Is DMD breaking BigInt?

2017-04-08 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-04-07 at 22:47 +, Meta via Digitalmars-d-learn wrote: > […] > > Do you have the -dip1000 switch enabled? Not as far as I know. Why would I want to do that? -- Russel. = Dr Russel Winder t: +44 20 7

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 11:24:02 UTC, Nicholas Wilson wrote: The ':' means that it applies to everything that follows it, so while it doesn't matters in this example if you had pragma( inline, true ): int kroundup32( int x) { ... } auto someVeryLargeFunction( Args args) { // ... } an

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 8 April 2017 at 11:01:34 UTC, biocyberman wrote: On Saturday, 8 April 2017 at 10:09:47 UTC, Mike Parker wrote: T kroundup32(T)(T x) { pragma(inline, true); --(x); (x)|=(x)>>1; (x)|=(x)>>2; (x)|=(x)>>4; (x)|=(x)>>8; (x)|=(x)>>16; return ++(x); } I a

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 10:09:47 UTC, Mike Parker wrote: T kroundup32(T)(T x) { pragma(inline, true); --(x); (x)|=(x)>>1; (x)|=(x)>>2; (x)|=(x)>>4; (x)|=(x)>>8; (x)|=(x)>>16; return ++(x); } I also came up with this: import std.stdio; pragma( inline, true

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 10:02:01 UTC, Mike Parker wrote: I would expect if you implement it as a function the compiler will inline it. You can always use the pragma(inline, true) [1] with -inline to verify. [1] https://dlang.org/spec/pragma.html#inline Thanks for mentioning pragma. Ho

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 8 April 2017 at 10:02:01 UTC, Mike Parker wrote: I would expect if you implement it as a function the compiler will inline it. You can always use the pragma(inline, true) [1] with -inline to verify. [1] https://dlang.org/spec/pragma.html#inline This gives me no error, so it d

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 8 April 2017 at 09:53:47 UTC, biocyberman wrote: What is the D mixin version equivalent to this macro: #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) The macro looks cryptic. What the macro does has been explained here: h

Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
What is the D mixin version equivalent to this macro: #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) The macro looks cryptic. What the macro does has been explained here: http://stackoverflow.com/questions/3384852/could-someone-help-ex

Re: Using template mixin, with or without mixin ?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Friday, 7 April 2017 at 23:53:12 UTC, Ali Çehreli wrote: The difference is that you can't use funcgen as a regular template: funcgen!(void, void); Error: template instance funcgen!(void, void) mixin templates are not regular templates I think it's good practice to use 'mixin templa

Re: pointer not aligned

2017-04-08 Thread Mogaki via Digitalmars-d-learn
On Sunday, 2 April 2017 at 19:00:30 UTC, Jon Degenhardt wrote: On Friday, 31 March 2017 at 04:41:10 UTC, Joel wrote: Linking... ld: warning: pointer not aligned at address 0x10017A4C9 (_D30TypeInfo_AxS3std4file8DirEntry6__initZ + 16 from .dub/build/application-debug-posix.osx-x86_64-dmd_2072-E