Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:23 PM, tsbockman wrote: On Friday, 13 May 2016 at 06:05:14 UTC, Andrew Edwards wrote: Additionally, what's the best way to handle nested #ifdef's? Those that appear inside structs, functions and the like... I know that global #ifdef's are turned to version blocks but versions blocks

Re: imports && -run [Bug?]

2016-05-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-05-13 08:10, tsbockman wrote: According to the DMD compiler manual, the -run switch only accepts a single source file: -run srcfile args... After the first source file, any further arguments passed to DMD will be interpreted as arguments to be passed to the program being run. To

Re: imports && -run [Bug?]

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:10 PM, tsbockman wrote: On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote: command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: er

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread tsbockman via Digitalmars-d-learn
On Friday, 13 May 2016 at 06:05:14 UTC, Andrew Edwards wrote: Additionally, what's the best way to handle nested #ifdef's? Those that appear inside structs, functions and the like... I know that global #ifdef's are turned to version blocks but versions blocks cannot be used inside classes, stuc

Re: imports && -run [Bug?]

2016-05-12 Thread tsbockman via Digitalmars-d-learn
On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote: command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit c

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 7:51 AM, Andrew Edwards wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX 9

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread tsbockman via Digitalmars-d-learn
On Friday, 13 May 2016 at 04:59:23 UTC, Andrew Edwards wrote: Is there a way to reproduce the same behavior? Are there reason's for not allowing this functionality or am I just misunderstanding and going about things the wrong way? [1] same result whether placed before or after the #include/i

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:40 AM, Andrew Edwards wrote: That seems wrong. You can't assign to an enum. Besides, doesn't your declaration of MIN shadow whatever other definitions may be currently in effect? Okay, got it. It seams I just hadn't hit that bug yet because of other unresolved issues. Perhaps wha

imports && -run [Bug?]

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
module mod; // import inc; [1] // import inc: p=print; [1] // static import inc; [1] void main() { // import inc: print; // [2] print(); // static import inc; // [3] // inc.print(); } -- module inc; /*public*/ void print() // [4] { import std.std

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:00 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, May 13, 2016 at 07:51:17AM +0900, Andrew Edwards via Digitalmars-d-learn wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 13, 2016 at 07:51:17AM +0900, Andrew Edwards via Digitalmars-d-learn wrote: > The following preprocessor directives are frequently encountered in C > code, providing a default constant value where the user of the code > has not specified one: > > #ifndef MIN > #define MIN

Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX 999 #endif I'm at

Re: Dynamically setting struct values from hash map

2016-05-12 Thread Andrew Chapman via Digitalmars-d-learn
On Thursday, 12 May 2016 at 21:01:06 UTC, Adam D. Ruppe wrote: foreach(member; __traits(allMembers, YourStruct)) if(member in yourhash) __traits(getMember, your_object, member) = to!right_type(yourhash[member]); basically, it is a bit more complex to filter out inappropriate fields and

Re: Dynamically setting struct values from hash map

2016-05-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 12 May 2016 at 20:52:46 UTC, Andrew Chapman wrote: I have seen the "allMembers" method from the traits module that can give me the names of the struct fields, but I am unsure if it's even possible to set the struct values using variable/dynamic names. Yes. You can't loop over t

Dynamically setting struct values from hash map

2016-05-12 Thread Andrew Chapman via Digitalmars-d-learn
Hi guys, apologies for the silly question, but I come from the world of dynamic languages and I'm wondering if it's possible to set struct values basic on dynamic variables? e.g. struct Person { string firstName; string lastName; } void main() { string[string] map; map["firstName

Re: How to split a string/array with multiple separators?

2016-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/16 3:25 PM, Thorsten Sommer wrote: On Wednesday, 16 December 2015 at 15:27:22 UTC, Marc Schütz wrote: On Wednesday, 16 December 2015 at 14:47:26 UTC, Dragos Carp wrote: On Wednesday, 16 December 2015 at 14:18:28 UTC, Borislav Kosharov wrote: I want to split a string using multiple sepa

Re: How to split a string/array with multiple separators?

2016-05-12 Thread Thorsten Sommer via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 15:27:22 UTC, Marc Schütz wrote: On Wednesday, 16 December 2015 at 14:47:26 UTC, Dragos Carp wrote: On Wednesday, 16 December 2015 at 14:18:28 UTC, Borislav Kosharov wrote: I want to split a string using multiple separators. In std.array the split function has

Re: Is this template constraint a bug?

2016-05-12 Thread Eric via Digitalmars-d-learn
Yes, it's a bug. Please file an issue. Meanwhile try this workaround: class A(T) { static assert(is(T : A!T), "..."); } Bug report filed, and thanks for the workaround. -Eric

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 15:29:17 UTC, Vadim Lopatin wrote: Hello, External themes support is planned. It is not a hard task. Btw, try to copy your resource files (res directory) to the same place dlangui executable (e.g. dlangide) is located. Resources from this directory must be accessi

Re: Is this template constraint a bug?

2016-05-12 Thread Daniel N via Digitalmars-d-learn
On Thursday, 12 May 2016 at 15:33:24 UTC, Eric wrote: is(T : A!T) tells if T can automatically be converted to A!T. The last line below is doing just that, yet the template constraint does not work. class A(T) if (is(T : A!T)) { } Yes, it's a bug. Please file an issue. Meanwhile try thi

Is this template constraint a bug?

2016-05-12 Thread Eric via Digitalmars-d-learn
is(T : A!T) tells if T can automatically be converted to A!T. The last line below is doing just that, yet the template constraint does not work. class A(T) if (is(T : A!T)) { } // if (is(T : A!T)) gives this error: // Error: template instance x.A!(B) does not match //template declara

Re: DlangIDE Themes

2016-05-12 Thread Vadim Lopatin via Digitalmars-d-learn
On Thursday, 12 May 2016 at 09:57:42 UTC, Chris wrote: On Thursday, 12 May 2016 at 09:51:18 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 09:17:24 UTC, Chris wrote: They shouldn't be hardwired. Best would be to load them dynamically with their respective names encoded in the xml file. In

Re: .array changes the order

2016-05-12 Thread xtreak via Digitalmars-d-learn
On Thursday, 12 May 2016 at 13:43:10 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 10:17:19 UTC, xtreak wrote: Thanks a lot. Can you kindly elaborate a little more on File.byLine with an example of the scenario so that I don't get bitten by it. File.byLine.array works as expected for me.

Re: Async or event library

2016-05-12 Thread yawniek via Digitalmars-d-learn
On Tuesday, 10 May 2016 at 13:34:36 UTC, chmike wrote: vibed uses libevent, a C library. The discussion is regarding a possible pure D equivalent of libevent. libasync is an interesting proposal but it is apparently slower than libevent. I don't know the current status because vibed improved

Re: Async or event library

2016-05-12 Thread Dsby via Digitalmars-d-learn
On Tuesday, 10 May 2016 at 13:34:36 UTC, chmike wrote: vibed uses libevent, a C library. The discussion is regarding a possible pure D equivalent of libevent. libasync is an interesting proposal but it is apparently slower than libevent. I don't know the current status because vibed improved

Re: .array changes the order

2016-05-12 Thread thedeemon via Digitalmars-d-learn
On Thursday, 12 May 2016 at 10:17:19 UTC, xtreak wrote: Thanks a lot. Can you kindly elaborate a little more on File.byLine with an example of the scenario so that I don't get bitten by it. File.byLine.array works as expected for me. A little more explanation on the permutations will also be

Is it bug compiler?

2016-05-12 Thread MGW via Digitalmars-d-learn
Windows 7 32bit --- import std.stdio; import std.conv; class CFormaMain { ~this() { char[] zz = [ 'A', 'B', 'C' ]; writeln(to!string(zz)); } } int main(string[] args) { CFormaMain formaMain; formaMain = new CForm

Re: Is it bug compiler?

2016-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/16 9:20 AM, MGW wrote: Windows 7 32bit --- import std.stdio; import std.conv; class CFormaMain { ~this() { char[] zz = [ 'A', 'B', 'C' ]; This allocates. Allocations are not allowed in GC collection cycle. -Steve

Re: Is it bug compiler?

2016-05-12 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 12 May 2016 at 13:20:35 UTC, MGW wrote: Windows 7 32bit --- import std.stdio; import std.conv; class CFormaMain { ~this() { char[] zz = [ 'A', 'B', 'C' ]; writeln(to!string(zz)); } } int main(string[] args) {

Re: static import (v2.071.0)

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 12:45:38 UTC, Steven Schveighoffer wrote: On 5/11/16 10:11 AM, Chris wrote: No. static import just defines what symbols are accessible in what contexts. The (likely) reason you are getting this is because you are importing a module with a selective import: impor

Re: .array changes the order

2016-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/16 6:17 AM, xtreak wrote: On Thursday, 12 May 2016 at 10:02:46 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 09:44:39 UTC, xtreak wrote: I came across the issue where using .array after .joiner caused the changes to the output. The program is at https://dpaste.dzfl.pl/0885ba2eddb4 .

Re: static import (v2.071.0)

2016-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/16 10:11 AM, Chris wrote: I'm updating my code to 2.071.0 at the moment. Naturally, I get a lot of warnings like `module std.uni is not accessible here, perhaps add 'static import std.uni;'` Will `static import` bloat my exe or simply access the members I use? No. static import just

Re: D equivalent of C++ bind ?

2016-05-12 Thread Dsby via Digitalmars-d-learn
On Tuesday, 10 May 2016 at 15:33:03 UTC, chmike wrote: Thanks. This does the job but it's not as concise. The std.functional.partial can not use in runtime, only on complier time. and it can not bind args that more than one.

Re: D equivalent of C++ bind ?

2016-05-12 Thread Dsby via Digitalmars-d-learn
On Tuesday, 10 May 2016 at 09:39:53 UTC, chmike wrote: Is there an equivalent in D of the C++11 std.bind template class [http://en.cppreference.com/w/cpp/utility/functional/bind] ? Here is a blog post showing different examples of its use https://oopscenities.net/2012/02/24/c11-stdfunction-and

Re: .array changes the order

2016-05-12 Thread xtreak via Digitalmars-d-learn
On Thursday, 12 May 2016 at 10:02:46 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 09:44:39 UTC, xtreak wrote: I came across the issue where using .array after .joiner caused the changes to the output. The program is at https://dpaste.dzfl.pl/0885ba2eddb4 . I tried to debug through the out

Re: .array changes the order

2016-05-12 Thread thedeemon via Digitalmars-d-learn
On Thursday, 12 May 2016 at 09:44:39 UTC, xtreak wrote: I came across the issue where using .array after .joiner caused the changes to the output. The program is at https://dpaste.dzfl.pl/0885ba2eddb4 . I tried to debug through the output but I couldn't get the exact issue. It will be helpful

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 09:51:18 UTC, thedeemon wrote: On Thursday, 12 May 2016 at 09:17:24 UTC, Chris wrote: They shouldn't be hardwired. Best would be to load them dynamically with their respective names encoded in the xml file. In this way people could add their own themes as they see

Re: DlangIDE Themes

2016-05-12 Thread thedeemon via Digitalmars-d-learn
On Thursday, 12 May 2016 at 09:17:24 UTC, Chris wrote: They shouldn't be hardwired. Best would be to load them dynamically with their respective names encoded in the xml file. In this way people could add their own themes as they see fit. I wouldn't mind creating themes and adding them to Dla

.array changes the order

2016-05-12 Thread xtreak via Digitalmars-d-learn
I came across the issue where using .array after .joiner caused the changes to the output. The program is at https://dpaste.dzfl.pl/0885ba2eddb4 . I tried to debug through the output but I couldn't get the exact issue. It will be helpful if someone confirms this as a bug.

Re: DlangIDE Themes

2016-05-12 Thread Chris via Digitalmars-d-learn
On Thursday, 12 May 2016 at 03:01:02 UTC, thedeemon wrote: On Wednesday, 11 May 2016 at 12:55:13 UTC, Chris wrote: Is there a way I can add my own themes? I've created a theme file and added it to views/resources.list However, it doesn't show up. "Default" and "Dark" seem to be hardwired some