Re: Get most D type from type

2017-03-17 Thread Mike Parker via Digitalmars-d-learn
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"; else static if(is(T == class)) return "class"; else static if(

Re: Get most D type from type

2017-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2017 07:28 PM, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 23:54:36 UTC, Hussien wrote: What I need to do, is also get the D types that these use. Those aren't types, they are more like categories of type, so there's nothing in the language that can represent them to return (exce

Re: code folding

2017-03-17 Thread Entity325` via Digitalmars-d-learn
On Saturday, 18 March 2017 at 05:00:48 UTC, Entity325` wrote: and both create a scope outside of which no declarations inside them are visible(potentially undesirable side-effects). Oh. Static ifs don't do that. Disregard, I'm wrong.

code folding

2017-03-17 Thread Entity325` via Digitalmars-d-learn
FYI, static if(true)//comments are great for adding some context to your code. { //stuff } and {//let's toss a comment on the scope declaration! //stuff } are functionally equivalent in my IDE. Both will fold down to only the top {(good), and both create a scope outside of which no dec

Re: Get most D type from type

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 23:54:36 UTC, Hussien wrote: What I need to do, is also get the D types that these use. Those aren't types, they are more like categories of type, so there's nothing in the language that can represent them to return (except maybe a string). Instead, you can test

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

Re: GitHub detects .d source as Makefile?

2017-03-17 Thread David Nadlinger via Digitalmars-d-learn
On Saturday, 18 March 2017 at 00:34:57 UTC, XavierAP wrote: Is this a known issue with D on GitHub? Should I report it I guess? How smart is GH that it doesn't look at the file extension? What happened? The extension .d can legitimately refer to makefiles as well (specifically, to dependency

Re: first try

2017-03-17 Thread Philip Miess via Digitalmars-d-learn
On Thu, 16 Mar 2017 19:53:08 -0700, Ali Çehreli wrote: > It looks pretty good to me. > > - All capital letters? Yuck! :) > > - Typo: DOLLERS > > - It's better to declare and define variables at the same time: > >int bet = inputInt( "\nWHAT IS YOUR BET"); int card1 = uniform(2, 15, >rnd)

Re: GitHub detects .d source as Makefile?

2017-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 18, 2017 00:34:57 XavierAP via Digitalmars-d-learn wrote: > So I have put my first code even on GitHub (comments welcome :)) > and GitHub seems to detect the wrong language, even if I'm not > familiar with this GH feature. > > https://github.com/XavierAP/etc/tree/master/heatsim >

Re: Get most D type from type

2017-03-17 Thread Nicholas Wilson via Digitalmars-d-learn
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 need to do, is also get the D types that these use. int is int, but So

GitHub detects .d source as Makefile?

2017-03-17 Thread XavierAP via Digitalmars-d-learn
So I have put my first code even on GitHub (comments welcome :)) and GitHub seems to detect the wrong language, even if I'm not familiar with this GH feature. https://github.com/XavierAP/etc/tree/master/heatsim The repository itself ("etc") is flagged as been written in Makefile? Right now I

Re: first try

2017-03-17 Thread XavierAP via Digitalmars-d-learn
On Friday, 17 March 2017 at 00:35:32 UTC, Philip Miess wrote: https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/ aceyducy.d You don't need string literals to be verbatim (r"") in order to insert newlines as in the code (without escape sequences). All string literals behave thi

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 term. I actually thin

Re: bug in foreach continue

2017-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: 1) Template expansion / AST manipulation, and: 2) CTFE (compile-time function evaluation). Not clearly understanding the distinction between the two often leads to confusion and frustration at why the compiler isn't doing "what

Re: Using packages: undefined reference to main

2017-03-17 Thread cloutiy via Digitalmars-d-learn
On Friday, 17 March 2017 at 16:16:00 UTC, bachmeier wrote: On Thursday, 16 March 2017 at 17:55:13 UTC, cloutiy wrote: I'd like to try making a simple web app using vibrant.d, however I don't think I'm using it correctly since I'm getting a linking error when compiling. Below is my SDL with ad

Re: List Comprehension equivalent

2017-03-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 17, 2017 at 07:21:50PM +, John Colvin via Digitalmars-d-learn wrote: [...] > reduce is a free function in std.algorithm. Just import it and you're > away. [...] Also, there is now a variant of reduce called `fold`, that has a nicer order of parameters, i.e., you can use it in UFCS

Re: List Comprehension equivalent

2017-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2017 12:21 PM, John Colvin wrote: > On Friday, 17 March 2017 at 19:08:36 UTC, Russel Winder wrote: >> Rust ownership problems >> seem to be a doddle compared to this problem. It sometimes feels like that but we don't want to lose you. :) > reduce is a free function in std.algorithm. Ju

Re: List Comprehension equivalent

2017-03-17 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-03-17 at 19:21 +, John Colvin via Digitalmars-d-learn wrote: > […] > > reduce is a free function in std.algorithm. Just import it and  > you're away. Anyway, is this what you wanted? > > string[] blah(string[][string] groups) > { >  import std.algorithm : map, joiner; >  

Re: List Comprehension equivalent

2017-03-17 Thread John Colvin via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:08:36 UTC, Russel Winder wrote: On Fri, 2017-03-17 at 17:51 +, Jerry via Digitalmars-d-learn wrote: On Friday, 17 March 2017 at 17:13:48 UTC, Russel Winder wrote: > I have a bit of code: > > string[] returnValue; >foreach(string key, string[] value; grou

Re: bug in foreach continue

2017-03-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 17, 2017 at 03:14:08PM +, Hussien via Digitalmars-d-learn wrote: [...] > What I am talking about is > > how the statement > > static if (x) continue; > pragma(msg, "called"); > > vs > > static if (x) { } else > pragma(msg, "not called"); > > > They are both semantically equiva

Re: List Comprehension equivalent

2017-03-17 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-03-17 at 17:51 +, Jerry via Digitalmars-d-learn wrote: > On Friday, 17 March 2017 at 17:13:48 UTC, Russel Winder wrote: > > I have a bit of code: > > > > string[] returnValue; > > foreach(string key, string[] value; groups) { > > returnValue ~=  > > value.sort!

Re: List Comprehension equivalent

2017-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2017 10:51 AM, Jerry wrote: On Friday, 17 March 2017 at 17:13:48 UTC, Russel Winder wrote: I have a bit of code: string[] returnValue; foreach(string key, string[] value; groups) { returnValue ~= value.sort!debianPackageNumberComparator()[0..$-1].array; } return

Re: List Comprehension equivalent

2017-03-17 Thread Jerry via Digitalmars-d-learn
On Friday, 17 March 2017 at 17:13:48 UTC, Russel Winder wrote: I have a bit of code: string[] returnValue; foreach(string key, string[] value; groups) { returnValue ~= value.sort!debianPackageNumberComparator()[0..$-1].array; } return returnValue; [...] You

List Comprehension equivalent

2017-03-17 Thread Russel Winder via Digitalmars-d-learn
I have a bit of code: string[] returnValue; foreach(string key, string[] value; groups) { returnValue ~= value.sort!debianPackageNumberComparator()[0..$-1].array; } return returnValue; which does seem to do the thing required, but this sort of code

Re: bug in foreach continue

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 15:14:08 UTC, Hussien wrote: What I am talking about is If you want to add a new feature, `static foreach`, that has static continue and static break, I can get behind that, but that's a new feature, not a bug in the existing feature. You think it is something it

Re: Using packages: undefined reference to main

2017-03-17 Thread bachmeier via Digitalmars-d-learn
On Thursday, 16 March 2017 at 17:55:13 UTC, cloutiy wrote: I'd like to try making a simple web app using vibrant.d, however I don't think I'm using it correctly since I'm getting a linking error when compiling. Below is my SDL with added vibrant.d dependency: name "cvmaker" description "A sim

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 Adam D. Ruppe via Digitalmars-d-learn
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 with the loop that it exists in. It did. It broke the loop coun

Re: bug in foreach continue

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 13:10:23 UTC, Jonathan M Davis wrote: it looks like break and continue _are_ used at compile time, since it prints They are working exactly the same way as any other loop. The fact that it is unrolled and the dead code removed from the binary is an implementation d

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: > > I tend

Re: bug in foreach continue

2017-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
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: > > > > I tend to agree with this. If the foreach is static, and > > contin

Re: bug in foreach continue

2017-03-17 Thread Michael via Digitalmars-d-learn
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: I tend to agree with this. If the foreach is static, and continue and break are just going to be ignored, then they should just be illegal. Allowing them

Re: bug in foreach continue

2017-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 17, 2017 01:55:19 Hussien via Digitalmars-d-learn wrote: > 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 wh

Re: first try

2017-03-17 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 17 March 2017 at 09:04:18 UTC, Andrea Fontana wrote: On Friday, 17 March 2017 at 00:35:32 UTC, Philip Miess wrote: This is my first 100+ line D program. https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/ aceyducy.d Its a translation/refactor of aceyducy from 101 basic p

Re: first try

2017-03-17 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 17 March 2017 at 00:35:32 UTC, Philip Miess wrote: This is my first 100+ line D program. https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/ aceyducy.d Its a translation/refactor of aceyducy from 101 basic programs. Could someone look over it and see if I've made any glar

Re: What is PostgreSQL driver is most stable?

2017-03-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-15 15:08, Suliman wrote: Could you give an example when it's better to use DBRow and where to get data in structure? Use PGCommand and call "executeQuery" to get back a result set that is iteratable: auto query = "SELECT * FROM foos" auto cmd = new PGCommand(connection, query); a