Re: What is D's "__debugbreak()" equivalent?

2021-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/27/21 12:54 PM, Simon wrote: Microsofts C++ compiler provides the __debugbreak function, which on x86 emits interrupt 3, which will cause the debugger to halt. What is the equivalent in D? I tried using raise(SIGINT) from core.stdc.signal, but that just closes the debugger (I thought

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/21 1:38 PM, Imperatorn wrote: That's the current implementation. No, that's the API. You cannot fix the implementation with that API and not end up allocating an array to hold the entire unzipped contents. You can't even decompress to a file, and then mmap those contents -- the

Re: Analyze debug condition in template

2021-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/21 11:39 AM, novice2 wrote: On Tuesday, 26 October 2021 at 09:44:42 UTC, Kagamin wrote: `debug(func1)writefln(...)` But specify a global debug version for the compiler: `dmd -debug=func1 app.d` i want to eliminate "debug(func1)" i want to be able on/off debugging for one function or

Re: std.zip expand: memory allocation failed

2021-10-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting

Re: std.zip expand: memory allocation failed

2021-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason  to uncompress a 1-gig file with uncompressed size of 4-gig, Zip Archive of D-Lang tries to use more than 16 gig of RAM. I don't know why.

Re: Dub failing to use the linker correctly.

2021-10-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/22/21 5:21 PM, jfondren wrote: On Friday, 22 October 2021 at 19:56:37 UTC, Ruby The Roobster wrote: I have a simple vibe-d project built with dub.  Running the command, dub build --force returns the following output: I'd start by running `dub -v build --force` instead, to see the exact

Re: Unexpected path of execution

2021-10-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/19/21 12:49 PM, Dennis wrote: On Tuesday, 19 October 2021 at 16:20:39 UTC, Charles Hixson wrote: core.exception.RangeError@source/freqs.d(32): Range violation ??:? _d_arrayboundsp [0x56041325a70d] ??:? _Dmain [0x560413233beb] DMD64 D Compiler v2.097.2 By the way, if

Re: New library: argparse, for parsing CLI arguments

2021-10-19 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/19/21 10:36 AM, Andrey Zherikov wrote: On Tuesday, 19 October 2021 at 14:06:21 UTC, Steven Schveighoffer wrote: Just nitpicks. Like allowing `@NamedArgument` without parentheses. Or using `@NamedArgument("b", "banana", "ban")` instead of `@NamedArgument([&

Re: New library: argparse, for parsing CLI arguments

2021-10-19 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/19/21 6:54 AM, Andrey Zherikov wrote: On Monday, 18 October 2021 at 13:16:01 UTC, Steven Schveighoffer wrote: Prepare for some PRs, I already see ways to make this better ;) Don't you mind sharing your ideas? Just nitpicks. Like allowing `@NamedArgument` without parentheses

Beerconf October 2021

2021-10-18 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Just one month to go before the next [dconf online](http://dconf.org/2021/online/index.html), I hope everyone is excited! In the meantime, we will once again get together online to discuss all things D, and sample some tasty beverages. This month, it falls on October 30-31. If

Re: New library: argparse, for parsing CLI arguments

2021-10-18 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/17/21 6:02 PM, Andrey Zherikov wrote: On Thursday, 14 October 2021 at 15:03:34 UTC, Steven Schveighoffer wrote: Having done a lot of stuff with serialization and UDAs, this turns into a mess if you have multiple systems (serialization is really what you are doing here) using the same

Re: How can we allow using phobos with asserts/contracts?

2021-10-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/18/21 8:35 AM, user1234 wrote: On Sunday, 17 October 2021 at 21:00:19 UTC, Steven Schveighoffer wrote: On 10/16/21 6:47 PM, solidstate1991 wrote: When I make this call ``` format(" %3.3f"w, avgFPS); ``` my program immediately crashes with an access violation error. The de

How can we allow using phobos with asserts/contracts?

2021-10-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/21 6:47 PM, solidstate1991 wrote: When I make this call ``` format(" %3.3f"w, avgFPS); ``` my program immediately crashes with an access violation error. The debugger out is different between x86 and x86-64. I've made all sanity checks, so I need some other suggestions. FYI,

Re: Threading challenge: calculate fib(45) while spinning

2021-10-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/21 10:01 AM, Ali Çehreli wrote: >    writefln!"\rFibonacci(%d) = %d"(n, fibN); That '\r' bothered me because the actual work needs to know what the spinner is doing to clear its remaining character. I would expect the original go code had the same problem. -Steve

Re: How to check if value is null, today?

2021-10-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/21 6:39 AM, tastyminerals wrote: On Thursday, 14 October 2021 at 12:43:36 UTC, jfondren wrote: Do you have a complete example? Because this runs without error: Steven Schveighoffer was correct, the error was caused by non explicit `someVar;` which had to be changed

Re: Threading challenge: calculate fib(45) while spinning

2021-10-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/14/21 11:35 PM, jfondren wrote: The book, "The Go Programming Language" has this simple goroutine example: ```go func main() {     go spinner(100 * time.Millisecond)     const n = 45     fibN := fib(n) // slow     fmt.Printf("\rFibonacci(%d) = %d\n", n, fibN) } func spinner(delay

Re: How to check if value is null, today?

2021-10-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/14/21 7:58 AM, tastyminerals wrote: The new `DMD v2.097.2` deprecated implicit null conversions `std.typecons.Nullable!double.Nullable.get_`. The deprecation warning tell you to `Please use .get explicitly.`. Here is an example code that doesn't work with the new compiler anymore: ```

Re: New library: argparse, for parsing CLI arguments

2021-10-14 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/13/21 9:13 PM, Andrey Zherikov wrote: On Thursday, 14 October 2021 at 00:35:11 UTC, Bill Baxter wrote: Not sure how much change there is over "classic" gflags, but https://abseil.io/docs/cpp/guides/flags is what google now uses internally. Abseil version suggests not to put flags

Re: New library: argparse, for parsing CLI arguments

2021-10-14 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/13/21 7:36 PM, Andrey Zherikov wrote: On Wednesday, 13 October 2021 at 16:24:52 UTC, Steven Schveighoffer wrote: The point is that I shouldn't have to tell the library the name of something that I've already given a name to. Having them named differently on the command line than

Re: New library: argparse, for parsing CLI arguments

2021-10-13 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/13/21 11:50 AM, Andrey Zherikov wrote: On Wednesday, 13 October 2021 at 14:36:30 UTC, Steven Schveighoffer wrote: One nitpick -- you should be able to opt in using the name of the field member instead of having to write `@NamedArgument`. e.g. your `string unused` parameter requires

Re: New library: argparse, for parsing CLI arguments

2021-10-13 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/13/21 7:27 AM, Andrey Zherikov wrote: Hi everyone, I'm happy to announce that I've published a CLI argument parsing library - [argparse](https://code.dlang.org/packages/argparse). It's been around for some time already so please take a look and provide your feedback if you haven't done

Re: Managing malloced memory

2021-10-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/11/21 6:53 AM, anon wrote: On Thursday, 7 October 2021 at 11:55:35 UTC, Steven Schveighoffer wrote: The GC is technically not required to free any blocks ever. But in general, it does. When it does free a struct, as long as you allocated with `new`, it should call the dtor

Re: How to do a function pointer to "malloc" and "free"?

2021-10-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/10/21 6:44 AM, rempas wrote: I'm having the following C code: ``` static void* (*ppmalloc)(size_t) = malloc; static void (*ppfree)(void*) = free; ``` I want to covert this code in D so I try to do the following: ``` static void* function(size_t)*ppmalloc = malloc; static void 

Re: A GUI for DMD, the final version has been release.

2021-10-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/11/21 5:44 PM, Dejan Lekic wrote: On Saturday, 9 October 2021 at 23:02:22 UTC, Murilo wrote: Hi guys, I've just finished the final version of the DMD GUI, there is Linux and a Windows version, click on the link below to download it: https://github.com/MuriloMir/DMD-GUI It is always

Re: DConf Online 2021 Schedule Published

2021-10-08 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/8/21 8:31 PM, Adam Ruppe wrote: On Friday, 8 October 2021 at 22:16:16 UTC, Matheus wrote: Adam beyond the continuation... we need a new and simply Web Browser written in D. :) You know back in 2013ish I actually was doing a little one. htmlwidget.d in my github repo. It always sucked

Re: Managing malloced memory

2021-10-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/21 3:22 PM, anon wrote: Sorry for messed up post, fixed it. On Wednesday, 6 October 2021 at 18:29:34 UTC, Steven Schveighoffer wrote: You can return this thing and pass it around, and the GC will keep it alive until it's not needed. Then on collection, the value is freed. Is the gc

Re: Managing malloced memory

2021-10-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/6/21 2:06 PM, anon wrote: I interface to a C library that gives me a malloced object. How can I manage that pointer so that it gets freed automatically. What I've thought of so far: * scope(exit): not an option because I want to return that memory * struct wrapper: Doesn't work because if

Re: Beta 2.098.0

2021-10-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/4/21 6:40 PM, Temtaime wrote: What is really discourages me that persons like Walter instead of making D great just do nothing helpful. https://issues.dlang.org/show_bug.cgi?id=22115 was created for no reason and fixed same day. Aside from the tasteless (and incorrect) attack here,

Re: Sort bug / strangeness

2021-10-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/1/21 12:44 PM, Danny Arends wrote: Hey all, Using a modified 3D A* tile searching algorithm, full code see: https://github.com/DannyArends/CalderaD/blob/master/src/math/search.d I get the following AssertError, 'sometimes' but not always on running the code: mutation.d(2816): Swap:

Re: Why sometimes stacktraces are printed and sometimes not?

2021-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/21 6:57 AM, JN wrote: What makes the difference on whether a crash stacktrace gets printed or not? Sometimes I get a nice clean stacktrace with line numbers, sometimes all I get is "segmentation fault error -1265436346" (pseudo example) and I need to run under debugger to get the

Re: Why sometimes stacktraces are printed and sometimes not?

2021-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/21 8:15 AM, Steven Schveighoffer wrote: On Linux, there is the undocumented `etc.linux.memoryhandler` Sorry, it's `etc.linux.memoryerror` Here is the code: https://github.com/dlang/druntime/blob/master/src/etc/linux/memoryerror.d -Steve

Re: Modules ... "import" vs. "compilation" ... what is the real process here?

2021-09-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/28/21 1:59 AM, james.p.leblanc wrote: On Tuesday, 28 September 2021 at 05:26:29 UTC, Ali Çehreli wrote: On 9/27/21 10:38 AM, james.p.leblanc wrote: In addition to what Mike Parker said, templates do complicate matters here: Templates are instantiated (i.e. compiled for a specific set

Re: abstract classes and interfaces

2021-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/21 12:11 PM, kyle wrote: I'm attempting Markdown for the first time so forgive me if that doesn't go well. Consider the following: ```d interface A {     bool broken(); } abstract class B : A { } class C : B { } void main() {     import std.stdio;     C test = new C();    

Re: write struct as raw data to file

2021-09-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/21 11:09 AM, Paul wrote: I'm building a binary file.  I can write my 'short[] myArray' directly to the file using: File f = File( "myFile.wav", "wb" ); f.rawWrite(myArray); It doesn't write any array formatting stuff (i.e. '[ ,  , ]'); it just moves the data into myFile like I want.

Re: Casting JSONValues arrays to native arrays ... ??? ...

2021-09-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/24/21 12:58 AM, james.p.leblanc wrote: On Thursday, 23 September 2021 at 20:32:36 UTC, james.p.leblanc wrote: On Thursday, 23 September 2021 at 19:18:11 UTC, james.p.leblanc wrote: On Thursday, 23 September 2021 at 19:04:47 UTC, Steven Schveighoffer wrote: On 9/23/21 2:20 PM

Re: Beerconf September 2021

2021-09-24 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/24/21 12:35 AM, james.p.leblanc wrote: That sounds great!  Could you post a link to how someone can join the BeerConf?  A quick forum search produced only two hits, neither with needed info. Here is the wiki article, which describes what beerconf online is and how it works.

Re: Casting JSONValues arrays to native arrays ... ??? ...

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 2:20 PM, james.p.leblanc wrote: Dear D-ers, In attempting to cast JSONValues that hold arrays to "native" array types, I have hit some issues.  Example code: ```d import std.stdio; import std.json; void main(){    JSONValue jj;    jj["d"] = [ 1.234 ];  // a

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 1:44 PM, eugene wrote: On Thursday, 23 September 2021 at 17:20:18 UTC, Steven Schveighoffer wrote: So imagine the sequence: With ease! 1. ctrl-c, signal handler triggers, shutting down the loop Just a note: there is no 'signal handler' in the program. SIGINT/SIGTERM

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 2:18 PM, eugene wrote: On Thursday, 23 September 2021 at 17:16:23 UTC, Steven Schveighoffer wrote: On 9/23/21 12:58 PM, eugene wrote: On Thursday, 23 September 2021 at 15:56:16 UTC, Steven Schveighoffer wrote: See more details: https://docs.microsoft.com/en-us/dotnet/api

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 12:53 PM, eugene wrote: On Thursday, 23 September 2021 at 15:53:37 UTC, Steven Schveighoffer wrote: Technically, they should live past the end of main, because it's still possible to receive signals then. No, as soon as an application get SIGTERM/SIGINT, event queue is stopped

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 12:58 PM, eugene wrote: On Thursday, 23 September 2021 at 15:56:16 UTC, Steven Schveighoffer wrote: See more details: https://docs.microsoft.com/en-us/dotnet/api/system.gc.keepalive?view=net-5.0#remarks " This method references the obj parameter, making that object ineli

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 9:18 AM, eugene wrote: On Thursday, 23 September 2021 at 12:53:14 UTC, Steven Schveighoffer wrote: We need to add a better way to do that (similar to C# KeepAlive). Do you mean some function attribute?.. C# KeepAlive (and Go KeepAlive) are a mechanism to do exactly what you

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 10:55 AM, eugene wrote: On Thursday, 23 September 2021 at 14:31:34 UTC, jfondren wrote: Nice. I thought of GC.addRoot several times but I was distracted by the general solution of using object lifetimes with it, so that a struct's destructor would call GC.removeRoot. For your case

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 8:10 AM, eugene wrote: On Wednesday, 22 September 2021 at 18:38:34 UTC, Steven Schveighoffer wrote: I find it interesting how you blame yourself for C's idiosyncrasies Me? Blaming *myself* for C 'idiosyncrasies'? :) Where? "When my C program crashes, I'm 100% sure I

Re: Program crash: GC destroys an object unexpectedly

2021-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/23/21 3:27 AM, eugene wrote: On Wednesday, 22 September 2021 at 18:38:34 UTC, Steven Schveighoffer wrote: Your experience is not typical though (clearly, as many of us long-time D users had no idea why it was happening). Oh, yeah - I have special trait of bumping against various low

Re: Program crash: GC destroys an object unexpectedly

2021-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/22/21 11:47 AM, eugene wrote: On Wednesday, 22 September 2021 at 12:26:53 UTC, Steven Schveighoffer wrote: On 9/22/21 8:22 AM, eugene wrote: And it follows that programming in GC-supporting languages *may* be harder than in languages with manual memory management, right? I meant my

Re: Program crash: GC destroys an object unexpectedly

2021-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/22/21 8:22 AM, eugene wrote: On Wednesday, 22 September 2021 at 11:44:16 UTC, Steven Schveighoffer wrote: Once it's on the stack, the GC can see it for the full run of `main`. This is why this case is different. Note that Java is even more aggressive, and might *still* collect

Re: Program crash: GC destroys an object unexpectedly

2021-09-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/21/21 4:17 PM, eugene wrote: On Tuesday, 21 September 2021 at 19:42:48 UTC, jfondren wrote: On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: There's nothing special about sg0 and sg1, except that they're part of Stopper. The Stopper in main() is collected before the end of

Re: Beerconf September 2021

2021-09-21 Thread Steven Schveighoffer via Digitalmars-d-announce
A bit early of a reminder here, but I wanted to let you know that while Stefan was the first BeerConf speaker, the second BeerConf speaker will be... also Stefan. He will provide an update on the status of newCTFE which he has used recently to show a proof-of-concept for enabling statically

Re: Why dtor are not executed when removing a struct from associative arrays?

2021-09-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/21/21 2:06 AM, Tejas wrote: On Monday, 20 September 2021 at 18:13:53 UTC, Steven Schveighoffer wrote: On 9/20/21 10:22 AM, Tejas wrote: In case you still want to delete stuff deterministically despite what Steve said, I suggest you make your `struct` a reference and use `core.memory

Re: Templates for instantiating derived class

2021-09-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/20/21 6:16 PM, rjkilpatrick wrote: Essentially, I would like to write a template that calls the constructor of the parent class or the constructor of the inherited class, depending on its type. ... Some kind of `return new this(...)` would be good, but that's not possible. I think it

Re: Why dtor are not executed when removing a struct from associative arrays?

2021-09-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/20/21 10:22 AM, Tejas wrote: In case you still want to delete stuff deterministically despite what Steve said, I suggest you make your `struct` a reference and use `core.memory.__delete`(not recommended to use this carelessly, btw) Do not call `__delete` here, use `destroy`. `__delete`

Re: Why dtor are not executed when removing a struct from associative arrays?

2021-09-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/20/21 8:23 AM, Learner wrote: I was expecting something like going out of scope for that ```d import std.stdio; struct S {     ~this()     {     writeln("S is being destructed");     } } void main() { S[int] aa;     aa[1] = S();     aa.remove(1);     writeln("Why no dtor

Re: Extract base type of any array?

2021-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/21 12:20 AM, jfondren wrote: On Sunday, 19 September 2021 at 03:58:41 UTC, Kirill wrote: How can I get the base type of any (multidimensional/static/dynamic/associative) array? Example: ``` void main() {     int[][] intArr;     double[4][] doubleArr;     string[string][] strArr;    

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:16 PM, frame wrote: On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Did you mean "long to char" cast? In that case, yes, you have to cast it. Note, `out` is a keyword, it can't be used as a variable, but you probably already figure

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:20 PM, frame wrote: On Saturday, 18 September 2021 at 21:16:13 UTC, frame wrote: On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Are you defining the prototype for strchr yourself instead of importing it from core.stdc.string? Not really :D

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 12:52 PM, frame wrote: There were also parts where the pointer is used in calculations - which is accepted by the compiler - it just complains about implicitly `long` to `char*` cast: ``` // const char *e // char *w out[p++] = ((w - e) + 3) % 40; ``` Did you mean "long to char"

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 12:52 PM, frame wrote: On Saturday, 18 September 2021 at 11:47:52 UTC, Steven Schveighoffer wrote: Have you tried: ```d const(char)* s2 = "..."; ``` This will work because string literals are zero terminated and implicitly castable to `immutable(char)*`, which

Re: What is the meaning of @future ?

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 7:49 AM, Steven Schveighoffer wrote: add buys "ad buys" of course :P -Steve

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:40 AM, frame wrote: On Friday, 17 September 2021 at 14:29:23 UTC, Steven Schveighoffer wrote: Looking at that signature, it does not appear that it uses zero-termination at all, as it takes a length. So using `dup` and therefore the gc is totally unnecessary. I'm assuming

Re: What is the meaning of @future ?

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 4:02 AM, Dylan Graham wrote: On Friday, 17 September 2021 at 14:37:29 UTC, Meta wrote: On Friday, 17 September 2021 at 10:31:34 UTC, bauss wrote: On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: [...] It's just another "useless" attribute that the language has added

Re: GC seems to crash my C-code function

2021-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/21 2:27 AM, frame wrote: On Thursday, 16 September 2021 at 18:02:44 UTC, Steven Schveighoffer wrote: Are you sure? Be very pedantic about what C functions do with the data you send it. Sometimes they store it somewhere to use later. Sometimes they expect it to be allocated by the C

Re: GC seems to crash my C-code function

2021-09-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/21 1:08 PM, frame wrote: On Thursday, 16 September 2021 at 15:34:25 UTC, Steven Schveighoffer wrote: `dup` is a GC allocation. Are you using that in your C code? the GC might be collecting that string. The compiler doesn't show that lines with -vgc. Maybe it knows that it is only

Re: GC seems to crash my C-code function

2021-09-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/21 6:28 AM, frame wrote: I have C-code translated in D that acts sometimes incorrect if the GC has made some collect. I would like to know why. - Code runs correct if the GC collections are off - There are no allocations within the C-translated-code except `throw new` (but they are

Re: mysql-native release v3.0.3

2021-09-15 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/14/21 8:14 PM, surlymoor wrote: On Tuesday, 14 September 2021 at 12:00:45 UTC, Steven Schveighoffer wrote: No worries, I am carving out time here and there to work on it. There are 2 heavy lifts here, both of which I think need to be done before a release. [...] Appreciate

Re: uint overflow behaviour

2021-09-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 15 September 2021 at 10:08:13 UTC, DLearner wrote: Please confirm that if the addition of two uint variables produces a result larger than can be held in a uint: 1. This is a D-legal operation (however inadvisable!), with the D-defined result of wraparound; Definition under

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 2:05 PM, eugene wrote: On Tuesday, 14 September 2021 at 17:02:32 UTC, jfondren wrote: It doesn't seem like communication between us is possible and you are wrong, as usual ,) in the "a five-pound phone won't sell" way. I am not a 'selling boy' My suggestion remains: try

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 10:56 AM, jfondren wrote: On Tuesday, 14 September 2021 at 14:40:55 UTC, eugene wrote: On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: This project is too big and complex Really, "too big and complex"? It's as simple as a tabouret :) It's

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 8:42 AM, eugene wrote: On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: I still recommend pinning the object when adding the epoll event and seeing if that helps. I understand your idea, but even if this will help, the question remains - why

Re: Recommendations on parsing XML via an InputRange

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 10:43 PM, Chris Piker wrote: Hi D I just finished a ~1K line project using `dxml` as the XML reader for my data streams.  It works well in my test examples using memory mapped files, but like an impulse shopper I didn't notice that dxml requires `ForwardRange` objects.  That's

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 7:31 AM, eugene wrote: On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: Then after pressing ^C (SIGINT) the program gets SIGSEGV, since references to sg0 and sg1 are no longer valid (they are "sitting" in epoll_event structure). ... forget to mention, crashes here:

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 1:49 AM, Tejas wrote: On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote: On 9/13/21 1:54 PM, eugene wrote: [...] The GC only scans things that it knows about. Inside your EventQueue you have this code: [...] Umm is it okay that he declared variables

Re: mysql-native release v3.0.3

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/14/21 5:16 AM, surlymoor wrote: On Tuesday, 14 September 2021 at 06:14:44 UTC, bauss wrote: See: https://github.com/mysql-d/mysql-native/pull/214#issuecomment-874692651 Thanks! Should've checked for recent activity before posting, it seems. Last I knew, Steven said there was some

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 1:54 PM, eugene wrote: On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: The problems seems to lies in `newSignal()` which "would" not allocate using the GC.     final Signal newSignal(int signum) {     Signal sg = new Signal(signum);     sg.owner = this;    

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 10:47 AM, user1234 wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: what else ? when you have ```d alias AA1 = int[int]; alias AA2 = AA1[int]; ``` then you can write ```d AA2 aa; aa[0] = [0 : 0]; aa[0][0] = 0; ``` The `[0][0]` cannot be expressed using

Beerconf September 2021

2021-09-11 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! It's that time again, time for a few days of brews and D discussion. This month, the last weekend falls on September 25-26. ## What is beerconf? Check out the [wiki article](https://wiki.dlang.org/Beerconf). ## Calling all presenters I know all you conference speakers submitted

mysql-native release v3.0.3

2021-09-11 Thread Steven Schveighoffer via Digitalmars-d-announce
I just tagged a new release. This fixes a couple of minor issues. See the [Changelog](https://github.com/mysql-d/mysql-native/blob/master/CHANGELOG.md) for details. -Steve

Re: Ali's Book - Programming in D

2021-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/21 10:21 AM, Ali Çehreli wrote: I want to thank Steven Schveighoffer here once more for his help with the book. I later realized that his name should have much more prominence. I can't understand how my older self did not realize this fact when the book was being finalized. Your

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/21 7:47 AM, eugene wrote: On Friday, 10 September 2021 at 11:09:10 UTC, bauss wrote: --DRT-gcopt=parallel:2 on the command line. A value of 0 disables parallel marking completely. but it does not: make -f Makefile-dmd dmd --DRT-gcopt=parallel:0 engine/*.d common-sm/*.d server-sm/*.d

Re: Ali's Book - Programming in D

2021-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/21 6:46 AM, Ron Tarrant wrote: I guess this is mainly a question for Ali, but if anyone else knows the answer, please jump in... If I were to buy a paperback copy of "Programming in D: Tutorial & Reference" from Amazon (this link:

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/8/21 5:55 AM, Chris Piker wrote: On Wednesday, 8 September 2021 at 08:39:53 UTC, jfondren wrote: so I'd look at a std.sumtype of them first: Wow, this forum is like a CS department with infinite office hours! Interesting.  I presume that the big win for using std.sumtype over a class

Re: [Semi-OT] Sdlang Initiative

2021-09-06 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/6/21 12:59 PM, SealabJaster wrote: https://github.com/SdlangInitiative Since SDLang is quite closely related to D, as D is one of the only real users of it, I felt this was "D appropriate" enough to post. I personally think SDLang is much better than the likes of JSON, XML, and YAML

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/21 10:13 AM, Mike Parker wrote: On Monday, 6 September 2021 at 13:23:21 UTC, Steven Schveighoffer wrote: I will note though, that some people use the mechanism for links that puts the link at the bottom of the post, and this can be annoying when you reply, if you don't include

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/5/21 9:18 PM, Ali Çehreli wrote: On 9/5/21 4:24 PM, someone wrote: > > For example; IIRC Ali's posts are always no-markdown. > That's because I've been using Thunderbird for mail and news for a long time now and unfortunately it is impossible to convince Thunderbird to add the

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/5/21 2:07 PM, james.p.leblanc wrote: But, my eyes had been looking for the beautiful green and blue text as an example ...  So, I completely missed the fact that the "highlight syntax" in the box was exactly what I was looking for. Actually, it may not be a bad idea to make that example

Re: Forum posting question ... how post a thread question with color syntax highlighting ??

2021-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/5/21 1:48 PM, james.p.leblanc wrote: Dear All, I have noticed that quite a few posts and responses on this forum include d snippets made with **nicely colored syntax highlighting.** (I do not mean just the bold markdown text.) This increases post clarity significantly. How is this being

Re: Phobos Unittest

2021-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/21 4:05 PM, Per Nordlöw wrote: On Saturday, 4 September 2021 at 13:12:49 UTC, Steven Schveighoffer wrote: Note that lexing and parsing is extremely quick, and I wouldn't focus on trying to trim this out, you won't get much performance out of that. -Steve For the record, a D file

Re: Phobos Unittest

2021-09-04 Thread Steven Schveighoffer via Digitalmars-d-learn
, even when you're compiling user code that has no interest in Phobos unittests. Well, no; it compiles all unittests of all *compiled* modules, not all *imported* modules. So it does not actually include Phobos unittests. [...] As Steven Schveighoffer [pointed out][1], Phobos unittests are never

Re: Phobos Unittest

2021-09-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/21 5:42 AM, Per Nordlöw wrote: On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote: As Steven Schveighoffer [pointed out][1], Phobos unittests are never included in user code, regardless of whether `StdUnittest` is used. Yes, but they are lexed and parsed, right? Yes

Re: Run-time setting of immutable variable?

2021-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/21 1:17 PM, DLearner wrote: I am looking for a mutable Arr but would like an immutable ArrPtr. Then you want const not immutable. Here is the reason: ```d void main() { int x = 5; immutable int *ptr = cast(immutable int *) assert(*ptr == 5); // ok x = 6;

Re: Run-time setting of immutable variable?

2021-09-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/21 12:01 PM, DLearner wrote: Suppose there is a variable that is set once per run, and is (supposed) never to be altered again.  However, the value to which it is set is not known at compile time. Example below, variable is 'ArrPtr'; ``` ubyte[10] Arr; // immutable void* ArrPtr; void*

Re: vibe.d: is it possible to use bare HTML with the functionalty of DIET templates ?

2021-09-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/21 8:40 PM, someone wrote: On Tuesday, 31 August 2021 at 14:06:32 UTC, Steven Schveighoffer wrote: The generation of code to output the page depends on the diet file format (i.e. code islands are designated by the leading `-`). However, vibe-d does not require using the diet

Re: Module import incompatibility

2021-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/21 11:17 AM, Paul Backus wrote: On Tuesday, 31 August 2021 at 14:09:01 UTC, Steven Schveighoffer wrote: Are you sure this is the problem? `PdfSurface` is not a valid identifier here except for the class. In order to access the package, you need to use `cairo.PdfSurface`. Must've

Re: vibe.d: is it possible to use bare HTML with the functionalty of DIET templates ?

2021-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/30/21 8:09 PM, someone wrote: Regarding vibe.d I think I'll give it a try (maybe placing it behind nginx at first) since I do really got a good first-impression ... kudos to the developers/maintainers :) I like the idea of having D at my disposal within a web page, actually, it is a

Re: Module import incompatibility

2021-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/21 8:57 AM, frame wrote: On Tuesday, 31 August 2021 at 12:37:51 UTC, bauss wrote: On Tuesday, 31 August 2021 at 12:26:28 UTC, frame wrote: I'm sure it was asked before but can't find the thread: How to deal best with an older library that uses the same class name as module name? I

Re: SAOC 2021 Projects Summarized

2021-08-30 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/30/21 8:47 AM, Mike Parker wrote: Five projects have been selected for SAOC 2021. I've summarized them on the blog. I would like to point out that the quality of the applications this year was top-notch. Thanks to the applicants for putting in the effort. I hope they all put the same

Re: vibe.d community/forum/whatever ?

2021-08-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/29/21 10:39 PM, someone wrote: https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/ I've been reading vibe.d tour and some documentation today to get some first impressions. https://vibed.org/community pointed to the link above ... but it seems it is full of crap. It used

Re: Is it legal to remove a key from associative array while iterating over aa.keys if a foreach loop?

2021-08-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/29/21 5:02 AM, Mike Parker wrote: On Sunday, 29 August 2021 at 08:55:44 UTC, realhet wrote: Is it safe, or do I have to take a snapsot of the keys range like this? -> You shouldn't remove anything when iterating over `.keys` or `.values`. Use `.byKey` and `.byValue` instead to get

Re: [Video] How to set up D/Raylib project on MacOS, Linux and Windows

2021-08-28 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/28/21 9:41 AM, Ki Rill wrote: [Link](https://youtu.be/yIVHdaPTtcE) FYI, I've not had to link against those Macos frameworks when building against raylib, but possibly that's a new thing since 3.0.0. Thanks for the update! -Steve

Re: Beerconf August 2021

2021-08-27 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/14/21 5:54 PM, Steven Schveighoffer wrote: ## Wait, I have something important to say! If you have some topic you want to reserve time for, let me know. So far nobody has taken up this offer, but it's still here, keeps coming back every month. You can have a nice audience to present some

<    3   4   5   6   7   8   9   10   11   12   >