Re: Why no offsetof for static struct?

2017-07-11 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2017 11:14 PM, FoxyBrown wrote: auto GetStaticAddress(T)() { mixin("auto p = cast(T*)&T."~__traits(allMembers, T)[0]~";"); return p; } Returns the address of a struct's static members. No, it returns the address of T's first member. It's pretty obvious, the compiler seems

Static array with parameter based size?

2017-07-11 Thread Miguel L via Digitalmars-d-learn
I need to create a non-dynamic array like this void f(int x) { int[x] my_array; ... this does not compile as x value needs to be known at compile time. The closest to this I can get is: void f(int x) { int[] my_array; my_array.length=x; but I don't really need a dynamic array as length is no

Re: Static array with parameter based size?

2017-07-11 Thread ketmar via Digitalmars-d-learn
Miguel L wrote: I need to create a non-dynamic array like this void f(int x) { int[x] my_array; ... this does not compile as x value needs to be known at compile time. The closest to this I can get is: void f(int x) { int[] my_array; my_array.length=x; but I don't really need a dynamic arr

Re: Static array with parameter based size?

2017-07-11 Thread Dgame via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 08:23:02 UTC, Miguel L wrote: I need to create a non-dynamic array like this void f(int x) { int[x] my_array; ... this does not compile as x value needs to be known at compile time. The closest to this I can get is: void f(int x) { int[] my_array; my_array.length=

How to add authentificaion method to request?

2017-07-11 Thread Suliman via Digitalmars-d-learn
I am using dlang-requests. I need authentificate on https://scihub.copernicus.eu/dhus/login and than do some data-parsing. MultipartForm form; form.add(formData("login_username", "Suliman")); form.add(formData("login_password", "123")); // changed auto content = postContent("ht

Re: How to add authentificaion method to request?

2017-07-11 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 12:15:39 UTC, Suliman wrote: I am using dlang-requests. I need authentificate on https://scihub.copernicus.eu/dhus/login and than do some data-parsing. MultipartForm form; form.add(formData("login_username", "Suliman")); form.add(formData("login_password

dmd, vibe.d RAM usage when compiling.

2017-07-11 Thread SrMordred via Digitalmars-d-learn
I never notice this before, but i tried to put a basic hello world from vibe.d (like the one that are in the dlang front page examples now), into the most basic instance on google cloud (with 600mb of RAM) and the compilation returned "Killed dmd failed with exit code 137." So I look at the RA

Re: dmd, vibe.d RAM usage when compiling.

2017-07-11 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 16:04:52 UTC, SrMordred wrote: I never notice this before, but i tried to put a basic hello world from vibe.d (like the one that are in the dlang front page examples now), into the most basic instance on google cloud (with 600mb of RAM) and the compilation returned

Re: dmd, vibe.d RAM usage when compiling.

2017-07-11 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 16:04:52 UTC, SrMordred wrote: I never notice this before, but i tried to put a basic hello world from vibe.d (like the one that are in the dlang front page examples now), into the most basic instance on google cloud (with 600mb of RAM) and the compilation returned

Re: Cannot dup an associative array but why?

2017-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/10/2017 04:24 PM, Jean-Louis Leroy wrote: > FYI, having a lot of fun. See > https://github.com/jll63/meth.d/blob/experiments/source/meth/examples/adventure.d I'm glad you're trying out multi-methods with D: https://github.com/jll63/meth.d/tree/experiments That's some serious code you

Re: pure factory function vs immutable(Foo)**

2017-07-11 Thread ag0aep6g via Digitalmars-d-learn
On 07/10/2017 04:57 PM, ag0aep6g wrote: alias T = int; T** f(const T** input) pure { T** output; return output; } void main() { T i; T* p = &i; immutable T** r = f(&p); } [...] Now change `T` to `alias T = immutable int;`. The program gets rejected. The erro

Re: How to add authentificaion method to request?

2017-07-11 Thread ikod via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 12:15:39 UTC, Suliman wrote: I am using dlang-requests. I need authentificate on https://scihub.copernicus.eu/dhus/login and than do some data-parsing. MultipartForm form; form.add(formData("login_username", "Suliman")); form.add(formData("login_password

Re: pure factory function vs immutable(Foo)**

2017-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/17 2:12 PM, ag0aep6g wrote: On 07/10/2017 04:57 PM, ag0aep6g wrote: alias T = int; T** f(const T** input) pure { T** output; return output; } void main() { T i; T* p = &i; immutable T** r = f(&p); } [...] Now change `T` to `alias T = immutable int;`.

Re: Cannot dup an associative array but why?

2017-07-11 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 17:20:33 UTC, Ali Çehreli wrote: That's some serious code you've written there and you must be happy that 'virtual' is not a keyword in D. ;) Thanks. Haha I would have used virtual_ like I did in C++ ;-) Maybe others can come up with ideas on a better syntax. Wh

Re: Cannot dup an associative array but why?

2017-07-11 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 17:20:33 UTC, Ali Çehreli wrote: @Virtual("t", "d", "w") string fight(Character t, Dragon d, Hands w) { return "you just killed a dragon with your bare hands. Incredible isn't it?"; [...] mixin ProcessMethods(); Great suggestion! I think this could work: st

Re: Cannot dup an associative array but why?

2017-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2017 01:25 PM, Jean-Louis Leroy wrote: > On Tuesday, 11 July 2017 at 17:20:33 UTC, Ali Çehreli wrote: > >> @Virtual("t", "d", "w") >> string fight(Character t, Dragon d, Hands w) { >> return "you just killed a dragon with your bare hands. Incredible >> isn't it?"; >> [...] >> mixin Pr

Re: mysql-native ResultRange + map

2017-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/5/17 12:04 PM, crimaniak wrote: Hi all! After some hard time with debugging, I found ResultRange returned by query() and Prepared::query() of mysql-native package can't be combined with map() because after map() it becomes empty resultset. [snip] As you see simple each() and foreach()

Re: Foreign threads in D code.

2017-07-11 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 06:18:44 UTC, Biotronic wrote: On Monday, 10 July 2017 at 20:03:32 UTC, Igor Shirkalin wrote: [...] If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC, and the GC might collect memory that the thread is referencing on

'typeof' not printing template arguments.

2017-07-11 Thread Deech via Digitalmars-d-learn
Hi all, I've been learning D for a few weeks by reading through Programming In D [1] and had a question about Eponymous Template section [2]. Here's the example: ``` template LargerOf(A, B) { static if (A.sizeof < B.sizeof) { alias LargerOf = B; } else { alias LargerOf = A; } }

Re: 'typeof' not printing template arguments.

2017-07-11 Thread Deech via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 00:44:38 UTC, Deech wrote: Hi all, I've been learning D for a few weeks by reading through Programming In D [1] and had a question about Eponymous Template section [2]. Here's the example: ``` template LargerOf(A, B) { static if (A.sizeof < B.sizeof) { alia

Why do array literals default to object.Object[]?

2017-07-11 Thread Brandon Buck via Digitalmars-d-learn
I apologize if this has been touched on before, I'm not quite sure what to search for and what I did try didn't bring anything up. Okay, so I'm learning D, using the D Tour flow and I went over interfaces. Everything is making sense. I key in the example (as I like to copy it by hand and then

Re: Why do array literals default to object.Object[]?

2017-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/17 9:27 PM, Brandon Buck wrote: I apologize if this has been touched on before, I'm not quite sure what to search for and what I did try didn't bring anything up. Okay, so I'm learning D, using the D Tour flow and I went over interfaces. Everything is making sense. I key in the example

Re: mysql-native ResultRange + map

2017-07-11 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 22:46:00 UTC, Steven Schveighoffer wrote: On 7/5/17 12:04 PM, crimaniak wrote: ... Because of the temporary copy likely inside map closes the connection. See the bug I reported: https://github.com/mysql-d/mysql-native/issues/117 Yes, it seems to be the same issue

Re: Why do array literals default to object.Object[]?

2017-07-11 Thread Brandon Buck via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 02:06:41 UTC, Steven Schveighoffer wrote: I do agree it's not intuitive for an initializer, especially when: auto a = [1, 2, 3]; // typeof(a) == int[] short[] b = [1, 2, 3]; // works Thank you for getting back to me, that's where my train of thought was going. W

Re: Static array with parameter based size?

2017-07-11 Thread Miguel L via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 05:45:13 UTC, Miguel L wrote: Hi I need to create a non-dynamic array like this void f(int x) { int[x] my_array; ... this does not compile as x value needs to be known at compile time. The closest to this I can get is: void f(int x) { int[] my_array; my_array.l

Static array with parameter based size?

2017-07-11 Thread Miguel L via Digitalmars-d-learn
Hi I need to create a non-dynamic array like this void f(int x) { int[x] my_array; ... this does not compile as x value needs to be known at compile time. The closest to this I can get is: void f(int x) { int[] my_array; my_array.length=x; but I don't really need a dynamic array as length i