Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 15:16:35 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this e

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:47:50 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: Glad you asked! It is very simple: I am trying to get the underlying D type from a type that I have. But why? What are you going to do with it? I'm going to use it in m

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this easily? What are you actually trying to do? Glad you asked! It is very simple: I am trying to get the underlying D typ

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 05:15:07 UTC, Mike Parker wrote: On Saturday, 18 March 2017 at 02:23:01 UTC, Hussien wrote: I need the general solution. One that simply returns the type. None of what you said helps... string dtype(T)() { static if(is(T == enum)) return "enum"; el

Re: Get most D type from type

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 00:36:21 UTC, Nicholas Wilson wrote: On Friday, 17 March 2017 at 23:54:36 UTC, Hussien wrote: I am using Parameters and ReturnType which give me the "name" of the type used. e.g., int foo(SomeEnum) will give SomeEnum and int for the type respectively. What I nee

Get most D type from type

2017-03-17 Thread Hussien via Digitalmars-d-learn
I am using Parameters and ReturnType which give me the "name" of the type used. e.g., int foo(SomeEnum) will give SomeEnum and int for the type respectively. What I need to do, is also get the D types that these use. int is int, but SomeEnum is an enum. Is there a traits function or some way

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: On Fri, Mar 17, 2017 at 03:14:08PM +, Hussien via Digitalmars-d-learn wrote: [...] [...] This appears to be yet another case of the term "compile-time" causing confusion, because it's actually an ambiguous ter

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 14:27:25 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 13:53:58 UTC, Hussien wrote: Yes, but you have a nested foreach loop. One runtime and one compile time. The break goes with the runtime loop... but NORMAL programming logic tells us that the break goes wi

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 13:10:23 UTC, Jonathan M Davis wrote: On Friday, March 17, 2017 11:53:41 Michael via Digitalmars-d-learn wrote: On Friday, 17 March 2017 at 11:30:48 UTC, Jonathan M Davis wrote: > On Friday, March 17, 2017 01:55:19 Hussien via > Digitalmars-d-learn wrote:

Re: bug in foreach continue

2017-03-16 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:41:47 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 01:34:52 UTC, Hussien wrote: Seems like continue needs to be static aware. That's not a bug, pragma is triggered when the code is *compiled*, not when it is run. The code is compiled, even if it is ski

Re: How to get inner most nested struct

2017-03-16 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:19:54 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 00:34:22 UTC, Hussien wrote: Anyway to do this? I don't think you can, the inner anonymous structs are just to organize the members and group them inside the union. ;/ D should retain the structure in

Re: multi compare

2017-03-16 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:27:01 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 00:39:15 UTC, Hussien wrote: if (x in [a,b,c,..]) import std.algorithm.comparison; x.among(a, b, c); http://dpldocs.info/experimental-docs/std.algorithm.comparison.among.1.html thanks

bug in foreach continue

2017-03-16 Thread Hussien via Digitalmars-d-learn
foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") { } else pragma(msg, y); } works but foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") continue pragma(msg, y); } fails. Seems like continue needs to be static aware. This leads to subtle bugs where one thinks the co

multi compare

2017-03-16 Thread Hussien via Digitalmars-d-learn
Instead of if (x == a || x == b || x = c || ) is there an easier way stuff like if (x in [a,b,c,..]) doesn't work.

How to get inner most nested struct

2017-03-16 Thread Hussien via Digitalmars-d-learn
struct VARIANT { union { struct { VARTYPE vt; WORD wReserved1; WORD wReserved2; WORD wReserved3; union { int lVal; LONGLONG llVal; ubyte bVal; short iVal;

Cannot compile dmd2

2017-03-16 Thread Hussien via Digitalmars-d-learn
I downloaded dmd2 nightly and tried to compile the compiler using the visual studio project. Using VS2014 I got several errors. There seems to be issue with locations of things in the project. 1. I had to download default_ddoc_theme.ddoc from the net and put it in /dmd2/src/dmd/vcbuild so t

Safe COM Variant

2017-03-15 Thread Hussien via Digitalmars-d-learn
Is there a safe com variant? We need to call To use a variant properly we must 1. CoTaskMemAlloc 2. VariantInit 3. VariantClear 4. CoTaskMemFree With 1/4 COM calls randomly crash/fail. (which is what lead me to use them) 2/3 are specified by COM spec. I guess D doesn't have a SafeVariant t