Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn
On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote: On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll D doesn't make particularly heavy use of the C runtime, so there's a

Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 09:54:43 UTC, Suliman wrote: On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote: On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll D

Re: Printing a floats in maximum precision

2017-01-18 Thread kinke via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:36:39 UTC, Nicholas Wilson wrote: Alternatively use %a to print in hex to verify exact bit patterns. +1, if it doesn't have to be human-readable.

Re: iterating through members of bitfields

2017-01-18 Thread Nestor via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 01:15:05 UTC, Ali Çehreli wrote: Not available but it should be possible to parse the produced code: import std.bitmanip; string makeBitFieldPrinter(string fieldImpl) { return q{ void printBitFields() const { import std.stdio: writeln;

Re: iterating through members of bitfields

2017-01-18 Thread drug via Digitalmars-d-learn
I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works.

Re: Where is floating point next{Up,Down}?

2017-01-18 Thread pineapple via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 23:41:27 UTC, Nordlöw wrote: On Tuesday, 17 January 2017 at 23:38:46 UTC, Ali Çehreli wrote: Found'em! :) https://dlang.org/phobos/std_math.html#.nextUp Thanks! (Shouts into the soundless void)

Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
Is it undefined behavior to assign to a pointer in the constructor of a struct?

Re: Returning Arrays from Functions

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:51:17 UTC, Samwise wrote: numbs[] = getInp(help, file, inp, args); This is wrong, try just `numbs = getImp(...);` numbs[] = xxx will copy stuff into the existing array, which is empty right now. You want to jut keep the slice the function passes

__traits(isRef, this) cannot distinguish l-value- from r-value-passed this

2017-01-18 Thread Nordlöw via Digitalmars-d-learn
A compilation of struct T { int x; @disable this(this); // this has no effect on the issue ref inout(T) memberFun() inout { pragma(msg, "memberFun:", __traits(isRef, this) ? "ref" : "non-ref", " this"); return this; } } void freeFun()(auto ref const T x)

Re: switch statement with variable branches

2017-01-18 Thread Ali Çehreli via Digitalmars-d-learn
On 01/18/2017 05:22 PM, Yuxuan Shui wrote: Somehow I can't use ubyte variables behind 'case', but ulong works fine. Why is that? void main() { alias TestType = ulong; // won't compile if = ubyte import std.stdio; TestType a,b,c; readf("%s %s %s ", , , ); switch(c){

Re: Intelligent enums

2017-01-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 19 January 2017 at 03:47:34 UTC, Ignacious wrote: On Thursday, 19 January 2017 at 02:59:04 UTC, Ignacious wrote: I have the need to create an enum flag like structure to specify certain properties of a type easily. e.g., enum properties { Red, Blue, Hot, Sexy,

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:12:15 UTC, Mike Parker wrote: (source files), then use the import statement to make the declarations in other modules. Sorry, this should read "make the implementations available to other modules".

Re: Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:08:07 UTC, Adam D. Ruppe wrote: On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote: Is it undefined behavior to assign to a pointer in the constructor of a struct? Yes: http://dlang.org/spec/struct.html "A struct is defined to not have an

alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn
class Y { int y; alias y this; } class X { Y[] x; alias x this; } Yet X ~= 3; fails. 3 should be implicitly convertible to Y and then ~ should assign it. ?

cannot alias array ;/

2017-01-18 Thread Jot via Digitalmars-d-learn
alias a = myarray[k]; fails myarray is a multidimensial array that I want to reduce writing it every time but D complains that it can't alias it. I simply want it to do a direct substitution, nothing fancy, just to reducing typing.

Function template advice

2017-01-18 Thread Jordan Wilson via Digitalmars-d-learn
I have a simple comparison function: struct Foo { string bar; } auto sameGroup(T,S) (T a, S b) { static assert (is(T == string) || is(T == Foo)); static assert (is(S == string) || is(S == Foo)); string aStr; string bStr; static if (is(T == string)){ aStr = a;

Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
I've done a whole bunch of looking around, and I don't see any mention of returning a dynamic array from a function. When I try it though, it just returns the .length value of the array, rather than the contents of the array. Does anyone know why this is, and what I can do to make it behave

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 19:28:20 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: extern(C), not simply extern. It turns off the name mangling. But really, the proper thing to do is to drop the prototype and import the module with the

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn
Thanks loads. I got it working using those modules. ~Sam

Re: __traits(isRef, this) cannot distinguish l-value- from r-value-passed this

2017-01-18 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 19 January 2017 at 00:44:51 UTC, Nordlöw wrote: Any clues on how to retrieve this information? Another much more common use case: Chained property setters could be optimized iff the property setter is called on an r-value, that is when `__traits(isRef,this)` is `false`

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } Yet X ~= 3; fails. 3 should be implicitly convertible to Y and then ~ should assign it. ? This should not fail: X x = new X; x ~= 3; This should fail as x is a member

Re: Function template advice

2017-01-18 Thread Ali Çehreli via Digitalmars-d-learn
On 01/18/2017 02:02 PM, Jordan Wilson wrote: I have a simple comparison function: struct Foo { string bar; } auto sameGroup(T,S) (T a, S b) { static assert (is(T == string) || is(T == Foo)); static assert (is(S == string) || is(S == Foo)); string aStr; string bStr;

Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:37:25 UTC, Adam D. Ruppe wrote: What code do you have now? This is the basic function. It takes all those boolean arguments and does things depending on them, and then takes any extra args that getopt didn't parse and reads them into numbs. That code

Re: Assigning in constructor.

2017-01-18 Thread pineapple via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:08:07 UTC, Adam D. Ruppe wrote: On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote: Is it undefined behavior to assign to a pointer in the constructor of a struct? Yes: http://dlang.org/spec/struct.html "A struct is defined to not have an

Re: switch statement with variable branches

2017-01-18 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:00:10 UTC, Ali Çehreli wrote: On 01/18/2017 05:22 PM, Yuxuan Shui wrote: Somehow I can't use ubyte variables behind 'case', but ulong works fine. Why is that? case expressions must be constants: "The case expressions must all evaluate to a constant

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:25 PM, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } This should not fail: X x = new X; x ~= 3; Yes, it

Re: alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } This should not fail: X x = new

Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:09:15 UTC, Adam D. Ruppe wrote: On Wednesday, 18 January 2017 at 22:51:17 UTC, Samwise wrote: numbs[] = getInp(help, file, inp, args); This is wrong, try just `numbs = getImp(...);` numbs[] = xxx will copy stuff into the existing array, which is

Re: Assigning in constructor.

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 00:55:42 UTC, NotSpooky wrote: You already answered on the IRC so thanks X2. So, it's problematic to have pointers to structs in all cases according to spec? Maybe... though in practice (and with C compatibility), pointers to ones where you know the memory

Re: Returning Arrays from Functions

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
What code do you have now?

Re: Assigning in constructor.

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote: Is it undefined behavior to assign to a pointer in the constructor of a struct? Yes: http://dlang.org/spec/struct.html "A struct is defined to not have an identity; that is, the implementation is free to make bit copies of the

Re: Function template advice

2017-01-18 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:39:02 UTC, Ali Çehreli wrote: On 01/18/2017 02:02 PM, Jordan Wilson wrote: [...] Yes, can be better with something similar to the following: struct Foo { string bar; } string value(U : Foo)(U u) { return u.bar; } string value(U : string)(U u) {

switch statement with variable branches

2017-01-18 Thread Yuxuan Shui via Digitalmars-d-learn
Somehow I can't use ubyte variables behind 'case', but ulong works fine. Why is that? void main() { alias TestType = ulong; // won't compile if = ubyte import std.stdio; TestType a,b,c; readf("%s %s %s ", , , ); switch(c){ case a:

Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } This should not fail: X x = new X; x ~= 3; Yes, it should fail. 3 is not implicitly convertible to

Intelligent enums

2017-01-18 Thread Ignacious via Digitalmars-d-learn
I have the need to create an enum flag like structure to specify certain properties of a type easily. e.g., enum properties { Red, Blue, Hot, Sexy, Active, ... } But some properties will be mutually exclusive. I would like to contain all those rules for in the enum itself

Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:51:03 UTC, rikki cattermole wrote: Now, lets say Y was a struct, then yeah it can work. In theory, it can work with either (the compiler could just insert the function call to alloc+construct), but it won't in D since we don't have implicit construction.

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:35 PM, Ignacious wrote: On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x

Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:35:08 UTC, Ignacious wrote: But this is alias this, the whole point of alias this is to treat the type as as the alias? No, alias this is for subtyping. Similar to a child class, a subtype can be used as its parent type, but must be constructed. class A {}

Re: alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:51:03 UTC, rikki cattermole wrote: On 19/01/2017 3:35 PM, Ignacious wrote: On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote:

Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: extern(C), not simply extern. It turns off the name mangling. But really, the proper thing to do is to drop the prototype and import the module with the implementation. It's tge way modules are intended to be used. Unless

Problems with stored procedure using the mysql-native library.

2017-01-18 Thread TheFlyingFiddle via Digitalmars-d-learn
Hi I am having problems using stored procedures that return results. Example procedure: CREATE PROCEDURE GetUsers() SELECT * FROM users; When I use this procedure from the MySQL command line everything works fine. However, when I use it from the mysql-native library i get into problems.

Re: Problems with stored procedure using the mysql-native library.

2017-01-18 Thread TheFlyingFiddle via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 19:40:12 UTC, TheFlyingFiddle wrote: Hi I am having problems using stored procedures that return results. Update: I am using the SvrCapFlags.MULTI_RESULTS flag when initiating the connection and have also tried using the SvrCapFlags.MULTI_STATEMENTS flag.