Is this possible in D?

2015-02-19 Thread Jonathan Marler via Digitalmars-d-learn
I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the function body? For example: version(StaticVersion) { static void myLongFunction() { // long body ... } } else { void

Re: Is this possible in D?

2015-02-19 Thread tcak via Digitalmars-d-learn
On Thursday, 19 February 2015 at 08:24:08 UTC, Jonathan Marler wrote: I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the function body? For example: version(StaticVersion) { static void m

D : dmd vs gdc : which one to choose?

2015-02-19 Thread Mayuresh Kathe via Digitalmars-d-learn
How do I (a newbie to D) figure out which compiler set to use? I am running Ubuntu 14.10, and intend to stick with it in the long term. Should I choose DMD or go with GDC? I would like to know the rationale for suggestions for either. Thanks.

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Rikki Cattermole via Digitalmars-d-learn
On 19/02/2015 9:46 p.m., Mayuresh Kathe wrote: How do I (a newbie to D) figure out which compiler set to use? I am running Ubuntu 14.10, and intend to stick with it in the long term. Should I choose DMD or go with GDC? I would like to know the rationale for suggestions for either. Thanks. Atle

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread bearophile via Digitalmars-d-learn
Mayuresh Kathe: Should I choose DMD or go with GDC? It's a good idea to use all available compilers. LDC and DMD are both useful. Every one of them has advantages and disadvantages. Bye, bearophile

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Dicebot via Digitalmars-d-learn
On Thursday, 19 February 2015 at 08:46:11 UTC, Mayuresh Kathe wrote: How do I (a newbie to D) figure out which compiler set to use? I am running Ubuntu 14.10, and intend to stick with it in the long term. Should I choose DMD or go with GDC? I would like to know the rationale for suggestions for

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 February 2015 at 08:24:08 UTC, Jonathan Marler wrote: I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the function body? For example: version(StaticVersion) { static void m

Re: Is this possible in D?

2015-02-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 February 2015 at 09:38:48 UTC, Mike Parker wrote: On Thursday, 19 February 2015 at 08:24:08 UTC, Jonathan Marler wrote: I am having a heck of a time trying to figure out how to do this. How do I change the attributes of a function based on the version without copying the functio

Re: Is this possible in D?

2015-02-19 Thread Dicebot via Digitalmars-d-learn
Most practical approach I am currently aware of is wrapping actual implementation (in most restrictive version): class Test { private static void foo_() {} version (Static) { static void foo() { foo_(); } } else { void foo() { foo_(); } } private void bar_() shared { } version (Sha

Re: Quick help on version function parameter

2015-02-19 Thread via Digitalmars-d-learn
On Thursday, 19 February 2015 at 01:39:19 UTC, Jonathan Marler wrote: On Wednesday, 18 February 2015 at 23:49:26 UTC, Adam D. Ruppe wrote: I'd write a foo_impl which always takes a parameter. Then do the versioned foo() functions which just forward to it: void foo_impl(int x) { long function u

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Mayuresh Kathe via Digitalmars-d-learn
On Thursday, 19 February 2015 at 09:10:16 UTC, Rikki Cattermole wrote: On 19/02/2015 9:46 p.m., Mayuresh Kathe wrote: How do I (a newbie to D) figure out which compiler set to use? I am running Ubuntu 14.10, and intend to stick with it in the long term. Should I choose DMD or go with GDC? I wo

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Rikki Cattermole via Digitalmars-d-learn
On 20/02/2015 12:10 a.m., Mayuresh Kathe wrote: On Thursday, 19 February 2015 at 09:10:16 UTC, Rikki Cattermole wrote: On 19/02/2015 9:46 p.m., Mayuresh Kathe wrote: How do I (a newbie to D) figure out which compiler set to use? I am running Ubuntu 14.10, and intend to stick with it in the long

Problem Instantiating a BinaryHeap with a Comparison Function the needs this

2015-02-19 Thread Nordlöw
I can understand how to correctly define an instance of BinaryHeap in my class DijkstraWalker at https://github.com/nordlow/justd/blob/master/knet/traversal.d#L264 because the comparsion function can't ge access to the class member distMap I get the error need 'this' for 'distMap' of type '

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 19 February 2015 at 10:17:47 UTC, Dicebot wrote: Most practical approach I am currently aware of is wrapping actual implementation (in most restrictive version): I really like mixins for this sort of thing. ``` enum signature = "void longFunction()"; version( Static ) enu

Re: Problem Instantiating a BinaryHeap with a Comparison Function the needs this

2015-02-19 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 19 February 2015 at 11:56:19 UTC, Nordlöw wrote: I can understand how to correctly define an instance of BinaryHeap in my class DijkstraWalker at https://github.com/nordlow/justd/blob/master/knet/traversal.d#L264 because the comparsion function can't ge access to the class member

Re: Problem Instantiating a BinaryHeap with a Comparison Function the needs this

2015-02-19 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 19 February 2015 at 11:56:19 UTC, Nordlöw wrote: Please provide reduced examples. This fails: class C { int[] a; alias BH = BinaryHeap!(int[], (x, y) => (x+a < y)); } This works: class C { int[] a; void foo() { alias BH = BinaryHeap!(int[], (x, y) => (x+a

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Thu, 19 Feb 2015 22:10:11 +1300, Rikki Cattermole wrote: > And anyway, GDC is still hasn't been updated to the latest version of D. > And its the last major D compiler that hasn't. LDC is 2.067 already? O_O 'cause GDC is 2.066.1 now. signature.asc Description: PGP signature

Re: Is this possible in D?

2015-02-19 Thread tcak via Digitalmars-d-learn
On Thursday, 19 February 2015 at 12:16:18 UTC, Mike Parker wrote: On Thursday, 19 February 2015 at 10:17:47 UTC, Dicebot wrote: Most practical approach I am currently aware of is wrapping actual implementation (in most restrictive version): I really like mixins for this sort of thing. ``` en

Re: Is this possible in D?

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Thu, 19 Feb 2015 08:24:06 +, Jonathan Marler wrote: > I am having a heck of a time trying to figure out how to do this. > How do I change the attributes of a function based on the > version without copying the function body? For example: > > version(StaticVersion) { > static void m

Re: GC deadlocks on linux

2015-02-19 Thread Byron Heads via Digitalmars-d-learn
On Wednesday, 18 February 2015 at 21:21:11 UTC, Byron Heads wrote: On Wednesday, 18 February 2015 at 21:05:10 UTC, Byron Heads wrote: On Wednesday, 18 February 2015 at 20:55:56 UTC, ketmar wrote: On Wed, 18 Feb 2015 20:35:44 +, Byron Heads wrote: On Wednesday, 18 February 2015 at 20:33:40

State of Windows x64 COFF support?

2015-02-19 Thread Etienne via Digitalmars-d-learn
I'm having corrupt symbol table errors on a Win64 build of a big application, I can't find a way around it. I'm wondering if the COFF support is still experimental in DMD? Thanks!

Re: GC deadlocks on linux

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Thu, 19 Feb 2015 16:33:58 +, Byron Heads wrote: > Now I am not sure. This code runs correctly: as i told you before, `fork()` is hard. you can experiment for monthes seeing strange bugs here and there, and seeing no bugs, and strange bugs, and... there are alot of things going on under

Re: Is this possible in D?

2015-02-19 Thread Mike Parker via Digitalmars-d-learn
On 2/20/2015 1:06 AM, tcak wrote: @OP: By using a token string (q{}) for funcBody rather than a WYSIWYG string (r"" or ``), you can still get syntax highlighting in your editor. Based on your example, bye bye readibility. It is like writing rocket taking off procedures. People are complaining

Re: Undefined symbol?

2015-02-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 February 2015 at 01:29:39 UTC, Tofu Ninja wrote: I am not sure what could be the offending obj. I re downloaded dmd and phobos(pre compiled for windows), cleaned out all my builds and removed all of the tempfiles for dub that I could find. Have you tried running dub with --for

C++ calling convention only

2015-02-19 Thread Benjamin Thaut via Digitalmars-d-learn
Is it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin Thaut

Re: State of Windows x64 COFF support?

2015-02-19 Thread Etienne via Digitalmars-d-learn
On 2015-02-19 11:39 AM, Etienne wrote: I'm having corrupt symbol table errors on a Win64 build of a big application, I can't find a way around it. I'm wondering if the COFF support is still experimental in DMD? Thanks! I just counted 67k sections using a printf in DMD... The limit is 65k so t

Re: State of Windows x64 COFF support?

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Thu, 19 Feb 2015 13:29:58 -0500, Etienne wrote: > On 2015-02-19 11:39 AM, Etienne wrote: >> I'm having corrupt symbol table errors on a Win64 build of a big >> application, I can't find a way around it. I'm wondering if the COFF >> support is still experimental in DMD? >> >> Thanks! > > I just

each extern (C) keyword causes ld (OS X) to add a duplicate library entry

2015-02-19 Thread Ernest Bruce via Digitalmars-d-learn
Note the last two lines of this list (i am running OS X 10.10.2 and Xcode 6.1.1): clang -v -t cprog.c dprog.a -o cprog Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.1.0 Thread model: posix "/Applications/Xcode.app/Contents/Developer/Toolchains/Xco

Re: Is this possible in D?

2015-02-19 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 19 February 2015 at 17:23:47 UTC, Mike Parker wrote: I agree that string mixins can kill readability. I encountered that when I used them to support both D1 and D2 in Derelict 2 years ago. But I think that when they are kept small and local as in cases like this, they aren't bad at

Re: State of Windows x64 COFF support?

2015-02-19 Thread Etienne via Digitalmars-d-learn
On 2015-02-19 1:41 PM, ketmar wrote: i remember that DMD creates one section for each function (to allow smartlink feature). with templates this can be alot. maybe it needs new cli flag "--collapse-sections" or something like it. I watched the section names and discovered over 20,000 sections

Re: C++ calling convention only

2015-02-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 February 2015 at 18:25:10 UTC, Benjamin Thaut wrote: Is it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin Thaut You can use pragma(mangle, ...) to set whatever mangling you like.

Re: C++ calling convention only

2015-02-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 February 2015 at 21:33:50 UTC, John Colvin wrote: On Thursday, 19 February 2015 at 18:25:10 UTC, Benjamin Thaut wrote: Is it possible to declare a function in D which gets the C++ calling convetion but not the C++ mangling? Kind Regards Benjamin Thaut You can use pragma(mangl

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-19 Thread stewarth via Digitalmars-d-learn
On Thursday, 19 February 2015 at 07:46:51 UTC, Ali Çehreli wrote: On 02/18/2015 10:39 PM, stewarth wrote: > This works under dmd 2066.1 but fails under dmd 2.067-b2. I don't know whether it is a bug. > struct B { > A* a; In any case, that must be immutable(A)*. > } > > static immutable

Re: GC deadlocks on linux

2015-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/15 12:01 PM, ketmar wrote: On Thu, 19 Feb 2015 16:33:58 +, Byron Heads wrote: Now I am not sure. This code runs correctly: as i told you before, `fork()` is hard. you can experiment for monthes seeing strange bugs here and there, and seeing no bugs, and strange bugs, and... th

Re: GC deadlocks on linux

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Thu, 19 Feb 2015 17:12:02 -0500, Steven Schveighoffer wrote: > On 2/19/15 12:01 PM, ketmar wrote: >> On Thu, 19 Feb 2015 16:33:58 +, Byron Heads wrote: >> >>> Now I am not sure. This code runs correctly: >> >> as i told you before, `fork()` is hard. you can experiment for monthes >> seeing

Re: Problem Instantiating a BinaryHeap with a Comparison Function the needs this

2015-02-19 Thread Nordlöw
On Thursday, 19 February 2015 at 14:12:51 UTC, Tobias Pankrath wrote: On Thursday, 19 February 2015 at 11:56:19 UTC, Nordlöw wrote: Please provide reduced examples. This fails: class C { int[] a; alias BH = BinaryHeap!(int[], (x, y) => (x+a < y)); } This works: class C { int[] a;

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Rikki Cattermole via Digitalmars-d-learn
On 20/02/2015 5:08 a.m., ketmar wrote: On Thu, 19 Feb 2015 22:10:11 +1300, Rikki Cattermole wrote: And anyway, GDC is still hasn't been updated to the latest version of D. And its the last major D compiler that hasn't. LDC is 2.067 already? O_O 'cause GDC is 2.066.1 now. Well according to G

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Fri, 20 Feb 2015 13:29:09 +1300, Rikki Cattermole wrote: > On 20/02/2015 5:08 a.m., ketmar wrote: >> On Thu, 19 Feb 2015 22:10:11 +1300, Rikki Cattermole wrote: >> >>> And anyway, GDC is still hasn't been updated to the latest version of >>> D. >>> And its the last major D compiler that hasn't.

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread ketmar via Digitalmars-d-learn
On Fri, 20 Feb 2015 02:08:19 +, ketmar wrote: > On Fri, 20 Feb 2015 13:29:09 +1300, Rikki Cattermole wrote: > >> On 20/02/2015 5:08 a.m., ketmar wrote: >>> On Thu, 19 Feb 2015 22:10:11 +1300, Rikki Cattermole wrote: >>> And anyway, GDC is still hasn't been updated to the latest version o

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Rikki Cattermole via Digitalmars-d-learn
On 20/02/2015 3:11 p.m., ketmar wrote: On Fri, 20 Feb 2015 02:08:19 +, ketmar wrote: On Fri, 20 Feb 2015 13:29:09 +1300, Rikki Cattermole wrote: On 20/02/2015 5:08 a.m., ketmar wrote: On Thu, 19 Feb 2015 22:10:11 +1300, Rikki Cattermole wrote: And anyway, GDC is still hasn't been updat

vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
Hi, I'm trying to follow the instructions for vibe-d with: >dub init web vibe.d >cd web >dub and then add the line "subConfigurations": {"vibe-d": "win32"}" to the dub.json file. This however is producing errors during linking. Could I get a hand? Pastebin of dub --vverbose: h

Re: vibe-d basic build errors

2015-02-19 Thread MartinNowak via Digitalmars-d-learn
On Friday, 20 February 2015 at 02:50:05 UTC, Charles wrote: Pastebin of dub --vverbose: http://pastebin.com/4BcHJM74 Target vibe-d 0.7.22 is up to date. Use --force to rebuild. Have you tried the --force switch to rebuild vibe.d? Looks like the existing vibe.d lib was build against a differe

How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Gan via Digitalmars-d-learn
I managed to copy an application bundle and change stuff inside it to run my executable, but it was very manual and kinda hackish. Also I can't get my application to load images that I place in the Resources folder(or any folder in the bundle for that matter). Is there an official way to tur

Re: vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 02:55:32 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 02:50:05 UTC, Charles wrote: Pastebin of dub --vverbose: http://pastebin.com/4BcHJM74 Target vibe-d 0.7.22 is up to date. Use --force to rebuild. Have you tried the --force switch to rebuild vibe.d

Re: vibe-d basic build errors

2015-02-19 Thread MartinNowak via Digitalmars-d-learn
On Friday, 20 February 2015 at 04:00:21 UTC, Charles wrote: Yes, I have. Here's a pastebin with --force --vverbose: http://pastebin.com/qZEKUN46 Just tried the dub init web vibe.d && cd web && dub thing, works for me. So the most interesting questions. - What version of dub and dmd are you u

Re: vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 04:13:08 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 04:00:21 UTC, Charles wrote: Yes, I have. Here's a pastebin with --force --vverbose: http://pastebin.com/qZEKUN46 Just tried the dub init web vibe.d && cd web && dub thing, works for me. So the mos

Re: How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Jeremy DeHaan via Digitalmars-d-learn
On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote: I managed to copy an application bundle and change stuff inside it to run my executable, but it was very manual and kinda hackish. Also I can't get my application to load images that I place in the Resources folder(or any folder in the bun

Re: How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote: Also I can't get my application to load images that I place in the Resources folder(or any folder in the bundle for that matter). I suggest to have a look at the projects generated by SFML regarding locating the resources in C++/ObjC and t

Re: How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Gan via Digitalmars-d-learn
On Friday, 20 February 2015 at 06:10:51 UTC, Nicholas Wilson wrote: On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote: Also I can't get my application to load images that I place in the Resources folder(or any folder in the bundle for that matter). I suggest to have a look at the projects

Re: D : dmd vs gdc : which one to choose?

2015-02-19 Thread Sebastien Alaiwan via Digitalmars-d-learn
On Thursday, 19 February 2015 at 08:46:11 UTC, Mayuresh Kathe wrote: Should I choose DMD or go with GDC? I work with projects whose code is half written in C, half written in D. I use GNU make to build them. I found out that using GDC was a much better choice for several reasons: - project