Re: method has no return statement with switch

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:30:29 UTC, crimaniak wrote: On Saturday, 7 November 2015 at 00:27:02 UTC, Adam D. Ruppe wrote: On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Inserting dummy return statement doesn't help. final switch / switch with default - no matter. Try

Re: opCmp with structs

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 22:55:15 UTC, Alex wrote: Ok... the question is not silly any more... without 'immutable' it works. So, what am I missing? sorry, again a forum bug that stripped my answer: sort() fails because in the template constraint `hasAssignableElements` fails.

method has no return statement with switch

2015-11-06 Thread crimaniak via Digitalmars-d-learn
Hi! I have the error message: source/url.cache.d(20,16): Error: function url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string Inserting dummy return statement doesn't help. final switch / switch with default - no matter. As I understand

Re: opCmp with structs

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 22:55:15 UTC, Alex wrote: Ok... the question is not silly any more... without 'immutable' it works. So, what am I missing? sort() fails because in the template constraint `hasAssignableElements

Re: method has no return statement with switch

2015-11-06 Thread crimaniak via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:27:02 UTC, Adam D. Ruppe wrote: On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Inserting dummy return statement doesn't help. final switch / switch with default - no matter. Try inserting assert(0); instead of a dummy return. Done, no

Re: Operator implicit conversion difference

2015-11-06 Thread Ali Çehreli via Digitalmars-d-learn
On 11/06/2015 04:56 PM, BBaz wrote: On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max,

Re: method has no return statement with switch

2015-11-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Inserting dummy return statement doesn't help. final switch / switch with default - no matter. Try inserting assert(0); instead of a dummy return.

Re: opCmp with structs

2015-11-06 Thread Ali Çehreli via Digitalmars-d-learn
On 11/06/2015 02:54 PM, Alex wrote: > I'm sure I'm doing a silly mistake somewhere, but why this doesn't work? > import std.stdio; > import std.algorithm; > > struct ku > { > immutable int id; > alias id this; > > this(int i) > { > id = i; > } > > int

opCmp with structs

2015-11-06 Thread Alex via Digitalmars-d-learn
I'm sure I'm doing a silly mistake somewhere, but why this doesn't work? import std.stdio; import std.algorithm; struct ku { immutable int id; alias id this; this(int i) { id = i; } int opCmp(ref const ku rhs)

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max, b = ushort.max; a += b; //

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 01:10:01 UTC, Ali Çehreli wrote: On 11/06/2015 04:56 PM, BBaz wrote: On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: [...] What's inconsistent is the integral promotion of the add expression result that stops from 4 bytes int: --- int a, b; a +=

Re: opCmp with structs

2015-11-06 Thread Alex via Digitalmars-d-learn
Ok... the question is not silly any more... without 'immutable' it works. So, what am I missing?

Re: question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
On Saturday, 7 November 2015 at 04:25:00 UTC, Mike Parker wrote: Missed this in my previous reply. No problem. I appreciate you taking the time to help me either way :)

Re: question about using std.bitmanip.read

2015-11-06 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For

Re: question about using std.bitmanip.read

2015-11-06 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: I went to std.bitmanip to look for unittests using the Endian, and the only one that does uses read!(T, endianness), which needs endianness to be known at compile time, which I don't have. Missed this in my previous reply.

Re: Align a variable on the stack.

2015-11-06 Thread steven kladitis via Digitalmars-d-learn
On Friday, 6 November 2015 at 01:17:20 UTC, TheFlyingFiddle wrote: On Friday, 6 November 2015 at 00:43:49 UTC, rsw0x wrote: On Thursday, 5 November 2015 at 23:37:45 UTC, TheFlyingFiddle wrote: On Thursday, 5 November 2015 at 21:24:03 UTC, TheFlyingFiddle wrote: [...] I reduced it further:

Re: question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:53:14 UTC, Nicholas Wilson wrote: On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to

Re: method has no return statement with switch

2015-11-06 Thread tcak via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Hi! I have the error message: source/url.cache.d(20,16): Error: function url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string [...] Because the "switch" is marked as "final",

Re: method has no return statement with switch

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: [...] url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string [...] public string doRealRequest(string url, Method method) You posted the wrong code sample: your code shows

Re: Align a variable on the stack.

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:18:59 UTC, steven kladitis wrote: [...] I am still disappointed that DMD is not native 64 bit in windows yet. [...] It's because they can't make a nice distribution. DMD win32 is a nice package that works out of the box (compiler, standard C lib, standard

question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For basic testing I'm just trying to use:

Re: struct constructor co nfusion

2015-11-06 Thread anonymous via Digitalmars-d-learn
On 06.11.2015 20:05, Spacen Jasset wrote: Also, I had to add a dummy private constructor to make my structs 'createable', or is there another way? e.g. struct Texture { @disable this(); static Texture create() { return Texture(0); } ... private: this(int) {

Re: question about using std.bitmanip.read

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For

Re: question about using std.bitmanip.read

2015-11-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For

Re: conver BigInt to string

2015-11-06 Thread Namal via Digitalmars-d-learn
On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote: Namal: Hello I am trying to convert BigInt to string like that while trying to sort it: void main() { import std.stdio, std.algorithm, std.conv, std.bigint, std.string; auto n = 17.BigInt ^^ 179;

Maybe a dmd bug, what do you think ?

2015-11-06 Thread user123456789abcABC via Digitalmars-d-learn
Template parameter deduction in partially specialized template fails: --- enum Bar{b,a,r} void foo(Bar bar, T)(T t){} alias foob(T) = foo!(Bar.b, T); void main() { foo!(Bar.b)(8); foob(8); // autsch } --- It looks like a bug, doesn't it ?

Re: Maybe a dmd bug, what do you think ?

2015-11-06 Thread rsw0x via Digitalmars-d-learn
On Friday, 6 November 2015 at 08:48:38 UTC, user123456789abcABC wrote: Template parameter deduction in partially specialized template fails: --- enum Bar{b,a,r} void foo(Bar bar, T)(T t){} alias foob(T) = foo!(Bar.b, T); void main() { foo!(Bar.b)(8); foob(8); // autsch } --- It looks

Re: Align a variable on the stack.

2015-11-06 Thread TheFlyingFiddle via Digitalmars-d-learn
On Friday, 6 November 2015 at 11:38:29 UTC, Marc Schütz wrote: On Friday, 6 November 2015 at 11:37:22 UTC, Marc Schütz wrote: Ok, benchA and benchB have the same assembler code generated. However, I _can_ reproduce the slowdown albeit on average only 20%-40%, not a factor of 10. Forgot to

Re: Unittest in a library

2015-11-06 Thread Charles via Digitalmars-d-learn
On Friday, 6 November 2015 at 04:34:28 UTC, TheFlyingFiddle wrote: On Friday, 6 November 2015 at 03:59:07 UTC, Charles wrote: Is it possible to have unittest blocks if I'm compiling a library? I've tried having this: test.d: class Classy { unittest { assert(0, "failed test"); }

Re: struct constructor co nfusion

2015-11-06 Thread Spacen Jasset via Digitalmars-d-learn
On Friday, 6 November 2015 at 17:50:17 UTC, Atila Neves wrote: On Friday, 6 November 2015 at 17:34:29 UTC, Spacen Jasset wrote: Hello, I have read various things about struct constructors, specifically 0 argument constructors, and using opCall and @disable this(); which no longer seems to

std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread HeiHon via Digitalmars-d-learn
Consider this: [code] import std.stdio, std.utf, std.exception; void do_decode(string txt) { try { size_t idx; writeln("decode ", txt); for (size_t i = 0; i < txt.length; i++) { dchar dc = std.utf.decode(txt[i..i+1], idx);

Re: Working Windows GUI library - no console Window

2015-11-06 Thread Spacen Jasset via Digitalmars-d-learn
On Friday, 6 November 2015 at 15:52:10 UTC, johann wrote: hi, i like to use a window gui library and i think i found a working one. https://github.com/FrankLIKE/dfl2 - works with x64 the problem is, that with DMD 2.069.0, VS2015 and visualD the trick of using "-L/SUBSYSTEM:windows,6.00

Re: Associative array with duplicated keys?

2015-11-06 Thread cym13 via Digitalmars-d-learn
On Thursday, 5 November 2015 at 13:08:20 UTC, Adam D. Ruppe wrote: On Thursday, 5 November 2015 at 10:04:02 UTC, Andrea Fontana wrote: Anyway: are duplicated keys on declaration allowed? They shouldn't be... Why? I'll admit it is something I've never even thought of using, but every

Re: Associative array with duplicated keys?

2015-11-06 Thread cym13 via Digitalmars-d-learn
On Friday, 6 November 2015 at 14:28:53 UTC, cym13 wrote: auto aa = ["a":10, "b", 42, "a":20]; This should readauto aa = ["a":10, "b":42, "a":20]; of course.

Working Windows GUI library - no console Window

2015-11-06 Thread johann via Digitalmars-d-learn
hi, i like to use a window gui library and i think i found a working one. https://github.com/FrankLIKE/dfl2 - works with x64 the problem is, that with DMD 2.069.0, VS2015 and visualD the trick of using "-L/SUBSYSTEM:windows,6.00 -L/ENTRY:mainCRTStartup" does not suppress the console window

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Suliman via Digitalmars-d-learn
On Friday, 6 November 2015 at 13:50:56 UTC, Kagamin wrote: MSVCR is a C runtime. On Linux it will depend on a C runtime too. But which part of my App depend on C runtime?

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Benjamin Thaut via Digitalmars-d-learn
On Friday, 6 November 2015 at 16:21:35 UTC, Suliman wrote: On Friday, 6 November 2015 at 13:50:56 UTC, Kagamin wrote: MSVCR is a C runtime. On Linux it will depend on a C runtime too. But which part of my App depend on C runtime? All of it. Phobos and druntime use the C runtime, that means

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Timo Sintonen via Digitalmars-d-learn
On Friday, 6 November 2015 at 16:21:35 UTC, Suliman wrote: On Friday, 6 November 2015 at 13:50:56 UTC, Kagamin wrote: MSVCR is a C runtime. On Linux it will depend on a C runtime too. But which part of my App depend on C runtime? I have an early draft to explain the libraries here:

Why my app require MSVCR120.dll?

2015-11-06 Thread Suliman via Digitalmars-d-learn
I wrote Application in D. That use next components: "colorize": ">=1.0.5", "ddbc": ">=0.2.11", "vibe-d": "~>0.7.26" On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll And I can't understand what component is pulling this lib as dependence.

struct constructor co nfusion

2015-11-06 Thread Spacen Jasset via Digitalmars-d-learn
Hello, I have read various things about struct constructors, specifically 0 argument constructors, and using opCall and @disable this(); which no longer seems to work. What I am after I think is the behavior of C++'s structs on the stack, namely for some or all of these uses at a given

Re: Align a variable on the stack.

2015-11-06 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 6 November 2015 at 11:37:22 UTC, Marc Schütz wrote: Ok, benchA and benchB have the same assembler code generated. However, I _can_ reproduce the slowdown albeit on average only 20%-40%, not a factor of 10. Forgot to add that this is on Linux x86_64, so that probably explains the

Re: Align a variable on the stack.

2015-11-06 Thread Marc Schütz via Digitalmars-d-learn
Ok, benchA and benchB have the same assembler code generated. However, I _can_ reproduce the slowdown albeit on average only 20%-40%, not a factor of 10. It turns out that it's always the first tested function that's slower. You can test this by switching benchA and benchB in the call to

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Kagamin via Digitalmars-d-learn
MSVCR is a C runtime. On Linux it will depend on a C runtime too.

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread ponce via Digitalmars-d-learn
On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: I wrote Application in D. That use next components: "colorize": ">=1.0.5", "ddbc": ">=0.2.11", "vibe-d": "~>0.7.26" On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll And I can't

Re: Align a variable on the stack.

2015-11-06 Thread arGus via Digitalmars-d-learn
I did some testing on Linux and Windows. I ran the code with ten times the iterations, and found the results consistent with what has previously been observed in this thread. The code seems to run just fine on Linux, but is slowed down 10x on Windows x86. Windows (32-bit) rdmd bug.d

Re: struct constructor co nfusion

2015-11-06 Thread Atila Neves via Digitalmars-d-learn
On Friday, 6 November 2015 at 17:34:29 UTC, Spacen Jasset wrote: Hello, I have read various things about struct constructors, specifically 0 argument constructors, and using opCall and @disable this(); which no longer seems to work. What I am after I think is the behavior of C++'s structs

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Cauterite via Digitalmars-d-learn
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 good chance you can link against a different C runtime DLL —

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote: Am I using std.utf.decode wrongly or is it buggy? It's obviously used wrongly, try this instead: import std.utf, std.stdio; --- dstring do_decode(string txt) { dstring result; try { size_t idx;

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread HeiHon via Digitalmars-d-learn
Sorry, I mixed up the line numbers from dmd 2.068.2 and dmd 2.069.0. The correct line numbers for dmd 2.069.0 are: Attempted to decode past the end of a string (at index 1) file=D:\dmd2\windows\bin\..\..\src\phobos\std\utf.d line=1281 and core.exception.RangeError@std\utf.d(1278): Range

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread Spacen Jasset via Digitalmars-d-learn
On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote: Consider this: [code] import std.stdio, std.utf, std.exception; void do_decode(string txt) { try { size_t idx; writeln("decode ", txt); for (size_t i = 0; i < txt.length; i++) { dchar

Re: std.utf.decode behaves unexpectedly - Bug?

2015-11-06 Thread BBaz via Digitalmars-d-learn
Sorry, the forum as stripped my answer. Here is the full version: On Friday, 6 November 2015 at 19:26:50 UTC, HeiHon wrote: Am I using std.utf.decode wrongly or is it buggy? It's obviously used wrongly, try this instead: import std.utf, std.stdio; --- dstring do_decode(string txt) {

Re: conver BigInt to string

2015-11-06 Thread cym13 via Digitalmars-d-learn
On Friday, 6 November 2015 at 10:00:23 UTC, Namal wrote: On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote: Namal: Hello I am trying to convert BigInt to string like that while trying to sort it: void main() { import std.stdio, std.algorithm, std.conv, std.bigint,

Re: Working Windows GUI library - no console Window

2015-11-06 Thread John Chapman via Digitalmars-d-learn
On Friday, 6 November 2015 at 15:52:10 UTC, johann wrote: hi, i like to use a window gui library and i think i found a working one. https://github.com/FrankLIKE/dfl2 - works with x64 the problem is, that with DMD 2.069.0, VS2015 and visualD the trick of using "-L/SUBSYSTEM:windows,6.00

Re: Align a variable on the stack.

2015-11-06 Thread rsw0x via Digitalmars-d-learn
On Friday, 6 November 2015 at 17:55:47 UTC, arGus wrote: I did some testing on Linux and Windows. I ran the code with ten times the iterations, and found the results consistent with what has previously been observed in this thread. The code seems to run just fine on Linux, but is slowed down

Re: Working Windows GUI library - no console Window

2015-11-06 Thread johann via Digitalmars-d-learn
On Friday, 6 November 2015 at 21:02:59 UTC, John Chapman wrote: On Friday, 6 November 2015 at 15:52:10 UTC, johann wrote: hi, i like to use a window gui library and i think i found a working one. https://github.com/FrankLIKE/dfl2 - works with x64 the problem is, that with DMD 2.069.0,