Re: Enum that can be 0 or null

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 20:32:23 UTC, Alex Parrill wrote: They'd be the same type, since you would define the vulkan functions to take these structures instead of pointer or integer types. It relies on a lot of assumptions about the ABI that make a raw pointer work the same as a structure

Re: How to enable feedback for AssertError?

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 02:05:00 UTC, Seb wrote: On Tuesday, 7 June 2016 at 01:40:01 UTC, your_name wrote: The way I traced the problem, ironically ;), was to catch Error and print it to screen. It involved dereferencing a null pointer in a thread and an 'assert null this' silently killed

Re: Parse File at compile time, but not embedded

2016-06-06 Thread Pie? via Digitalmars-d-learn
If I use an enum dmd DOES remove it in release build. But I'm not sure for the general case yet.

Re: Parse File at compile time, but not embedded

2016-06-06 Thread Pie? via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 02:04:41 UTC, Mithun Hunsur wrote: On Monday, 6 June 2016 at 21:57:20 UTC, Pie? wrote: On Monday, 6 June 2016 at 21:31:32 UTC, Alex Parrill wrote: [...] This doesn't seem to be the case. In a release build, even though I never "use" the string, it is embedded. I

Re: Windows system casting

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 04:06:01 UTC, Mike Parker wrote: Fourth, while casting the string directly to void* will work, it's considered best practice to use the pointer property for clarity. Oops! cast(void*)path.ptr In both cases. Like I said, without .ptr, it works, but this makes

Re: Windows system casting

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 June 2016 at 19:52:36 UTC, Alexander Patapoff wrote: import std.stdio; import std.string; import core.sys.windows.windows; void main() { string filepath = "C:\\Users\\awpat\\Pictures\\patterns_00387591.jpg"; auto p = toStringz(filepath); int result;

Error: castSwitch

2016-06-06 Thread none via Digitalmars-d-learn
import std.algorithm.iteration : map; import std.algorithm : castSwitch; import std.format : format; class A { int value; this(int value) { this.value = value; }} interface I { } class B : I { } Object[] arr = [new A(5), new B(), null]; auto results = arr.map!(castSwitch!(

Re: How to enable feedback for AssertError?

2016-06-06 Thread Seb via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 01:40:01 UTC, your_name wrote: On Monday, 6 June 2016 at 00:09:15 UTC, Ali Çehreli wrote: [...] Hello Ali, The behavior you described is what I'd expect, however, it's not what I get. The way I traced the problem, ironically ;), was to catch Error and print it

Re: Parse File at compile time, but not embedded

2016-06-06 Thread Mithun Hunsur via Digitalmars-d-learn
On Monday, 6 June 2016 at 21:57:20 UTC, Pie? wrote: On Monday, 6 June 2016 at 21:31:32 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 17:31:52 UTC, Pie? wrote: Is it possible to parse a file at compile time without embedding it into the binary? I have a sort of "configuration" file that

Re: How to enable feedback for AssertError?

2016-06-06 Thread your_name via Digitalmars-d-learn
On Monday, 6 June 2016 at 00:09:15 UTC, Ali Çehreli wrote: On 06/05/2016 07:39 AM, your_name wrote: > The problem I have is whenever an assert in my debug build fails the > program or thread is just killed silently. That's strange. When an assertion fails, the stack trace is printed and the

Re: Parse File at compile time, but not embedded

2016-06-06 Thread Pie? via Digitalmars-d-learn
On Monday, 6 June 2016 at 21:31:32 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 17:31:52 UTC, Pie? wrote: Is it possible to parse a file at compile time without embedding it into the binary? I have a sort of "configuration" file that defines how to create some objects. I'd like to be

Re: Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object

2016-06-06 Thread ag0aep6g via Digitalmars-d-learn
On 06/06/2016 11:25 PM, Alex Parrill wrote: You might be able to get away with casting the const away, if you are sure it won't modify the hash or equality check. Casting away const and then mutating has undefined behavior. The compiler is free to assume that it doesn't happen. Be aware

Re: Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object

2016-06-06 Thread Begah via Digitalmars-d-learn
On Monday, 6 June 2016 at 21:25:16 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 21:16:18 UTC, Begah wrote: Does the key of a associative array will be const if the reference is requested? That's probably what it is, actually. Modifying the key with the ref could cause the hash of the

Re: Parse File at compile time, but not embedded

2016-06-06 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 6 June 2016 at 17:31:52 UTC, Pie? wrote: Is it possible to parse a file at compile time without embedding it into the binary? I have a sort of "configuration" file that defines how to create some objects. I'd like to be able to read how to create them but not have that config file

Re: Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object

2016-06-06 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 6 June 2016 at 20:40:12 UTC, Begah wrote: I have a pretty weird error : Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object [...] It may infer const from the type of `this.instance`, which may be further modified if the method you

Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object

2016-06-06 Thread Begah via Digitalmars-d-learn
I have a pretty weird error : Error: mutable method isolated.graphics.g3d.model.Model.begin is not callable using a const object The weird part is that i do not use const or immutable objects in my code ( for the Model ) : struct Handle { Model *asset = null; string

Re: Enum that can be 0 or null

2016-06-06 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 6 June 2016 at 18:43:33 UTC, ParticlePeter wrote: On Saturday, 21 May 2016 at 06:36:53 UTC, tsbockman wrote: ... As an example, if VK_NULL_HANDLE only ever needs to be assigned to opaque types on the D side (that is, types that serve only as an ID or address for communicating with

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 6 June 2016 at 18:33:36 UTC, ParticlePeter wrote: On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type

Windows system casting

2016-06-06 Thread Alexander Patapoff via Digitalmars-d-learn
import std.stdio; import std.string; import core.sys.windows.windows; void main() { string filepath = "C:\\Users\\awpat\\Pictures\\patterns_00387591.jpg"; auto p = toStringz(filepath); int result; result = SystemParametersInfo(cast(uint)SPI_SETDESKWALLPAPER,

Re: Enum that can be 0 or null

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 21 May 2016 at 06:36:53 UTC, tsbockman wrote: ... As an example, if VK_NULL_HANDLE only ever needs to be assigned to opaque types on the D side (that is, types that serve only as an ID or address for communicating with the C side), you could do this: private struct VkNullHandle

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 18:33:36 UTC, ParticlePeter wrote: On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:19:02 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A

Parse File at compile time, but not embedded

2016-06-06 Thread Pie? via Digitalmars-d-learn
Is it possible to parse a file at compile time without embedding it into the binary? I have a sort of "configuration" file that defines how to create some objects. I'd like to be able to read how to create them but not have that config file stick around in the binary. e.g., (simple

Re: core.sys.windows so lean?

2016-06-06 Thread Mike Parker via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:51:20 UTC, Jonathan Marler wrote: Hmmm...it seems to be missing quite alot though. Especially the winsock api. Over the weekend I was writing some code that uses a windows IOCompletionPort and had to add a fair amount of code that was missing: Pull requests

Re: core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 6 June 2016 at 17:11:44 UTC, Vladimir Panteleev wrote: On Monday, 6 June 2016 at 16:51:20 UTC, Jonathan Marler wrote: Hmmm...it seems to be missing quite alot though. You could've mentioned you meant just the winsock modules. They have not been brought over because they were not

Re: core.sys.windows so lean?

2016-06-06 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:51:20 UTC, Jonathan Marler wrote: Hmmm...it seems to be missing quite alot though. You could've mentioned you meant just the winsock modules. They have not been brought over because they were not explicitly under an open-source license.

Re: core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:13:48 UTC, Vladimir Panteleev wrote: On Monday, 6 June 2016 at 16:04:30 UTC, Jonathan Marler wrote: I'm writing some platform specific D code and I've found that what the druntime exposes for the windows platform is pretty lean. I'm guessing that the purpose of

Re: core.sys.windows so lean?

2016-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
With the newest dmds, if you use -m32mscoff you just use the Microsoft libraries and linkers and the core.sys.windows is pretty full - should be easy to use.

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A extern( C ) function should be able to take it as either one.

Re: core.sys.windows so lean?

2016-06-06 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 6 June 2016 at 16:04:30 UTC, Jonathan Marler wrote: I'm writing some platform specific D code and I've found that what the druntime exposes for the windows platform is pretty lean. I'm guessing that the purpose of the druntime version of the windows api is to implement the minimum

core.sys.windows so lean?

2016-06-06 Thread Jonathan Marler via Digitalmars-d-learn
I'm writing some platform specific D code and I've found that what the druntime exposes for the windows platform is pretty lean. I'm guessing that the purpose of the druntime version of the windows api is to implement the minimum required to support the windows platform and not meant to be a

Re: Implicit conversion of struct to bool for if (s) operation ?

2016-06-06 Thread chmike via Digitalmars-d-learn
On Monday, 6 June 2016 at 15:28:35 UTC, John wrote: Thank you John and Adam. That was a quick answer !

Re: Implicit conversion of struct to bool for if (s) operation ?

2016-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 6 June 2016 at 15:23:50 UTC, chmike wrote: I would like an implicit conversion of Info to bool that return false if category_ is null so that I can write add: bool opCast(T : bool)() { return whatever; } to the struct and it should work.

Re: Implicit conversion of struct to bool for if (s) operation ?

2016-06-06 Thread John via Digitalmars-d-learn
On Monday, 6 June 2016 at 15:23:50 UTC, chmike wrote: Hello, I have a structure with two fields ad defined as struct Info { this(int value, Category category) { category_ = category; value_ = category ? value : 0; } // This converts implicitly to bool.

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 12:09:33 UTC, ParticlePeter wrote: I don't see the connection here, you introduced two symbols with two different types. I want one symbol which can pose as two different (constant) types. Ah, my apologies, I misunderstood the question.

Re: Range and poolTask

2016-06-06 Thread moechofe via Digitalmars-d-learn
On Monday, 6 June 2016 at 11:25:00 UTC, Rene Zwanenburg wrote: Could you elaborate a bit? Yes. I have an InputRange and need to pass it throughout a couple of iteration and manipulation functions such as filter, map and finishing by grouping with fold. Like: myrange .filter!xxx

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 6 June 2016 at 11:40:11 UTC, Anonymouse wrote: On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A extern( C ) function should be able to take it as either one.

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: A extern( C ) function should be able to take it as either one. Missed this bit. Not sure about that one.

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 10:26:11 UTC, moechofe wrote: The functions passed to map or amap take the type of the element of the range as argument, but not a range itself. Right. I don't think I understand what the semantics of your example would be though.. Could you elaborate a bit?

Re: Range and poolTask

2016-06-06 Thread moechofe via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:38:32 UTC, Rene Zwanenburg wrote: http://dlang.org/phobos/std_parallelism.html#.TaskPool Or, more specifically, http://dlang.org/phobos/std_parallelism.html#.TaskPool.amap http://dlang.org/phobos/std_parallelism.html#.TaskPool.map The functions passed to map or

Emulate C's (polymorphic) NULL type

2016-06-06 Thread ParticlePeter via Digitalmars-d-learn
In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A extern( C ) function should be able to take it as either one. Overloaded enum pops into my mind as example: enum NULL = 0; enum

Re: Range and poolTask

2016-06-06 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:32:30 UTC, moechofe wrote: I wonder if it is possible to write something like this: --- // taskPool.distribute -- take a range and distribute entries to different threads. dirEntries().distribute(function(R1,R2)(R1 from,R2 to){ from .filter!xxx

Range and poolTask

2016-06-06 Thread moechofe via Digitalmars-d-learn
I wonder if it is possible to write something like this: --- // taskPool.distribute -- take a range and distribute entries to different threads. dirEntries().distribute(function(R1,R2)(R1 from,R2 to){ from .filter!xxx .map!yyy .tee!zzz(to); }) .each!www; --- This

Re: Speed up `dub`.

2016-06-06 Thread ciechowoj via Digitalmars-d-learn
On Sunday, 5 June 2016 at 21:20:20 UTC, Andrej Mitrovic wrote: On Thursday, 2 June 2016 at 13:04:00 UTC, ciechowoj wrote: and found that an assert from `std/path.d:3168` (`globMatch`) contributes a major amount to the running time of dub. ``` assert(balancedParens(pattern, '[', ']', 0));

Re: Embed files into binary.

2016-06-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/06/2016 6:45 PM, Pie? wrote: On Monday, 6 June 2016 at 06:10:35 UTC, rikki cattermole wrote: On 06/06/2016 6:06 PM, Pie? wrote: On Monday, 6 June 2016 at 05:30:12 UTC, rikki cattermole wrote: On 06/06/2016 5:07 PM, Pie? wrote: [...] Then I would say go get a new image library as that

Re: Embed files into binary.

2016-06-06 Thread Pie? via Digitalmars-d-learn
On Monday, 6 June 2016 at 06:10:35 UTC, rikki cattermole wrote: On 06/06/2016 6:06 PM, Pie? wrote: On Monday, 6 June 2016 at 05:30:12 UTC, rikki cattermole wrote: On 06/06/2016 5:07 PM, Pie? wrote: [...] Then I would say go get a new image library as that one isn't a very good one.

Re: Embed files into binary.

2016-06-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/06/2016 6:06 PM, Pie? wrote: On Monday, 6 June 2016 at 05:30:12 UTC, rikki cattermole wrote: On 06/06/2016 5:07 PM, Pie? wrote: [...] Then I would say go get a new image library as that one isn't a very good one. ..snip.. Right got rid of all that text. If you want to make the

Re: Embed files into binary.

2016-06-06 Thread Pie? via Digitalmars-d-learn
On Monday, 6 June 2016 at 05:30:12 UTC, rikki cattermole wrote: On 06/06/2016 5:07 PM, Pie? wrote: [...] Then I would say go get a new image library as that one isn't a very good one. ..snip.. Right got rid of all that text. If you want to make the filesystem appear to have files it