RE: enum question

2014-03-18 Thread eric
Awesome... it works!-Eric Original Message Subject: Re: enum question From: Ali Çehreli Date: Tue, March 18, 2014 3:51 pm To: digitalmars-d-learn@puremagic.com On 03/18/2014 01:40 PM, Eric wrote: > Apparently you can't pass an enum as a reference, It is

Troubles with taskPool.amap, lambdas and more

2014-03-18 Thread bearophile
This Rosettacode code task (in two different D versions) seems to show some D/Phobos regressions (or just some problems): http://rosettacode.org/wiki/Parallel_calculations#D In the second version (that works with dmd 2.066alpha) I have had to comment out the pure nothrow here, despite this use

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 23:33:12 UTC, bearophile wrote: Chris Williams: But I also like to know how most-effectively to write a C-style macro in D, so it seemed worth checking what the state of the art is. This is an antipattern :-) Bye, bearophile As are goto, pointers, and conditio

GDC/LDC on Sparc Solaris

2014-03-18 Thread Nordlöw
Does GDC and/or LDC have sparc solaris backend support? I'm trying to make my company use D and we have a bunch of legacy machines that unfortunately run on sparc-solaris 2.10. /Per

Re: Alias template param - Undefined Identifier

2014-03-18 Thread bearophile
Chris Williams: But I also like to know how most-effectively to write a C-style macro in D, so it seemed worth checking what the state of the art is. This is an antipattern :-) Bye, bearophile

Re: Alias template param - Undefined Identifier

2014-03-18 Thread anonymous
On Tuesday, 18 March 2014 at 23:10:05 UTC, Chris Williams wrote: Annoying that formatting the string is required. I think you're right that it's ignoring my alias parameter because I'm not using it. Formatting doesn't accomplish anything except to use the parameter. But in exchange, you have to

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 23:05:51 UTC, bearophile wrote: Chris Williams: I could put a wrapper around the calls to these functions that performs this action, but I figured a little macro would be sufficient for my needs (it's just a little script.) I suggest to keep the code simpler. By

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 22:42:20 UTC, anonymous wrote: You can pass the variable name as a string: Or you can get the variable name from the alias parameter: import std.string: format; template gotoPath(alias path) { enum gotoPath = format(q{ ...

Re: Alias template param - Undefined Identifier

2014-03-18 Thread bearophile
Chris Williams: I could put a wrapper around the calls to these functions that performs this action, but I figured a little macro would be sufficient for my needs (it's just a little script.) I suggest to keep the code simpler. Bye, bearophile

Re: enum question

2014-03-18 Thread Ali Çehreli
On 03/18/2014 01:40 PM, Eric wrote: > Apparently you can't pass an enum as a reference, It is possible as seen in the following code. > I have read on this forum that someday enums may be able to be > made with class elements. Someday is today! :) class C { int i; this(int i) {

Re: Alias template param - Undefined Identifier

2014-03-18 Thread anonymous
On Tuesday, 18 March 2014 at 21:56:32 UTC, Chris Williams wrote: import fs = std.file; import std.stdio; template gotoPath(alias path) { enum gotoPath = q{ string currPath = fs.getcwd(); scope (exit) fs.chdir(currPath); fs.chdir(path); }; This is just a string.

Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
I have a series of functions that each needs to change directory, perform an action, and then revert to the original working directory. I could put a wrapper around the calls to these functions that performs this action, but I figured a little macro would be sufficient for my needs (it's just

Re: enum question

2014-03-18 Thread Eric
On Tuesday, 18 March 2014 at 20:56:45 UTC, Adam D. Ruppe wrote: On Tuesday, 18 March 2014 at 20:40:36 UTC, Eric wrote: However, using struct type seems inefficient because structs are pass by value. That's not necessarily a problem, especially if the struct is small, passing by value is faste

Re: enum question

2014-03-18 Thread Adam D. Ruppe
On Tuesday, 18 March 2014 at 20:40:36 UTC, Eric wrote: However, using struct type seems inefficient because structs are pass by value. That's not necessarily a problem, especially if the struct is small, passing by value is faster than by reference. What is your code trying to do? Can enums

enum question

2014-03-18 Thread Eric
I would like to use enums with elements that are either a struct type or a class type. However, using struct type seems inefficient because structs are pass by value. Apparently you can't pass an enum as a reference, so eliminating the pass by value for enums does not seem possible. I have

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread Meta
On Tuesday, 18 March 2014 at 19:18:23 UTC, anonymous wrote: See the rest of my message. Right, I was afraid this was the case.

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread anonymous
On Tuesday, 18 March 2014 at 18:58:04 UTC, Meta wrote: On Tuesday, 18 March 2014 at 17:38:26 UTC, anonymous wrote: [...] Since left and right are alias parameters, you need "alias" in the is expression, too: --- if (is(P == Pair!(left, right), alias left, alias right) && /* etc */) --- Ye

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread Meta
On Tuesday, 18 March 2014 at 17:38:26 UTC, anonymous wrote: On Tuesday, 18 March 2014 at 16:02:26 UTC, Meta wrote: I'd like to have the arguments of the template parameter list of an is-expression to be visible outside that is-expression, but I can't figure out a way to get an alias to them. Is

Re: Ubuntu dmd 2.065 amd64 linkage problem.

2014-03-18 Thread Carl Sturtivant
I can now confirm that the part of the document http://dlang.org/dll-linux.html about loading D dynamic libraries from a D main program is experimentally apparently correct with a real world largish executable. The machinery to initialize the runtime in the dynamic library in http://stackove

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread Ali Çehreli
On 03/18/2014 10:44 AM, anonymous wrote: On Tuesday, 18 March 2014 at 17:07:01 UTC, Ali Çehreli wrote: On 03/18/2014 09:02 AM, Meta wrote: [...] struct Pair(alias left, alias right) {} template Left(P) if (is(P == Pair!(left, right), left, right) && is(typeof(left) == int) && is(typeo

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread anonymous
On Tuesday, 18 March 2014 at 17:07:01 UTC, Ali Çehreli wrote: On 03/18/2014 09:02 AM, Meta wrote: [...] struct Pair(alias left, alias right) {} template Left(P) if (is(P == Pair!(left, right), left, right) && is(typeof(left) == int) && is(typeof(right) == int)) Too many typeofs there

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread anonymous
On Tuesday, 18 March 2014 at 16:02:26 UTC, Meta wrote: I'd like to have the arguments of the template parameter list of an is-expression to be visible outside that is-expression, but I can't figure out a way to get an alias to them. Is something like this possible? struct Pair(alias left, ali

Re: Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread Ali Çehreli
On 03/18/2014 09:02 AM, Meta wrote: I'd like to have the arguments of the template parameter list of an is-expression to be visible outside that is-expression, but I can't figure out a way to get an alias to them. Is something like this possible? struct Pair(alias left, alias right) {} template

Aliasing arguments in the template parameter list of an is-expression

2014-03-18 Thread Meta
I'd like to have the arguments of the template parameter list of an is-expression to be visible outside that is-expression, but I can't figure out a way to get an alias to them. Is something like this possible? struct Pair(alias left, alias right) {} template Left(P) if (is(P == Pair!(left, r

Re: Appending Text to SWT Textbox from multiple threads.

2014-03-18 Thread Sharad Gupta
On Tuesday, 18 March 2014 at 07:20:05 UTC, Jacob Carlborg wrote: On Tuesday, 18 March 2014 at 07:19:05 UTC, Jacob Carlborg wrote: What exact problems do you have? Note that SWT is not thread safe. All UI changes need to be made on the UI thread. This is usually done using the "Display.asyncE

Re: DirEntries range seems impractical with foreach

2014-03-18 Thread Spacen Jasset
On Tuesday, 18 March 2014 at 08:54:50 UTC, Spacen Jasset wrote: On Monday, 17 March 2014 at 20:39:45 UTC, anonymous wrote: On Monday, 17 March 2014 at 09:18:36 UTC, Spacen Jasset wrote: While trying to use dirEntries range with foreach I encountered a seemingly unsurmountable problem. The probl

Re: DirEntries range seems impractical with foreach

2014-03-18 Thread Spacen Jasset
On Monday, 17 March 2014 at 20:39:45 UTC, anonymous wrote: On Monday, 17 March 2014 at 09:18:36 UTC, Spacen Jasset wrote: While trying to use dirEntries range with foreach I encountered a seemingly unsurmountable problem. The problem is that an execption is thrown while calling .front() on the

Re: Appending Text to SWT Textbox from multiple threads.

2014-03-18 Thread Jacob Carlborg
On Tuesday, 18 March 2014 at 07:19:05 UTC, Jacob Carlborg wrote: What exact problems do you have? Note that SWT is not thread safe. All UI changes need to be made on the UI thread. This is usually done using the "Display.asyncExec" method. Forgot the link to the example: http://git.eclipse.

Re: Appending Text to SWT Textbox from multiple threads.

2014-03-18 Thread Jacob Carlborg
On Monday, 17 March 2014 at 23:16:16 UTC, Sharad Gupta wrote: Hi All, I am trying to update a text box from another thread but it has me stumped right now. What I am trying to achieve is that the user can Initiate multiple pipeShell and the output from each of those should go into its own T