Re: Forked GC explained

2022-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/3/22 9:35 AM, frame wrote: I'm not sure I fully understand how it works. I know that the OS creates read only memory pages for both and if a memory section is about to be written, the OS will issue a copy of the pages so any write operation will be done in it's own copy and cannot mess up

Re: Error while generate DNA with uniform()

2022-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/3/22 8:09 AM, Salih Dincer wrote: Hi All, We discovered a bug yesterday and reported it: https://forum.dlang.org/thread/mailman.1386.1662137084.31357.digitalmars-d-b...@puremagic.com You know, there is `generate()` depend to `std.range`. It created the error when we use it with the

raylib-d version 4.2.0 released!

2022-08-28 Thread Steven Schveighoffer via Digitalmars-d-announce
I just released version 4.2.0 of the [raylib-d binding](https://code.dlang.org/packages/raylib-d). [Release notes](https://github.com/schveiguy/raylib-d/releases/tag/v4.2.0): * Raylib binding now updated to reflect version 4.2.0 of the C library * Include new `validateRaylibBinding`

Re: D Language Foundation July 2022 Quarterly Meeting Summary

2022-08-28 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/28/22 6:37 AM, Mike Parker wrote: SARC has marked a major milestone in that their 500KLOC Extended Pascal codebase has been completely transcompiled to D This is awesome! I remember that talk, and it was very interesting. Congratulations! -Steve

Re: how to install the new dmd on Mac M1?

2022-08-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/25/22 11:50 PM, MichaelBi wrote: you are right, the package install is OK. but after running dub build --compiler=dmd, the error of "ld: library not found for - lssl" is still there... I've not had problems since updating to the M1, but my system was upgraded through many years, so I

Re: Beerconf August 2022

2022-08-25 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/10/22 11:46 AM, Steven Schveighoffer wrote: # BEERCONF! This month, following the actual dconf (which was amazing by the way, great job to everyone) and live beerconf (which I sadly missed), we will be having the online version on August 27-28, 2 weeks from this Saturday. Just

Re: how to install the new dmd on Mac M1?

2022-08-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/25/22 10:44 AM, MichaelBi wrote: On Thursday, 25 August 2022 at 14:37:01 UTC, Steven Schveighoffer wrote: On 8/25/22 10:19 AM, MichaelBi wrote: I downloaded the new dmd 2.1 on Mac, but with fail message of "unsupported Arch arm64". how can I do? thanks. DMD is x86 only. M1 ma

Re: how to install the new dmd on Mac M1?

2022-08-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/25/22 10:19 AM, MichaelBi wrote: I downloaded the new dmd 2.1 on Mac, but with fail message of "unsupported Arch arm64". how can I do? thanks. DMD is x86 only. M1 macs can run x86 via rosetta. I haven't had this specific problem. Can you list the actual commands you are running, and the

Re: How to escape control characters?

2022-08-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/23/22 6:09 AM, Bastiaan Veelo wrote: On Thursday, 31 March 2016 at 03:15:49 UTC, cy wrote: This might be a dumb question. How do I format a string so that all the newlines print as \n and all the tabs as \t and such? The easiest is this: ```d import std.conv; string str = `Hello "World"

Re: Is it possible to return mutable and const range from a single method?

2022-08-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/22/22 12:36 PM, realhet wrote: Hello, I managed to make a universal getParent() function which can preserve constness. I also had success with inout functions that work with this inout getParent method. Is it possible to do something like this but for the allParents input range producer

Re: typeof(func!0) != typeof(func!0())

2022-08-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/22/22 12:19 PM, Andrey Zherikov wrote: On Monday, 22 August 2022 at 15:20:46 UTC, Paul Backus wrote: On Monday, 22 August 2022 at 14:43:24 UTC, Andrey Zherikov wrote: But the question is still opened: why is `typeof(U().func!0)` not the same as `typeof(U().func!0())`? Probably because

Re: typeof(func!0) != typeof(func!0())

2022-08-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/22/22 8:04 AM, Paul Backus wrote: On Monday, 22 August 2022 at 11:24:59 UTC, Andrey Zherikov wrote: On Monday, 22 August 2022 at 06:01:11 UTC, JG wrote: Why not just change to: alias type = typeof(U().func!0()); This is user's code and `U().func!0` is legit syntax. Workaround: wrap it

Re: "Error: no property `offsetof` for type `char*`"

2022-08-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/19/22 12:36 PM, MyNameHere wrote: On Friday, 19 August 2022 at 14:30:50 UTC, kinke wrote: Oh and `DevicePath()` is a convenience member returning a pointer to the 'dynamic array' (as the array decays to a pointer in C too), so no need to fiddle with `.offsetof` and computing the pointer

Re: "Error: no property `offsetof` for type `char*`"

2022-08-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/19/22 9:49 AM, MyNameHere wrote: Thank you, that seems to have resolved the issue, though I wish these sorts of problems would stop cropping up, they are souring the experience with the language. Most likely that "member" is a macro in C. D doesn't have macros, so it uses properties.

Re: In-place extension of arrays only for certain alignment?

2022-08-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/18/22 1:16 AM, Ali Çehreli wrote: On 8/17/22 19:27, Steven Schveighoffer wrote: > On 8/17/22 10:09 PM, Ali Çehreli wrote: >>  > IIRC, your data does not need to be sequential in *physical memory*, >>  > which means you can use a ring buffer that is segmented instea

Re: In-place extension of arrays only for certain alignment?

2022-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/22 10:09 PM, Ali Çehreli wrote: > IIRC, your data does not need to be sequential in *physical memory*, > which means you can use a ring buffer that is segmented instead of > virtually mapped, and that can be of any size. I thought about that as well. But I would like the sizes of

Re: In-place extension of arrays only for certain alignment?

2022-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/22 2:40 PM, Ali Çehreli wrote: On 8/16/22 19:33, Steven Schveighoffer wrote: Using a 16-byte block sounds like a good strategy at first because nobody knows whether an array will get more than one element. However, if my guess is correct (i.e. the first element of size of 16-bytes

Re: Compile time int to string conversion in BetterC

2022-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/22 6:38 AM, Dennis wrote: On Wednesday, 17 August 2022 at 08:44:30 UTC, Ogi wrote: Maybe I’m missing something? I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof; ``` I have the same thing in my code: ```d enum intStr(int x) =

Re: In-place extension of arrays only for certain alignment?

2022-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/22 4:53 PM, Ali Çehreli wrote: On 8/16/22 12:31, Steven Schveighoffer wrote: > > No, it's based on 2 factors: > > 1. Is it a page-size-or-greater block? I assume the length of the new block. No, the length of the *existing* block. Everything in the memory allocator

Re: In-place extension of arrays only for certain alignment?

2022-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/22 2:11 PM, Ali Çehreli wrote: Related to my DConf 2022 lightning talk, I am noticing that D runtime's in-place array extension optimization is available only for array data that are at certain memory alignments. No, it's based on 2 factors: 1. Is it a page-size-or-greater block?

Re: How long will DUB update a package from github release?

2022-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/15/22 10:12 PM, Domain wrote: The project [Lumars](https://code.dlang.org/packages/lumars) has released a new version 10 days ago in [github](https://github.com/BradleyChatha/lumars). But still unavailable in DUB. It should be done automatically, but this has been an intermittent

Re: Programs in D are huge

2022-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/16/22 4:25 AM, Diego wrote: Hello everyone, I'm a Java programmer at work but i'm learning D for pleasure. I'm reading _The D Programming Language by Ali Çehreli_. I noticed that DMD creates very huge executable, for example an empty program: ``` empty.d: void main() { } ``` after

Re: DConf '22 Livestream Links -- Day 3 Video Links

2022-08-16 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/15/22 11:38 PM, zjh wrote: On Tuesday, 9 August 2022 at 18:01:13 UTC, Steven Schveighoffer wrote: ... No ppt? I did not do anything special, just used the youtube interface to link to specific points in the live stream. I assume at some point the slides and edited videos

Re: Array Wierdness

2022-08-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/10/22 11:26 AM, Ruby The Roobster wrote: On Wednesday, 10 August 2022 at 15:19:41 UTC, Ruby The Roobster wrote: Take the following code: ```d void main() {     shared class C { bool opEquals(const(shared(C)) rhs) const shared { return true;}}     const(C) c = new C();     const(C)[] a

Beerconf August 2022

2022-08-10 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Just when you thought you have had enough beerconf, here it comes again! I'm posting a bit early this month, because I'm going to be offline this weekend. This month, following the actual dconf (which was amazing by the way, great job to everyone) and live beerconf (which I

Re: Cast converts AA to rvalue?

2022-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/22 7:02 PM, Johan wrote: Testcase: ``` shared int[int] aa; void main () {     cast()aa[1] = 1; } ``` Up to dlang 2.097, this program runs and works fine. Since dlang 2.098, the program errors with: `core.exception.RangeError@/app/example.d(3): Range violation` I think the 2.098+

Re: DConf '22 Livestream Links -- Day 3 Video Links

2022-08-09 Thread Steven Schveighoffer via Digitalmars-d-announce
# Day 3 Video links to livestream 9:00 [Present and Future of the D Programming Language](https://dconf.org/2022/index.html#atilan) - Átila Neves [Video](https://youtu.be/ksNGwLTe0Ps?t=1712) 10:00 [A D Language Backend for GNU Bison](https://dconf.org/2022/index.html#adelav) - Adela Vais

Re: Acess variable that was set by thread

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 4:04 PM, ag0aep6g wrote: On Monday, 8 August 2022 at 19:33:14 UTC, Steven Schveighoffer wrote: There's nothing clever. If you want to access C globals, you should use `__gshared`, because that's what it is. Using `shared`, isn't going to save you at all. Yes, using `shared` does

Re: Acess variable that was set by thread

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 10:54 AM, ag0aep6g wrote: On Monday, 8 August 2022 at 14:29:43 UTC, Steven Schveighoffer wrote: C has no notion of shared, so it's not the right type. Putting `shared` on it is kind of lying, and can lead to trouble. Better to be explicit about what it is. Nonsense. Putting `shared

Re: Acess variable that was set by thread

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 10:12 AM, ag0aep6g wrote: On Monday, 8 August 2022 at 13:31:04 UTC, Steven Schveighoffer wrote: On 8/8/22 6:17 AM, ag0aep6g wrote: [...] Never ever use `__gshared` ever. It's a glaring safety hole. Use `shared` instead. If you are interfacing with C, you need __gshared. But yeah

Re: How do I initialize a templated constructor?

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 9:36 AM, Steven Schveighoffer wrote: On 8/8/22 1:38 AM, rempas wrote: In the following struct (as an example, not real code): ``` struct TestArray(ulong element_n) {    int[element_n] elements;    this(string type)(ulong number) { pragma(msg, "The type is: " ~ t

Re: How do I initialize a templated constructor?

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 1:38 AM, rempas wrote: In the following struct (as an example, not real code): ``` struct TestArray(ulong element_n) {   int[element_n] elements;   this(string type)(ulong number) {     pragma(msg, "The type is: " ~ typeof(type).stringof);   } } ``` I want to create it and be

Re: Fix template parameter

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 8:02 AM, Dom Disc wrote: Hello. I found in the documentation functions declared like this: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` What is the difference to declaring it like: ```D pure @nogc @safe BigInt opAssign(BigInt x); ``` To me the first declaration seems

Re: Acess variable that was set by thread

2022-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/22 6:17 AM, ag0aep6g wrote: On Monday, 8 August 2022 at 07:14:33 UTC, vc wrote: it seems change it to working is working ```d  __gshared bool zeus;  ``` but as I'm new in to D, i will like to hear thoughts even if it works for me Never ever use `__gshared` ever. It's a glaring

Re: Acess variable that was set by thread

2022-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/22 9:36 PM, vc wrote: Hello, i have the following code, the flora contains a boolean zeus in the DerivedThread the boolean zeus was set to true; but when i'm trying to access it outside the thread in main it returns me false; any thoughts ? is zeus declared just as: ```d bool zeus;

Re: Main foreach loop fails when another foreach is added

2022-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/22 10:11 PM, ikelaiah wrote: Hi, I'm writing a program that reads a text file and launch my work URLs in it. It worked fine, and very happy. Then I added another `foreach` loop to count total number of lines. After this, the main `foreach` won't work. Does anyone know as to why this

Re: importC | Using D with Raylib directly | No bindings | [video]

2022-08-07 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/6/22 9:09 PM, Ki Rill wrote: Testing out importC with Raylib. Here is the [link](https://www.youtube.com/watch?v=1BrvRkZdGOA). Really nice demonstration! I lament the fact that you have to declare C variables just to get access to the #define colors. Also, IIRC, in the latest master

Re: Giving up

2022-08-06 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/6/22 8:59 PM, mw wrote: On Sunday, 7 August 2022 at 00:54:35 UTC, Steven Schveighoffer wrote: Note, we have a complete copy of the git repository. So you mean all the dub registered packages are cached somewhere? Can we publish the cache address? I don't know how it's done. It's

Re: Giving up

2022-08-06 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 10:40 PM, bachmeier wrote: On Friday, 5 August 2022 at 18:29:46 UTC, mw wrote: On Friday, 5 August 2022 at 17:56:47 UTC, bachmeier wrote: Here's the code if anyone is relying on it: https://github.com/bachmeil/decimal/tree/main I really think DUB should save a copy of all the files

Re: More fun with toStringz and the GC

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 8:51 PM, Don Allen wrote: And this, from Section 32.2 of the Language Reference Manual: If pointers to D garbage collector allocated memory are passed to C functions, it's critical to ensure that the memory will not be collected by the garbage collector before the C function is

Re: More fun with toStringz and the GC

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 7:13 PM, jfondren wrote: On Friday, 5 August 2022 at 22:51:07 UTC, Don Allen wrote: My theory: because gc_protect2 is never referenced, I'm guessing that the compiler is optimizing away the storage of the returned pointer, the supporting evidence being what I said in the previous

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/5/22 3:53 PM, frame wrote: On Friday, 5 August 2022 at 15:24:16 UTC, Steven Schveighoffer wrote: oof, I expected this to include the template parameters! I believe it normally does? This is a bug that should be filed. -Steve Sorry, I don't get what you takling about? The docs says

Re: Giving up

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 12:48 PM, Rumbu wrote: On Friday, 5 August 2022 at 16:37:56 UTC, Steven Schveighoffer wrote: I don't think that code ever built. Possibly you didn't test it properly originally. But if you are done with it, I guess it doesn't matter. Thank you for this. Deleted since everything

Re: Giving up

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 12:30 PM, Rumbu wrote: On Friday, 5 August 2022 at 16:08:50 UTC, Steven Schveighoffer wrote: Just saying, I see an integer. That's an integer according to the language (as far back as I can test, which is 2.060 released 2012). If that was somehow parsing as a float before

Re: Giving up

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 11:57 AM, React wrote: On Friday, 5 August 2022 at 15:44:10 UTC, Steven Schveighoffer wrote: On 8/5/22 11:36 AM, Rumbu wrote: float z = 85886696878585969769557975866955695.E0; //integer overflow, I don't see any int That's an integer, which is trying to call a UFCS function named

Re: Giving up

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-announce
On 8/5/22 11:36 AM, Rumbu wrote: float z = 85886696878585969769557975866955695.E0; //integer overflow, I don't see any int That's an integer, which is trying to call a UFCS function named `E0`. Did you mean to include the `.`? -Steve

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/5/22 11:24 AM, Steven Schveighoffer wrote: On 8/4/22 10:27 PM, jfondren wrote:  a.opOpAssign(b);  b.opOpAssign(a); oof, I expected this to include the template parameters! I believe it normally does? It does not! I'm genuinely shocked. ```d void foo(string s, T)(T t) {} void

Re: Unittest Absurdity

2022-08-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/22 10:27 PM, jfondren wrote: The output's not that useful... ```d import object; struct S { int n; void opOpAssign(string op)(S rhs) if (op == "/=") {     n++; } void opOpAssign(string op)(S rhs) if (op == "/") { } } unittest { S a = S(1);   

Re: Unittest Absurdity

2022-08-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/4/22 9:51 PM, Paul Backus wrote: On Friday, 5 August 2022 at 01:47:07 UTC, Ruby The Roobster wrote: I found the issue:  opOpAssign isn't getting called at all.  I have no idea why, though. Given that the example works, the problem must be in some other part of your code that you

Re: DConf '22 Livestream Links -- Day 2 Video Links

2022-08-04 Thread Steven Schveighoffer via Digitalmars-d-announce
# Day 2 Video links to livestream 9:00 [Lua and Pallene](https://dconf.org/2022/index.html#robertoi) - Roberto Ierusalimschy [Video](https://youtu.be/04gJXpJ1i8M?t=1711) 10:00 [Atomic Variables: Not radioactive, but you probably still don't want to touch

Re: DConf '22 Livestream Links

2022-08-02 Thread Steven Schveighoffer via Digitalmars-d-announce
Figured someone should do this. I'll do day 2 later (unless someone else beats me to it). # Day 1 links to livestream 9:00 [Strawberries and Cream, a.k.a. Delightful Emergent Properties of D](https://dconf.org/2022/index.html#walterb) - Walter Bright [Video](https://youtu.be/V6KFtzF2Hx8?t=0)

Re: Converting JSONValue to AssociativeArray.

2022-08-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/1/22 2:00 PM, hype_editor wrote: I need to convert variable of type `JSONValue` to variable of type `string[string]` (AssociativeArray). ```d import std.json : JSONValue; import std.stdio : writefln; void main() {     JSONValue data = parseJSON(`{ "name": "Hype Editor", "hobby":

Re: Expanding CTFE code during compilation

2022-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/22 2:27 PM, Azi Hassan wrote: On Saturday, 23 July 2022 at 00:56:39 UTC, Steven Schveighoffer wrote: On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) { version(debug

Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 2:34 PM, Ben Jones wrote: Can you elaborate on why it's probably OK in practice? Because the GC deals with interior pointers just fine. Blocks with the "no interior" bit set are very rare, and for only specialized use, so normally this should not be a problem. I have argued in

Re: Expanding CTFE code during compilation

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {     enum printEnum(alias x) = x;     } } ``` But I like yours better.

Re: OK to do bit-packing with GC pointers?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 12:50 PM, Ben Jones wrote: I'm looking to store a pointer to one of 2 unrelated (no inheritance relationship) classes and use the LSb to track which type I have.  Is this going to cause any problems with the GC? For one of the classes I'll have a "pointer" to 1 byte past the start

Re: mixin template bug with opBinary?

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 8:33 AM, Anthony Quizon wrote: Hello, I'm trying to create a mixin for quick binary operator overloads by passing in types with a corresponding associative array of strings to functions. However, the code I currently have: ``` module foo; mixin template opBi(     A, A

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 8:57 PM, Steven Schveighoffer wrote: There's a slight bloat in the compiler symbol table when  but other than that it should be effective. Obviously I didn't finish that thought... "when `-debug` isn't used on the command line" -Steve

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 8:33 PM, Azi Hassan wrote: Nice, a compile time console.log. Thanks a lot, this will come in handy. I wonder if it can be combined with version(debug) to only run the pragma line if compiled with -g, this way we can keep the printEnum! line as it is. Then again, the code would

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 5:43 PM, Azi Hassan wrote: Just in case this is a consequence of the XY problem, the reason why I'm looking for this is to make sure that the code I wrote did evaluate to what I'm expecting it to. Right now I do this with an enum assignment followed by static asserts, but I'd love

Re: File.write introduces \r regardless of presence

2022-07-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 16 July 2022 at 20:46:00 UTC, HuskyNator wrote: is raises 3 questions for me. 1. Are there any nasty pitfalls with this change that might force me to find a workaround? (eg. en/decoding issues or the like?) This is strictly a C mechanism, and only on Windows. So refer to the C

Re: null == "" is true?

2022-07-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 15 July 2022 at 06:38:58 UTC, Salih Dincer wrote: Consider null type array which is a related topic but it cannot get a null element! The first is ok, but the second is legal. So no effect, is it normal? ```d auto p = [ null, null ];//* assert( is(typeof(null)[] :

Re: Beerconf July 2022

2022-07-14 Thread Steven Schveighoffer via Digitalmars-d-announce
On Saturday, 2 July 2022 at 19:52:28 UTC, Steven Schveighoffer wrote: # BEERCONF! So this month is going to be a bit different. We are going to have beerconf *early*! It's like early Christmas, but with beer instead of presents! The reason for the early date is that the normal end

Re: null == "" is true?

2022-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/22 4:36 PM, Antonio wrote: On Tuesday, 12 July 2022 at 18:56:43 UTC, Paul Backus wrote: On Tuesday, 12 July 2022 at 16:40:38 UTC, H. S. Teoh wrote: Because an empty string is, by default, represented by an empty slice of the null pointer. Do not rely on this, however; it's possible

Re: null == "" is true?

2022-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/22 12:40 PM, H. S. Teoh wrote: Because an empty string is, by default, represented by an empty slice of the null pointer. No, it's not a null pointer. It's a pointer to a zero-character. But it is indeed an empty slice. -Steve

Re: null == "" is true?

2022-07-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/12/22 12:27 PM, Antonio wrote: It works ```d void main() {    assert(null==""); } ``` why? A string is not exactly a reference type. It's a length and a pointer. This can be confusing to newcomers, especially ones that come from languages that treat arrays and strings as object

Re: Is there any implementation of a 128bit integer?

2022-07-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/22 8:19 PM, Era Scarecrow wrote: On Friday, 8 July 2022 at 15:32:44 UTC, Rob T wrote: https://forum.dlang.org/post/mailman.10914.1566237225.29801.digitalmars-d-le...@puremagic.com In case someone comes across this old thread https://dlang.org/phobos/core_int128.html There was a

Re: Calling readln() after readf

2022-07-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/5/22 8:14 PM, Gary Chike wrote: On Monday, 20 June 2022 at 16:08:33 UTC, Ali Çehreli wrote: On 6/20/22 07:00, Gary Chike wrote: > Would it be appropriate to forego `readf` > and read input as a string using `readln` ,benefiting from the `strip` > function, then convert to their

Beerconf July 2022

2022-07-02 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! So this month is going to be a bit different. We are going to have beerconf *early*! It's like early Christmas, but with beer instead of presents! The reason for the early date is that the normal end-of-the-month date would be just before real dconf (literally one day before).

Re: ePub/Mobi/AZW3/PDF of Phobos Runtime Library

2022-06-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/28/22 2:42 PM, Marcone wrote: I love programming in D. D is my favorite programming language. I'm not a professional programmer, but I love to program. I would like to learn D deeply. Most programming languages have a PDF/CHM/MOBI/ePub version of the standard library. But D still doesn't

Re: int | missing | absent

2022-06-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/27/22 9:03 AM, Antonio wrote: On Wednesday, 22 June 2022 at 01:09:22 UTC, Steven Schveighoffer wrote: On 6/2/22 9:24 AM, bauss wrote: I feel it's too loose to make a best effort, and leave the rest up to initial values, or just ignore possibly important information during parsing

Re: Beerconf June 2022

2022-06-23 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/12/22 2:06 PM, Steven Schveighoffer wrote: # BEERCONF! This month we are celebrating 2 years of monthly online beerconf. That's right, 2 years ago in June 2020 was the first time we started this, when live dconf was supposed to happen, but was canceled. We've had one every month since

Re: int | missing | absent

2022-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/22 11:20 AM, Jesse Phillips wrote: On Wednesday, 22 June 2022 at 01:09:22 UTC, Steven Schveighoffer wrote: There are 3 situations: 1. field in json and struct. Obvious result. 2. field in json but not in struct. 3. field in struct but not in json. I do a lot of reading JSON data

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-23 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/23/22 8:14 AM, Kagamin wrote: On Wednesday, 22 June 2022 at 20:48:13 UTC, Steven Schveighoffer wrote: Sometimes algorithms require manipulation of structure, such as sorting arrays, or using linked lists, and sometimes it's nice to be able to point at things on the stack, temporarily

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-23 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/23/22 8:01 AM, Dukc wrote: On Thursday, 23 June 2022 at 00:37:24 UTC, Steven Schveighoffer wrote: You mean like a system function which removes the scope-ness of an array? Let me introduce you to my other thread: https://forum.dlang.org/thread/t7qd45$1lrb$1...@digitalmars.com You

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/22/22 5:44 PM, Dukc wrote: On Wednesday, 22 June 2022 at 21:07:50 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 June 2022 at 20:48:13 UTC, Steven Schveighoffer wrote: The part about `scope` being shallow. This is a problem. One thing that will be confusing to most users

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/22/22 5:58 PM, Dukc wrote: On Wednesday, 22 June 2022 at 20:48:13 UTC, Steven Schveighoffer wrote: On 6/21/22 11:05 AM, Mike Parker wrote: The part about `scope` being shallow. This is a problem. Is there any plan to address this other than "just use `@system`"? I thin

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/22/22 5:07 PM, Ola Fosheim Grøstad wrote: On Wednesday, 22 June 2022 at 20:48:13 UTC, Steven Schveighoffer wrote: The part about `scope` being shallow. This is a problem. One thing that will be confusing to most users is that it appears to be using "taint" rather than p

Re: DIP1000: Memory Safety in a Modern System Programming Language Pt.1

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-announce
On 6/21/22 11:05 AM, Mike Parker wrote: Ate Eskola was inspired to write a series of tutorials about DIP1000 for the D Blog. The first post in the series is live. If you haven't yet dug into DIP1000 much or understood how to use it, this should give you enough to get started. The blog:

Re: nested function overloading

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/22/22 2:05 AM, monkyyy wrote: On Monday, 20 June 2022 at 13:20:51 UTC, Steven Schveighoffer wrote: And you can also use an inner struct to define overloaded functions. I believe templates make a better bandaid ```d void main(){ template bar(){     void bar_(int){}     void

Re: int | missing | absent

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/2/22 9:24 AM, bauss wrote: On Thursday, 2 June 2022 at 08:27:32 UTC, Antonio wrote: JSON properties can be - a value - null - absent What's the standard way to define a serialziable/deserializable structs supporting properties of any of this 4 kinds?: * int * int | null * int | absent

Re: destroy and @safe

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 1:33 PM, H. S. Teoh wrote: On Tue, Jun 21, 2022 at 01:29:47PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: ```d void foo(void delegate() @system dg) @safe { int *bar; @system void corrupt() { bar = cast(int *)0xdeadbeef;} dg = // can I call dg now

Re: Better way to achieve the following

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 1:19 PM, JG wrote: On Tuesday, 21 June 2022 at 17:15:02 UTC, Steven Schveighoffer wrote: On 6/21/22 1:09 PM, JG wrote: Thoughts? Use a pointer? Especially if you are using `.method` calls, this just works seamlessly. Thanks for the suggestion.  My immediate reaction

Re: destroy and @safe

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 1:17 PM, H. S. Teoh wrote: On Tue, Jun 21, 2022 at 04:47:44PM +, Antonio via Digitalmars-d-learn wrote: On Tuesday, 21 June 2022 at 16:20:32 UTC, Antonio wrote: My code starts to be a @safe/@trusted mess (because external libraries). The only solution I have is to "wrap" them

Re: Better way to achieve the following

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 1:09 PM, JG wrote: Thoughts? Use a pointer? Especially if you are using `.method` calls, this just works seamlessly. -Steve

Re: destroy and @safe

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 12:33 PM, Antonio wrote: On Tuesday, 21 June 2022 at 15:14:43 UTC, Steven Schveighoffer wrote: You delegate doesn't seem to be marked @safe as well. Thanks a lot Steve, I didn't found a way (or example) to specify the delegate must be @safe until I have found

Re: destroy and @safe

2022-06-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/21/22 10:40 AM, Antonio wrote: I'm using explicitly destroy!false(obj) for a "deterministic" resources release. I replicate the c# "using" pattern, or the python "with" pattern with my own "use" template supposing object are RAII i.e.: ```d Item[] items = query("...").use( (Answer a)

Re: std.conv.to

2022-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/22 8:48 AM, harakim wrote: On Friday, 17 June 2022 at 12:31:45 UTC, harakim wrote: I can generically convert a string to a type using to!type. I have a read function that does that. I have simplified the example below: ```d int readNumber() {     return read!int(val =>

Re: nested function overloading

2022-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/22 8:09 AM, Chris Katko wrote: I don't need this functionality, but I wanted to be sure. Does function overloading not work with nested functions? I got a compiler error (something like "function already defined") when I tried it. Correct, it's not allowed. However, you can define a

Re: Comparing Exceptions and Errors

2022-06-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/16/22 6:07 AM, kdevel wrote: On Wednesday, 15 June 2022 at 20:46:56 UTC, Steven Schveighoffer wrote: [...] It has not harmed my code though. I tried throwing inside a scope guard, and it just works, I'm not sure why you can't throw in those? You can but that is not acceptable

Re: Comparing Exceptions and Errors

2022-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/22 3:51 PM, kdevel wrote: On Wednesday, 15 June 2022 at 03:09:56 UTC, Steven Schveighoffer wrote: I don't see what you see wrong with the code I wrote. It's straightforward, obvious, and does the job I need it to do, in a way that's not prone to future mistakes. Sometimes

Re: Comparing Exceptions and Errors

2022-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
I don't see what you see wrong with the code I wrote. It's straightforward, obvious, and does the job I need it to do, in a way that's not prone to future mistakes. I explained why, but you don't agree with the explanation. That's OK, we don't all have to write the same exact systems. D is a

Re: Bug?

2022-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/22 3:35 PM, JG wrote: Hi, Is this a bug? ```d import std; template test(alias f) {     auto test(I)(I i) { return f(i); } } void main() {     alias t = test!(x=>x+1);     1.t.writeln; //<--Doesn't compile     1.test!(x=>x+1).writeln;     t(1).writeln; } ``` Not a bug. Local

Re: Failure due to memcpy being called at compile time

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/22 4:09 PM, JG wrote: Thanks. It seems to be something to do with the variadic template since this works: ```d import std; struct ParseError { string msg; } alias ParseErrorOr(T) = SumType!(ParseError,T); auto parseErrorOr(T)(T x) { return ParseErrorOr!T(x); } auto parserOr(I,alias

Re: Failure due to memcpy being called at compile time

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/22 3:48 PM, JG wrote: Hi, I reduced my code to the following.  Could anyone help me to discover why the line marked with //THIS LINE causes memcpy to be called, and how can I avoid this? ```d import std; struct ParseError { string msg; } alias ParseErrorOr(T) =

Re: Dynamic chain for ranges?

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/22 9:44 AM, Ola Fosheim Grøstad wrote: On Monday, 13 June 2022 at 13:22:52 UTC, Steven Schveighoffer wrote: I would think sort(joiner([arr1, arr2, arr3])) should work, but it's not a random access range. Yes, I got the error «must satisfy the following constraint: isRandomAccessRange

Re: Comparing Exceptions and Errors

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/22 9:15 AM, Steven Schveighoffer wrote: Yes. If you don't execute the rollback and start executing more DB calls, they all get included in the transaction (and might be expected to be). Should have said "might *not* be expected to be" -Steve

Re: Dynamic chain for ranges?

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/13/22 4:51 AM, Ola Fosheim Grøstad wrote: Is there a dynamic chain primitive, so that you can add to the chain at runtime? Context: the following example on the front page is interesting. ```d void main() {     int[] arr1 = [4, 9, 7];     int[] arr2 = [5, 2, 1, 10];     int[] arr3 =

Re: Comparing Exceptions and Errors

2022-06-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/22 4:11 PM, kdevel wrote: On Tuesday, 7 June 2022 at 18:37:13 UTC, Steven Schveighoffer wrote: [...] My very common use of `scope(failure)` for my DB code: ```d conn.exec("START TRANSACTION"); scope(success) conn.exec("COMMIT"); scope(failure)

Beerconf June 2022

2022-06-12 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! This month we are celebrating 2 years of monthly online beerconf. That's right, 2 years ago in June 2020 was the first time we started this, when live dconf was supposed to happen, but was canceled. We've had one every month since! The dates are June 25-26. We will post a

<    1   2   3   4   5   6   7   8   9   10   >