Re: Pointers - Is it safe to point to invalid memory?

2025-08-17 Thread Ali Çehreli via Digitalmars-d-learn
On 8/17/25 8:05 AM, Paul Backus wrote: > In C, it is UB to *create* an out-of-bounds pointer, *except* for a > pointer that is one element past the end of an array, which is allowed. > (Source: [C11 § 6.5.6 ¶ 8][1]) The intent of this exception is to allow > idioms like the one above. > > In D, m

Re: const objects

2025-08-17 Thread Dom DiSc via Digitalmars-d-learn
On Sunday, 17 August 2025 at 15:09:30 UTC, H. S. Teoh wrote: If you want to pass an immutable pointer to S2.this, you need to use `inout`: ```d struct S2 { int* my_x; this(inout(int)* x) inout { my_x = x; } } void main(string[] args) { immutable int i = 1; auto s2 = im

Re: dmd debug(level) Is it obsolete?

2025-08-17 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 17 August 2025 at 14:59:00 UTC, Brother Bill wrote: Page 462 of book: Programming in D This won't compile. Is this obsolete? ``` app.d(8,8): Error: identifier expected inside `debug(...)`, not `1` debug(1) writeln("entered myFunction"); ^ Yes, for rationale see: htt

Is there any tutorial on how to use the shared attribute on structs

2025-08-17 Thread solidstate1991 via Digitalmars-d-learn
I created a nogc array handler struct, and I would like to use it as a shared array. I can only easily find anything related to it for simple built-in types, let alone for slices. If at least I could use slices directly, it would be a great help (lock write access in a `synchronized` scope, t

Re: dmd debug(level) Is it obsolete?

2025-08-17 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
That was removed a while back. https://github.com/dlang/dmd/pull/20713

Re: Pointers - Is it safe to point to invalid memory?

2025-08-17 Thread monkyyy via Digitalmars-d-learn
On Sunday, 17 August 2025 at 15:05:32 UTC, Paul Backus wrote: In D, merely *creating* an out-of-bounds pointer is never UB The #wontfix list about the gc is labled as ub and is all about pointers(instead of #wontfix and documenting real issues); and this is a fundamental limitation of a gc t

Re: const objects

2025-08-17 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Aug 17, 2025 at 01:21:34PM +, Dom DiSc via Digitalmars-d-learn wrote: > If I do: > ```d > struct S1 > { >const int* my_x; >this(const int* x) { my_x = x; } > } > > struct S2 > { >int* my_x; >this(int* x) { my_x = x; } > } > > main() > { >immutable int i = 5; >

Re: Pointers - Is it safe to point to invalid memory?

2025-08-17 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 16 August 2025 at 22:28:15 UTC, Andy Valencia wrote: On Saturday, 16 August 2025 at 21:58:30 UTC, Paul Backus wrote: Creating a pointer that points out-of-bounds does not, by itself, result in undefined behavior. However, such a pointer would not be considered a [safe value][1],

dmd debug(level) Is it obsolete?

2025-08-17 Thread Brother Bill via Digitalmars-d-learn
Page 462 of book: Programming in D This won't compile. Is this obsolete? ``` app.d(8,8): Error: identifier expected inside `debug(...)`, not `1` debug(1) writeln("entered myFunction"); ^ source\app.d(10,8): Error: identifier expected inside `debug(...)`, not `2` debug(2) {

Re: dub -debug=tag for Windows

2025-08-17 Thread Brother Bill via Digitalmars-d-learn
On Sunday, 17 August 2025 at 14:17:42 UTC, 0xEAB wrote: On Sunday, 17 August 2025 at 14:15:37 UTC, 0xEAB wrote: Unless you provide `-debug` as well, you should not get identifier-less ones compiled in as well. ``` import std.stdio; void main() { writeln("foo"); debug writeln("bar");

Re: dub -debug=tag for Windows

2025-08-17 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 17 August 2025 at 14:15:37 UTC, 0xEAB wrote: Unless you provide `-debug` as well, you should not get identifier-less ones compiled in as well. ``` import std.stdio; void main() { writeln("foo"); debug writeln("bar"); debug(foobar) writeln("foobar"); } ``` As far as I ca

Re: dub -debug=tag for Windows

2025-08-17 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 17 August 2025 at 14:13:48 UTC, 0xEAB wrote: Any `-debug` switch will enable the compilation of identifier-less debug statements. Sorry, I was looking at the wrong output. Unless you provide `-debug` as well, you should not get identifier-less ones compiled in as well.

Re: dub -debug=tag for Windows

2025-08-17 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 17 August 2025 at 12:39:59 UTC, Brother Bill wrote: The goal is to only run debug(binarySearch), and not regular debug. How about giving the “regular” debug statement a named identifier as well? Any `-debug` switch will enable the compilation of identifier-less debug statements.

const objects

2025-08-17 Thread Dom DiSc via Digitalmars-d-learn
If I do: ```d struct S1 { const int* my_x; this(const int* x) { my_x = x; } } struct S2 { int* my_x; this(int* x) { my_x = x; } } main() { immutable int i = 5; S1 s = S1(&i); // works immutable S2 t = S2(&i); // fails } ``` Shoudn't S2 also work? It's immutable, so even if

dub -debug=tag for Windows

2025-08-17 Thread Brother Bill via Digitalmars-d-learn
Page 462 of Programming in D book. The goal is to only run debug(binarySearch), and not regular debug. Looking for the CLI for dub or dmd. Tried: dmd source/app.d -w -debug=binarySearch but it printed all the debug statements. What CLI command will get the job done? ``` import std.stdio; v

Re: Typed data frames in D

2025-08-17 Thread Marc via Digitalmars-d-learn
On Saturday, 16 August 2025 at 20:51:35 UTC, Dejan Lekic wrote: The only one I know is this one: https://github.com/navid-m/parallax This one looks good overall.

Re: Typed data frames in D

2025-08-17 Thread Dejan Lekic via Digitalmars-d-learn
On Saturday, 16 August 2025 at 20:40:50 UTC, Marc wrote: What features would you like to see in the data frame? Any ideas or feature request would be appreciated. https://github.com/istmarc/typeddataframe I forgot to mention - if I was to implement dataframes, I would read polars code, and c