Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-09 Thread Dennis via Digitalmars-d-learn
On Friday, 8 March 2019 at 11:42:11 UTC, Simon wrote: Thanks, this works flawlessly. Out of interest: what is the "enum" doing there? I had the exact same behaviour in a function before, that I only called at compile-time, so why did it complain then? Can I somehow tell the compiler that a

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to

Re: Phobos in BetterC

2019-03-09 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to

Re: Phobos in BetterC

2019-03-09 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to

Re: Phobos in BetterC

2019-03-09 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: Also I would to know what parts of Phobos are available there (e.g. std.traits, std.typecons...). There is no clear rule on which phobos packages work and which don't. It all depends on what underlying features the phobos package

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 9 March 2019 at 12:42:34 UTC, Sebastiaan Koppe wrote: There might also be the option to use @nogc exceptions (dip 1008), but I am not sure. That won't work as the implementation on DIP1008 cheats the type system but doesn't actually work, i.e. the exceptions are still CG

Re: Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:39:29 UTC, bitwise wrote: Is it possible to get Dub to output import headers for compiled D files? I found this, which almost works: "dflags": [ "-H", "-Hdimport", "-op" ] The only problem is that Dub runs *above* the source directory, resulting in all my

Re: Phobos in BetterC

2019-03-09 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 9 March 2019 at 17:14:37 UTC, 9il wrote: It was fixed to be used in BetterC. If it still does not work you can open an issue and ping me (@9il). That is awesome. I suppose support for betterC is only from v3 upwards?

Re: Phobos in BetterC

2019-03-09 Thread 9il via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to

Distinguish float and integer types from string

2019-03-09 Thread Jacob Shtokolov via Digitalmars-d-learn
Hi, Recently, I was trying to solve some funny coding challenges (https://www.techgig.com). The questions were really simple, but I found it interesting because the website allows to use D. One of the task was to take a string from STDIN and detect its type. There were a few options: Float,

Re: Distinguish float and integer types from string

2019-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 March 2019 at 18:11:09 UTC, Jacob Shtokolov wrote:w One of the task was to take a string from STDIN and detect its type. The way I'd do this is a very simple loop: enum Type { String, Float, Int } if(str.length && str[0] == '-') { str = str[1 .. $]; } Type type = str.length

Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
Is it possible to get Dub to output import headers for compiled D files?

this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
Hello everyone! I've encountered the problem which I already encountered before. Unfortunately, I had no time in the previous time to report and to talk about it. So I decided to play making my own "malloc" function in pure D (betterC) at this time. And I encountered the issue one more time.

Re: Make Dub output *.di files

2019-03-09 Thread bitwise via Digitalmars-d-learn
On Saturday, 9 March 2019 at 19:08:22 UTC, bitwise wrote: On Saturday, 9 March 2019 at 18:39:29 UTC, bitwise wrote: Is it possible to get Dub to output import headers for compiled D files? I found this, which almost works: "dflags": [ "-H", "-Hdimport", "-op" ] The only problem is that Dub

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: struct S { bool isThisNull() { return is null; } } void main() { import.std.stdio; S* p = null; writeln((*p).isThisNull); // true } Interactive version: https://run.dlang.io/is/fgT2rS Anyway, thank you! I didn't

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is not null before calling. Take a look at the line of code

Re: this is null

2019-03-09 Thread ANtlord via Digitalmars-d-learn
On Saturday, 9 March 2019 at 21:00:51 UTC, Ali Çehreli wrote: I haven't run the code but which pointer is null? Try adding I mean `this` by "this" word. You can see that `this` is null if you run gdb and before that line make `p/x this` [0] this check as well: auto node =

Re: this is null

2019-03-09 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 9 March 2019 at 19:18:38 UTC, ANtlord wrote: Hello everyone! I've encountered the problem which I already encountered before. Unfortunately, I had no time in the previous time to report and to talk about it. So I decided to play making my own "malloc" function in pure D (betterC)

Re: this is null

2019-03-09 Thread Ali Çehreli via Digitalmars-d-learn
On 03/09/2019 12:10 PM, ANtlord wrote: On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote: You can end up with a null `this` reference if you dereference a null pointer to a struct and then call a method on the result. For example: I can but my reference is not null before

Re: Phobos in BetterC

2019-03-09 Thread 9il via Digitalmars-d-learn
On Saturday, 9 March 2019 at 19:40:27 UTC, Sebastiaan Koppe wrote: On Saturday, 9 March 2019 at 17:14:37 UTC, 9il wrote: It was fixed to be used in BetterC. If it still does not work you can open an issue and ping me (@9il). That is awesome. I suppose support for betterC is only from v3