Re: opDispatch with string mixin does not work as I would expect.

2018-02-10 Thread German Diago via Digitalmars-d-learn
On Saturday, 10 February 2018 at 07:47:58 UTC, Nicholas Wilson wrote: On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago Alternatively you could do something like auto opDispatch(string name)() if(hasMember!(HeaderData,name){ readHeader(); return mixin("head

Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just recovering from a bug which took me one day to discover because of this. I have a large static initialized array, let's say

Re: Fixed size array initialization

2018-02-10 Thread b2.temp--- via Digitalmars-d-learn
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just recovering from a bug which took me one day to discover because o

Re: Fixed size array initialization

2018-02-10 Thread Kagamin via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=481#c40

typedef behavior with @disable this()

2018-02-10 Thread Alex via Digitalmars-d-learn
Do I overlook something? /// --- code --- /// import std.typecons; void main(){} static assert(!__traits( compiles, E())); static assert(!__traits( compiles, MyE())); // line 6 struct E { size_t dummy; @disable this(); this(size_t val) { dummy = val; } } alias MyE = T

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Saturday, 10 February 2018 at 12:28:16 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just rec

Re: Fixed size array initialization

2018-02-10 Thread b2.temp--- via Digitalmars-d-learn
On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: On Saturday, 10 February 2018 at 12:28:16 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip decl

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Saturday, 10 February 2018 at 14:55:49 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: In this case, it there any way to be sure that I declared all the elements I intended? Obviously, without counting them by hand. At the level of the library use a templa

Re: Fixed size array initialization

2018-02-10 Thread Seb via Digitalmars-d-learn
On Saturday, 10 February 2018 at 15:54:03 UTC, rumbu wrote: On Saturday, 10 February 2018 at 14:55:49 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: In this case, it there any way to be sure that I declared all the elements I intended? Obviously, without count

Getting a reference to an immutable string

2018-02-10 Thread David Zhang via Digitalmars-d-learn
Hi, I've got an immutable string declared in module scope, and I attempted to get a pointer to its characters through both &str[0] and str.ptr. However, it appears to me that the string is behaving like a manifest constant, in that the pointer is null. The language reference indicates that i

Re: Getting a reference to an immutable string

2018-02-10 Thread ag0aep6g via Digitalmars-d-learn
On 02/10/2018 11:26 PM, David Zhang wrote: I've got an immutable string declared in module scope, and I attempted to get a pointer to its characters through both &str[0] and str.ptr. However, it appears to me that the string is behaving like a manifest constant, in that the pointer is null. T

Re: Getting a reference to an immutable string

2018-02-10 Thread David Zhang via Digitalmars-d-learn
On Saturday, 10 February 2018 at 22:36:41 UTC, ag0aep6g wrote: On 02/10/2018 11:26 PM, David Zhang wrote: I've got an immutable string declared in module scope, and I attempted to get a pointer to its characters through both &str[0] and str.ptr. However, it appears to me that the string is beh

Re: Getting a reference to an immutable string

2018-02-10 Thread David Zhang via Digitalmars-d-learn
Building with Visual Studio seems to be fine. This isn't an OptLink issue, is it?

Re: Getting a reference to an immutable string

2018-02-10 Thread ag0aep6g via Digitalmars-d-learn
On 02/10/2018 11:46 PM, David Zhang wrote: This is what I'm talking about: void createWindow( ... ) {     assert( wndclassName.ptr ); //This fails     HWND hwnd = CreateWindowW(     wndclassName.ptr, //This too     null,     0,     CW_USEDEFAULT, CW_USEDEFAULT,     C

Re: Getting a reference to an immutable string

2018-02-10 Thread David Zhang via Digitalmars-d-learn
On Saturday, 10 February 2018 at 22:59:18 UTC, ag0aep6g wrote: But there is a recent regression on Windows that might be related. Do you also have a static constructor (`static this`) that uses `wndclassName`? If so, you might be hitting issue 18412. https://issues.dlang.org/show_bug.cgi?id=1

Re: typedef behavior with @disable this()

2018-02-10 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 10 February 2018 at 13:18:28 UTC, Alex wrote: Do I overlook something? /// --- code --- /// import std.typecons; void main(){} static assert(!__traits( compiles, E())); static assert(!__traits( compiles, MyE())); // line 6 struct E { size_t dummy; @disable this()

Re: Fixed size array initialization

2018-02-10 Thread psychoticRabbit via Digitalmars-d-learn
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I have a large static initialized array, let's say int[155], and I forgot to declare the last element: int[155] myarray = [ a, b, c, ... //forgot to declare the 155th element ]; Well, in C.. I can do: int arr[2] = { [0]

Re: typedef behavior with @disable this()

2018-02-10 Thread Alex via Digitalmars-d-learn
On Sunday, 11 February 2018 at 00:54:07 UTC, Simen Kjærås wrote: Typedef explicitly initializes the wrapped value to T.init, thus circumventing the disabled default constructor. Filed a bug: https://issues.dlang.org/show_bug.cgi?id=18415 -- Simen Thanks!

Re: Fixed size array initialization

2018-02-10 Thread psychoticRabbit via Digitalmars-d-learn
On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit wrote: Well, in C.. I can do: int arr[2] = { [0]=10, [1]=20 }; I cannot work out how to do that in D yet (anyone know??) Oh. just worked it out after reading this thread ;-) int[2] arr = [ 0:10, 1:20 ];

Re: typedef behavior

2018-02-10 Thread Alex via Digitalmars-d-learn
On Saturday, 10 February 2018 at 02:55:26 UTC, Alex wrote: bug filed https://issues.dlang.org/show_bug.cgi?id=18416

Re: Linking multiple libraries

2018-02-10 Thread b2.temp--- via Digitalmars-d-learn
On Sunday, 26 November 2017 at 11:15:58 UTC, Jacob Carlborg wrote: On 2017-11-25 23:31, Mike Parker wrote: For "ld" on macOS the order does not matter. For "ld" on Linux the order does matter, but, if necessary, the following flags can be used to link libraries in any order: "--start-group" an

How can I get the new stdout which changes periodically from a process?

2018-02-10 Thread Marc via Digitalmars-d-learn
I do call a program from my application which changes its stdout perdiodically (with ncurses library, I guess), where I'd to get somehow "notified" when some change happen (I need to new data from that changes and change my application accordingly). Currently, I do use spawnProcess() which runs

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Sunday, 11 February 2018 at 01:26:59 UTC, psychoticRabbit wrote: On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit wrote: Well, in C.. I can do: int arr[2] = { [0]=10, [1]=20 }; I cannot work out how to do that in D yet (anyone know??) Oh. just worked it out after reading thi