std.experimental.allocator and @nogc

2016-07-21 Thread Yuxuan Shui via Digitalmars-d-learn
I was trying to use allocators in a @nogc function. I tried FreeList!Mallocator and it works fine. But AllocatorList!Mallocator doesn't work. dmd complains that AllocatorList.allocate is not @nogc, even when BookkeepingAllocator is NullAllocator. But if I add '@nogc' to

full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own path. The original batch script uses the %~dp0 variable for this,

Re: multithreaded hell, help!

2016-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 21, 2016 21:47:09 rikki cattermole via Digitalmars-d-learn wrote: > On 21/07/2016 9:44 PM, Brons wrote: > > Im trying to access data in a global between threads. > > So ive set my global to shared, however the object trying to access it > > needs to also then be shared, but it

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 21, 2016 19:54:34 Jonathan Marler via Digitalmars-d-learn wrote: > Is there a way to get the full path of the current source file? > Something like: > > __FILE_FULL_PATH__ > > I'm asking because I'm rewriting a batch script in D, meant to be > ran with rdmd. However, the script

Re: full path to source file __FILE__

2016-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:28:39 UTC, zabruk70 wrote: won't? what this means? That gives the path to the .exe but he wants the path to the .d. But why? I would think the current working directory is probably adequate and that's easy to get...

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:33:39 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:28:39 UTC, zabruk70 wrote: won't? what this means? That gives the path to the .exe but he wants the path to the .d. But why? I would think the current working directory is probably adequate and

Re: full path to source file __FILE__

2016-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/16 3:54 PM, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own path. The original batch

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:39:45 UTC, Steven Schveighoffer wrote: On 7/21/16 3:54 PM, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with

Re: union initalization

2016-07-21 Thread Rufus Smith via Digitalmars-d-learn
On Friday, 22 July 2016 at 02:08:06 UTC, Ali Çehreli wrote: On 07/21/2016 06:48 PM, Rufus Smith wrote: > I would like to combine two types > > > template Foo(A, B = 4) > { > union > { > byte b = B; > int a = A << 8; > } > } > > This packs a and b together in to an

union initalization

2016-07-21 Thread Rufus Smith via Digitalmars-d-learn
I would like to combine two types template Foo(A, B = 4) { union { byte b = B; int a = A << 8; } } This packs a and b together in to an int bytes, saving an int(rather than storing a and b in an int each) and makes it easier to access. I get an error about

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:57:06 UTC, Jonathan M Davis wrote: On Thursday, July 21, 2016 18:39:45 Steven Schveighoffer via Digitalmars-d- learn wrote: [...] It would be pretty terrible actually to put the executable in the source path, and in many cases, the user wouldn't even have the

Re: union initalization

2016-07-21 Thread Ali Çehreli via Digitalmars-d-learn
On 07/21/2016 06:48 PM, Rufus Smith wrote: > I would like to combine two types > > > template Foo(A, B = 4) > { > union > { > byte b = B; > int a = A << 8; > } > } > > This packs a and b together in to an int bytes, saving an int(rather > than storing a and b in an

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 01:52:57 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:47:42 UTC, Jonathan Marler wrote: I explain in the original post. Any ideas Adam? Thanks in advance. But why does the batch script use it? Since you are rewriting anyway, maybe you can find an

Re: full path to source file __FILE__

2016-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:47:42 UTC, Jonathan Marler wrote: I explain in the original post. Any ideas Adam? Thanks in advance. But why does the batch script use it? Since you are rewriting anyway, maybe you can find an easier/better way to achieve the goal.

Re: full path to source file __FILE__

2016-07-21 Thread zabruk70 via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: thisExePath won't work. won't? what this means? this work on my windows import std.file: thisExePath; import std.stdio: writeln; void main() { writeln(thisExePath()); }

Re: full path to source file __FILE__

2016-07-21 Thread fdgdsgf via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own

Re: LDC with ARM backend

2016-07-21 Thread Claude via Digitalmars-d-learn
On Thursday, 21 July 2016 at 10:30:55 UTC, Andrea Fontana wrote: On Thursday, 21 July 2016 at 09:59:53 UTC, Claude wrote: I can build a "Hello world" program on ARM GNU/Linux, with druntime and phobos. I'll write a doc page about that. It's a good idea :) Done:

Re: Default implementations in inherited interfaces

2016-07-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. You

Re: Default implementations in inherited interfaces

2016-07-21 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. How can I achieve this? I'm facing an error when I try this: interface

Re: multithreaded hell, help!

2016-07-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/07/2016 9:44 PM, Brons wrote: Im trying to access data in a global between threads. So ive set my global to shared, however the object trying to access it needs to also then be shared, but it cant be because its part of a library... Is there any simple way to transfer data from one thread

Re: LDC with ARM backend

2016-07-21 Thread Claude via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 16:10:48 UTC, Claude wrote: R_ARM_TLS_IE32 used with non-TLS symbol ?? Oh, that was actually quite obvious... If I revert the first android patch on LLVM sources, and build it back it works! I can build a "Hello world" program on ARM GNU/Linux, with druntime

Re: shuffle a character array

2016-07-21 Thread pineapple via Digitalmars-d-learn
On Wednesday, 20 July 2016 at 18:32:15 UTC, Jesse Phillips wrote: I think you mean that your range library treats them as arrays of code units, meaning your library will break (some) unicode strings. Right - I disagree with the assessment that all (or even most) char[] types are intended to

multithreaded hell, help!

2016-07-21 Thread Brons via Digitalmars-d-learn
Im trying to access data in a global between threads. So ive set my global to shared, however the object trying to access it needs to also then be shared, but it cant be because its part of a library... Is there any simple way to transfer data from one thread to another? 1. My situation is

Default implementations in inherited interfaces

2016-07-21 Thread Saurabh Das via Digitalmars-d-learn
I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. How can I achieve this? I'm facing an error when I try this: interface A { int func(int); } interface B : A { final int

Re: multithreaded hell, help!

2016-07-21 Thread Brons via Digitalmars-d-learn
On Thursday, 21 July 2016 at 09:47:09 UTC, rikki cattermole wrote: On 21/07/2016 9:44 PM, Brons wrote: Im trying to access data in a global between threads. So ive set my global to shared, however the object trying to access it needs to also then be shared, but it cant be because its part of

Re: LDC with ARM backend

2016-07-21 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 21 July 2016 at 09:59:53 UTC, Claude wrote: I can build a "Hello world" program on ARM GNU/Linux, with druntime and phobos. I'll write a doc page about that. It's a good idea :)

Re: Default implementations in inherited interfaces

2016-07-21 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 21 July 2016 at 09:46:10 UTC, Lodovico Giaretta wrote: Interesting. This is worth a bugzilla issue, IMHO. In fact, if you try the other way (i.e.: you provide an implementation of func in class C), you get the opposite error, that you are overriding a final function (B.func).

Re: Default implementations in inherited interfaces

2016-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. You can't, interfaces cannot have implementations of virtual

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 21, 2016 18:39:45 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 7/21/16 3:54 PM, Jonathan Marler wrote: > > Is there a way to get the full path of the current source file? > > Something like: > > > > __FILE_FULL_PATH__ > > > > I'm asking because I'm rewriting a batch