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: 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

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 (r.em

Re: really why module declarations?

2017-03-26 Thread Nicholas Wilson 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. But in the community (and Phobos) I see it's strongly recomme

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 impor

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: 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: 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 Models/Nanosuit/helmet_dif

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: 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 ca

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 decla

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 t

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 violation.

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, because

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 listen()-method

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 `aiGet

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 a

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 anonymo

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 not

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