Re: how to define my own traits

2017-03-26 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 26 March 2017 at 23:25:49 UTC, XavierAP wrote: I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r

Re: Loading assimp

2017-03-26 Thread Dlearner via Digitalmars-d-learn
I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access violation. As far as I can tell, it seems to be an issue with `aiGetMaterialTexture`. It is meant to return an aiString with

Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn
On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote: On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote: You can ignore the loop()-method. It is not called as the application will never reach this statement, because it cannot, because it crashes already in the

Re: Loading assimp

2017-03-26 Thread ag0aep6g via Digitalmars-d-learn
On 03/26/2017 11:31 PM, Dlearner wrote: SDL_Surface* surface = IMG_Load(filename.ptr); if (surface is null) { writeln("surface is null: ", to!string(IMG_GetError())); } else { writeln(filename); } From console: surface is null: Couldn't open

Re: really why module declarations?

2017-03-26 Thread XavierAP via Digitalmars-d-learn
On Sunday, 26 March 2017 at 20:58:24 UTC, Adam D. Ruppe wrote: Module declarations are only optional in the most trivial case that is rarely useful in real world code. I recommend you ALWAYS use them (and always put a ddoc comment on them!), and moreover that you avoid top name modules (use

Re: really why module declarations?

2017-03-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 26, 2017 20:51:01 XavierAP via Digitalmars-d-learn wrote: > I've perused both the spec[1] and Andrei's book, and I the idea I > get is that module declarations are optional, recommended only in > case of file names not being valid D names. But in the community > (and Phobos) I see

Re: Loading assimp

2017-03-26 Thread Dlearner via Digitalmars-d-learn
On Sunday, 26 March 2017 at 12:40:42 UTC, Dlearner wrote: ... About half the textures seem to load fine. Some progress! I don't know why, but when I get to the 8th texture, the filename has some garbage attached. SDL_Surface* surface = IMG_Load(filename.ptr); if (surface is null) {

Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn
On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote: On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote: [...] Chances are it's invoked in another thread and thus you can't catch it like that. To sum it up. Ex. void thisFunctionThrows() { ... } void ableToCatch() { try {

Re: really why module declarations?

2017-03-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 26 March 2017 at 22:10:07 UTC, XavierAP wrote: I was curious but I guess it's long to explain the different things that can go wrong if one doesn't declare module names. You'll just get a name conflict eventually. Either two modules with the same name, or "module `foo` must be

how to define my own traits

2017-03-26 Thread XavierAP via Digitalmars-d-learn
I've looked into Phobos to emulate it when defining my own trait template, and when I see this: module std.range.primitives; // ... template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if

foreach, is and pointer

2017-03-26 Thread helxi via Digitalmars-d-learn
What's the difference between 1. string x = "abcd"; foreach(character; x) write(character); and string x = "abcd"; foreach(character; x[0..$]) write(character); 2. is and == 3. pointer and address and reference?

Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote: yes. you have a typo in second `writefln`: S1 instead of S2. ;-) thank you. another question, related to my first post: why size of S2.b1 and S2.b2 still 3, not 4? am i right: then align applied to members, compiler not change size of

Re: Howto catch SocketOSException?

2017-03-26 Thread bauss via Digitalmars-d-learn
On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote: On Sunday, 26 March 2017 at 11:35:00 UTC, Jolly James wrote: [...] Found out something: You cannot catch any exception thrown in the listen()-method in general. ■ Original code: [...] ■ Modified one: [...] ■ Not working

Re: really why module declarations?

2017-03-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 26 March 2017 at 20:51:01 UTC, XavierAP wrote: I've perused both the spec[1] and Andrei's book, and I the idea I get is that module declarations are optional, recommended only in case of file names not being valid D names. Module declarations are only optional in the most trivial

really why module declarations?

2017-03-26 Thread XavierAP via Digitalmars-d-learn
I've perused both the spec[1] and Andrei's book, and I the idea I get is that module declarations are optional, recommended only in case of file names not being valid D names. But in the community (and Phobos) I see it's strongly recommended and used throughout. What's the reason? If the

Re: union.sizeof

2017-03-26 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote: yes. you have a typo in second `writefln`: S1 instead of S2. ;-) thank you. another question, related to my first post: why size of S2.b1 and S2.b2 still 3, not 4? am i right: then align applied to members, compiler

Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn
On Sunday, 26 March 2017 at 11:35:00 UTC, Jolly James wrote: On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote: On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote: You can ignore the loop()-method. It is not called as the application will never reach this statement,

Re: Loading assimp

2017-03-26 Thread Dlearner via Digitalmars-d-learn
On Sunday, 26 March 2017 at 11:10:55 UTC, ag0aep6g wrote: On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote: I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access

Re: union.sizeof

2017-03-26 Thread ketmar via Digitalmars-d-learn
zabruk70 wrote: On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote: most of the time either location or padding will work the same. hmm.. you ruined my expirence.. i made another experiment. whould you please explain me S2 size 6? thank you for you time. yes. you have a typo in second

Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 06:38:59 UTC, zabruk70 wrote: oh sorry sorry - mistyping ok. DMD use padding, so for real container.sizeof i should use lastMemeber.offsetof+lastMemeber.sizeof

Re: Loading assimp

2017-03-26 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote: I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access violation. As far as I can tell, it seems to be an issue with

Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote: most of the time either location or padding will work the same. hmm.. you ruined my expirence.. i made another experiment. whould you please explain me S2 size 6? thank you for you time. https://dpaste.dzfl.pl/9a31b6e370a0 struct S1

Re: union.sizeof

2017-03-26 Thread zabruk70 via Digitalmars-d-learn
On Sunday, 26 March 2017 at 07:18:14 UTC, ketmar wrote: i.e. what compiler does (roughly) is inserting anonymous fields of the appropriate size *into* the container. for "inner" aligning compiler inserts anonymous fields *between* other fields. for "outer" aligning compiler just appends

Re: foreach, is and pointer

2017-03-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/03/2017 7:52 AM, helxi wrote: What's the difference between 1. string x = "abcd"; foreach(character; x) write(character); and string x = "abcd"; foreach(character; x[0..$]) write(character); Hopefully the compiler is smart enough to ignore that slice (since its

Re: Recommend: IDE and GUI library

2017-03-26 Thread Soulsbane via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 20:23:57 UTC, aberba wrote: On Friday, 24 February 2017 at 22:44:55 UTC, XavierAP wrote: [...] Gtkd is obviously defacto for Linux ONLY, dlangui for cross platform app without native feel. But if you want something easy and flexible with native look and feel on