Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
On 28/02/2017 01:20, sarn wrote: > On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: >> How can I make sure, that the calculations are done at compile time? > > If you ever have doubts, you can always use something like this to check: > > assert (__ctfe); Thanks a lot,

Re: Recommend: IDE and GUI library

2017-02-27 Thread thedeemon via Digitalmars-d-learn
On Friday, 24 February 2017 at 22:44:55 UTC, XavierAP wrote: Hi I've looked at wiki.dlang.org/IDEs, and I see that Visual D is linked from dlang.org/download.html. Still I was looking for personal opinions and experiences beyond hard specs, I wonder if one of the IDEs is already dominant at

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 00:20:05 UTC, sarn wrote: On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread sarn via Digitalmars-d-learn
On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: How can I make sure, that the calculations are done at compile time? If you ever have doubts, you can always use something like this to check: assert (__ctfe);

Re: getSymbolsByUDA toSymbols error instantiating

2017-02-27 Thread Ali Çehreli via Digitalmars-d-learn
On 02/27/2017 06:26 AM, Oleg B wrote: Hello. I have this code: ```d import std.traits; enum myuda; class A { @myuda int x; } class B : A { @myuda int some; void foo() { foreach (s; getSymbolsByUDA!(typeof(this), myuda)) {} } } void main() { (new B).foo(); } ``` And have this error:

Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 16:04:00 UTC, Bastiaan Veelo wrote: I get a bus error some time out in execution. It could be that I am running out of stack space. I am on OS X, and non-main threads are given a very limited stack size, they say [1, 2]. This foreach of mine calls into itself,

Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Dukc via Digitalmars-d-learn
On Monday, 27 February 2017 at 19:26:06 UTC, Christian Köstlin wrote: Is it enough to put up static immutable modifiers? How can I make sure, that the calculations are done at compile time? ... static immutable time = Unit("time", [Unit.Scale("ms", 1), ... An initialization of a static

How to enforce compile time evaluation (and test if it was done at compile time)

2017-02-27 Thread Christian Köstlin via Digitalmars-d-learn
I have a small example, that can be used to express 3601000ms as 1h 1s (a much more advanced version has already been done by https://github.com/nordlow/units-d). I would like to enforce that the precomputation (multiplying and inverting the list of scale's) is done at compile time. Is it enough

Re: How to get the name for a Tid

2017-02-27 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:04:38 UTC, Christian Köstlin wrote: std.concurrency contains the register function to associate a name with a Tid. This is stored internally in an associative array namesByTid. I see no accessors for this. Is there a way to get to the associated names of a

Re: Package visibility strange behaviour

2017-02-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 27, 2017 14:07:21 Oleg B via Digitalmars-d-learn wrote: > Hello. Is this behavior normal, or it's a bug? And if it's normal > why it's normal? I want to use function with `package` visibility > in same package where it's defined, but I don't. > > ```d > module package_visible;

Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 11:53:09 UTC, ag0aep6g wrote: You can generate wrapper functions that have no overloads: static int wrap(alias f)(int arg) { return f(arg); } enum addrOf(alias f) = enum fptrs = staticMap!(addrOf, staticMap!(wrap, funcs)); /* ... r and foreach as before ...

getSymbolsByUDA toSymbols error instantiating

2017-02-27 Thread Oleg B via Digitalmars-d-learn
Hello. I have this code: ```d import std.traits; enum myuda; class A { @myuda int x; } class B : A { @myuda int some; void foo() { foreach (s; getSymbolsByUDA!(typeof(this), myuda)) {} } } void main() { (new B).foo(); } ``` And have this error: ``` % rdmd uda_symbols.d

Package visibility strange behaviour

2017-02-27 Thread Oleg B via Digitalmars-d-learn
Hello. Is this behavior normal, or it's a bug? And if it's normal why it's normal? I want to use function with `package` visibility in same package where it's defined, but I don't. ```d module package_visible; package void foo() { } void main() { foo(); } ``` ``` % rdmd package_visible.d

Re: Parallel foreach over AliasSec?

2017-02-27 Thread ag0aep6g via Digitalmars-d-learn
On 02/27/2017 10:52 AM, Bastiaan Veelo wrote: On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote: [...] enum fptr(alias f) = (This is still a bit magical to me: it this a shorthand for a template?) Yes, it's short for this: template fptr(alias f) { enum fptr = } "addrOf" is

Re: Getting nice print of struct for debugging

2017-02-27 Thread Martin Tschierschke via Digitalmars-d-learn
On Saturday, 25 February 2017 at 01:30:09 UTC, Minty Fresh wrote: On Saturday, 25 February 2017 at 01:27:09 UTC, Minty Fresh wrote: On Wednesday, 22 February 2017 at 11:18:15 UTC, Martin Tschierschke wrote: [...] Since structs are Plain-old Data and don't do inheritance, the best option is

Re: Parallel foreach over AliasSec?

2017-02-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote: Make a range or an array of function pointers from the AliasSeq of function aliases: import std.meta: staticMap; import std.range: only; enum fptr(alias f) = enum fptrs = staticMap!(fptr, funcs); auto r = only(fptrs); foreach

Re: How to get the name for a Tid

2017-02-27 Thread Oleg B via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:04:38 UTC, Christian Köstlin wrote: std.concurrency contains the register function to associate a name with a Tid. This is stored internally in an associative array namesByTid. I see no accessors for this. Is there a way to get to the associated names of a

Re: code D'ish enough? - ignore previous post with same subject

2017-02-27 Thread Thorstein via Digitalmars-d-learn
On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: auto readNumMatCsv2 (string filePath, string ndv, string new_ndv){ double[][] p_numArray; try { auto lines = File(filePath,"r").byLine; lines.popFront; // get read of header p_numArray =

Re: code D'ish enough? - ignore previous post with same subject

2017-02-27 Thread Thorstein via Digitalmars-d-learn
I really appriciate your comments and thoughts! On Sunday, 26 February 2017 at 21:02:52 UTC, ag0aep6g wrote: On Sunday, 26 February 2017 at 19:34:33 UTC, thorstein wrote: * "no-data-value"? No-data-values in data sets are common at least in geosciences: raster images, spatial simulation