Re: opApply Magic Function Body Transformation

2025-07-31 Thread Mike Shah via Digitalmars-d-learn
On Monday, 28 July 2025 at 19:28:54 UTC, Mike Shah wrote: On Monday, 28 July 2025 at 18:57:27 UTC, kinke wrote: On Monday, 28 July 2025 at 14:28:57 UTC, Mike Shah wrote: Is there somewhere already in LDC2 where I can dump out the generated transformation (Otherwise I can probably read the IR w

Re: Non-static foreach on tupleof has no UDAs?

2025-07-31 Thread monkyyy via Digitalmars-d-learn
On Thursday, 31 July 2025 at 11:29:41 UTC, IchorDev wrote: I'd much prefer if the above code worked rather than having to do this: ```d static foreach(i; 0..a.tupleof.length){ pragma(msg, __traits(getAttributes, a.tupleof[i])); //AliasSeq!(y(10)) } ``` That verbosity is unnecessary to swap

Non-static foreach on tupleof has no UDAs?

2025-07-31 Thread IchorDev via Digitalmars-d-learn
How come doing a `foreach` on `.tupleof` causes ` __traits(getAttributes` to return nothing? Is it because it creates a new 'symbol'? Is this a bug? ```d struct y{ int z; } struct X{ @y(z: 10) string x; } void main(){ X a; foreach(b; a.tupleof){

Re: How to use D on M2 macOS?

2025-07-31 Thread IchorDev via Digitalmars-d-learn
On Monday, 21 July 2025 at 17:21:58 UTC, Albert wrote: Though I do think D could do so much better with onboarding first time users... I think it's not entirely fair to say that, given that your issue was mostly that (1) you downloaded a compiler that doesn't fully support your native CPU arc

Re: How to use D on M2 macOS?

2025-07-31 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 23 July 2025 at 14:12:30 UTC, Brian Callahan wrote: On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how

Re: fread return value?

2025-07-30 Thread Andy Valencia via Digitalmars-d-learn
On Wednesday, 30 July 2025 at 20:03:37 UTC, 0xEAB wrote: On Wednesday, 30 July 2025 at 19:45:20 UTC, Andy Valencia wrote: but I'd like to understand what's up before just changing my code to assume 0 is a success value? AFAICT your code is wrong. The parameters of `fread()` are `ptr`, `size`,

Re: fread return value?

2025-07-30 Thread Ali Çehreli via Digitalmars-d-learn
On 7/30/25 12:45 PM, Andy Valencia wrote: > Scratching my head here. fread() I haven't used anything other than rawRead() for that purpose. rawRead() returns a slice of what it's just read: import std.algorithm; import std.exception; import std.file; import std.format; import std.stdio; void

Re: fread return value?

2025-07-30 Thread 0xEAB via Digitalmars-d-learn
On Wednesday, 30 July 2025 at 19:45:20 UTC, Andy Valencia wrote: but I'd like to understand what's up before just changing my code to assume 0 is a success value? AFAICT your code is wrong. The parameters of `fread()` are `ptr`, `size`, `n`, `stream`. Your code is attempting to read `1` unit wi

Re: fread return value?

2025-07-30 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 30 July 2025 at 19:45:20 UTC, Andy Valencia wrote: Scratching my head here. fread() really appears to be the standard C idea of an fread(), so it returns a count. Instead, it returns 0. The buf[] does indeed have the expected content, but I'd like to understand what's up before

fread return value?

2025-07-30 Thread Andy Valencia via Digitalmars-d-learn
Scratching my head here. fread() really appears to be the standard C idea of an fread(), so it returns a count. Instead, it returns 0. The buf[] does indeed have the expected content, but I'd like to understand what's up before just changing my code to assume 0 is a success value? (Linux,

Re: Programming in D, page 155. shared static this() fails

2025-07-30 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 30 July 2025 at 18:00:39 UTC, H. S. Teoh wrote: On Wed, Jul 30, 2025 at 10:54:15AM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: [...] immutable int[] i; shared static this() { immutable(int)[] temp; temp ~= foo(); temp ~= bar(); i = temp; } But even the

Re: Programming in D, page 155. shared static this() fails

2025-07-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 30, 2025 at 10:54:15AM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: [...] > immutable int[] i; > > shared static this() > { > immutable(int)[] temp; > temp ~= foo(); > temp ~= bar(); > i = temp; > } > > But even the shared

Re: Programming in D, page 155. shared static this() fails

2025-07-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 29, 2025 5:18:18 PM Mountain Daylight Time Brother Bill via Digitalmars-d-learn wrote: > Your changes do work, but at the cost of making i NOT deeply > immutable: no assignment, no changing any elements, no appending, > no setting length. This syntax permits appe

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:48:58 UTC, H. S. Teoh wrote: `i` is immutable, so it's illegal to use mutating operations like ~= on it. @luna The question should be if programming in d (page 177 https://ddili.org/ders/d.en/Programming_in_D.pdf) should be authoritive here It is possible t

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 29, 2025 at 10:57:50PM +, Brother Bill via Digitalmars-d-learn wrote: > ``` > import std.stdio; > > immutable int[] i; > > shared static this() { > writeln("In shared static this()"); > i ~= 43; > } `i` is immutable, so it'

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread Luna via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 22:57:50 UTC, Brother Bill wrote: ``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\w

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:18:18 UTC, Brother Bill wrote: Your changes do work, but at the cost of making i NOT deeply immutable: no assignment, no changing any elements, no appending, no setting length. if you insit on the type id suggest this code then ```d import std.stdio; immutabl

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread Brother Bill via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:03:41 UTC, monkyyy wrote: On Tuesday, 29 July 2025 at 22:57:50 UTC, Brother Bill wrote: ``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()");

Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 22:57:50 UTC, Brother Bill wrote: ``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\w

Programming in D, page 155. shared static this() fails

2025-07-29 Thread Brother Bill via Digitalmars-d-learn
``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\internal\array\appe

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 21:47:05 UTC, not monkyyy wrote: Who are you?

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 20:34:27 UTC, Nick Treleaven wrote: On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: On Monday, 28 July 2025 at 11:18:48 UTC, Nick Treleaven wrote: The solution I offered at the time while still fundamentally flawed was far more robust then what was merged W

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread not monkyyy via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: The solution I offered at the time while still fundamentally flawed was far more robust Sounds a lot like… Whack-a-moleing

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: On Monday, 28 July 2025 at 11:18:48 UTC, Nick Treleaven wrote: The solution I offered at the time while still fundamentally flawed was far more robust then what was merged What solution?

Re: Class-Inheritancing Error

2025-07-28 Thread David T. Oxygen via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:02:45 UTC, H. S. Teoh wrote: On Sun, Jul 27, 2025 at 05:02:35PM +, user1234 via Digitalmars-d-learn wrote: [...] Simply because because if OP writes ``` class Person{ string name; this(string name){this.name=name;} } class Someone:Person{ } void main

workarounds for foreach limitations

2025-07-28 Thread monkyyy via Digitalmars-d-learn
still want this: https://forum.dlang.org/thread/lmvyzfatklcvrijcy...@forum.dlang.org I dont think it will magicly appear in a few hours but maybe someone wants to write the templated opApply code some active code: ```d auto takewhilecmp(string op="<",R,T)(R r,ref T senti){ struct ran

Re: opApply Magic Function Body Transformation

2025-07-28 Thread Mike Shah via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:57:27 UTC, kinke wrote: On Monday, 28 July 2025 at 14:28:57 UTC, Mike Shah wrote: Is there somewhere already in LDC2 where I can dump out the generated transformation (Otherwise I can probably read the IR well enough)? Yeah I'm afraid the IR is probably the best

Re: opApply Magic Function Body Transformation

2025-07-28 Thread kinke via Digitalmars-d-learn
On Monday, 28 July 2025 at 14:28:57 UTC, Mike Shah wrote: Is there somewhere already in LDC2 where I can dump out the generated transformation (Otherwise I can probably read the IR well enough)? Yeah I'm afraid the IR is probably the best source. LDC's `-vv` verbose codegen output would show

Re: Cannot instantiate ReturnType with lambda

2025-07-28 Thread monkyyy via Digitalmars-d-learn
On Monday, 28 July 2025 at 11:18:48 UTC, Nick Treleaven wrote: In Phobos 3 `isCallable` will likely be replaced. I think when it was made to support some templates with `!()`, that muddied the waters. Whack-a-moleing; you guys do that allot The solution I offered at the time while still fun

Re: Class-Inheritancing Error

2025-07-28 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 27, 2025 at 05:02:35PM +, user1234 via Digitalmars-d-learn wrote: [...] > Simply because because if OP writes > > ``` > class Person{ > string name; > this(string name){this.name=name;} > } > class Someone:Person{ > } > void main(){ &g

Re: opApply Magic Function Body Transformation

2025-07-28 Thread Mike Shah via Digitalmars-d-learn
On Monday, 28 July 2025 at 12:25:39 UTC, kinke wrote: On Monday, 28 July 2025 at 04:39:00 UTC, Mike Shah wrote: [...] I think that's where the confusion comes from, that misleading `-vcg-ast` output for the loop-body-lambda, apparently printed as `… => 0` regardless of the actual loop body.

Re: extern(C) on var decl is confusing

2025-07-28 Thread user1234 via Digitalmars-d-learn
On Monday, 28 July 2025 at 11:06:40 UTC, kinke wrote: On Sunday, 27 July 2025 at 23:23:40 UTC, user1234 wrote: That is confusing It affects the mangling of global vars, just like functions. ah indeed

Re: opApply Magic Function Body Transformation

2025-07-28 Thread kinke via Digitalmars-d-learn
On Monday, 28 July 2025 at 04:39:00 UTC, Mike Shah wrote: **So really my one concrete question is** -- can I see main.main()__foreachbody_L21_C3(ref int) anywhere? I think that's where the confusion comes from, that misleading `-vcg-ast` output for the loop-body-lambda, apparently printed as

Re: Cannot instantiate ReturnType with lambda

2025-07-28 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 26 July 2025 at 23:08:35 UTC, luafyn wrote: Why doesn't this work? ```d import std; struct Optional(T) { T value; bool hasValue; } auto map(alias fn, T)(Optional!T m) { alias U = ReturnType!fn; In this case, an untyped function literal (`it => 123`) is actually a te

Re: extern(C) on var decl is confusing

2025-07-28 Thread kinke via Digitalmars-d-learn
On Sunday, 27 July 2025 at 23:23:40 UTC, user1234 wrote: That is confusing It affects the mangling of global vars, just like functions.

Re: extern(C) on var decl is confusing

2025-07-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 27, 2025 5:23:40 PM Mountain Daylight Time user1234 via Digitalmars-d-learn wrote: > That is confusing, e.g > > ``` > extern(C) int r; > > int main() > { > return r; > } > ``` > > works. But what is likely more intended here is

opApply Magic Function Body Transformation

2025-07-27 Thread Mike Shah via Digitalmars-d-learn
I'm preparing a video to teach opApply, and I think I'm still kind of unsure on how opApply works in regards to the compiler transformation. It's one of those features I understand how to use, but I'd like a bit of a deeper understanding before I teach it -- to admittingly really know what I am

extern(C) on var decl is confusing

2025-07-27 Thread user1234 via Digitalmars-d-learn
That is confusing, e.g ``` extern(C) int r; int main() { return r; } ``` works. But what is likely more intended here is ``` extern int r; int main() { return r; } ``` which leads, this time, to the expected linker error.

Re: Class-Inheritancing Error

2025-07-27 Thread user1234 via Digitalmars-d-learn
On Sunday, 27 July 2025 at 15:14:03 UTC, H. S. Teoh wrote: On Sun, Jul 27, 2025 at 11:08:33AM +, David T. Oxygen via Digitalmars-d-learn wrote: I wrote a piece of code like this: ```d class Person{ string name; this(string name){this.name=name;} } class Someone:Person

Re: Class-Inheritancing Error

2025-07-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 27, 2025 at 11:08:33AM +, David T. Oxygen via Digitalmars-d-learn wrote: > I wrote a piece of code like this: > > ```d > class Person{ > string name; > this(string name){this.name=name;} > } > class Someone:Person{ > alias

Re: Inherited constructor

2025-07-27 Thread Luna Nielsen via Digitalmars-d-learn
On Friday, 25 July 2025 at 03:57:34 UTC, Andy Valencia wrote: On Friday, 25 July 2025 at 02:40:35 UTC, H. S. Teoh wrote: In D, constructors are not inherited, so yes, unfortunately you have to write a forwarding ctor that passes the arguments along to the base class. My OO worldview goes bac

Re: How do I pass a variables as data with gtkd signals ?

2025-07-27 Thread huangyy via Digitalmars-d-learn
On Friday, 25 July 2025 at 19:21:07 UTC, Dejan Lekic wrote: On Friday, 25 July 2025 at 16:44:13 UTC, huangyy wrote: I want to write a small program with gtkd. I need to use Signals.connectData to transfer an int type parameter to the callback function. I don't know how to write it. I hope some

Class-Inheritancing Error

2025-07-27 Thread David T. Oxygen via Digitalmars-d-learn
I wrote a piece of code like this: ```d class Person{ string name; this(string name){this.name=name;} } class Someone:Person{ alias super this; } void main(){ Someone x=new Someone("Bob"); } ``` And then,I got a Error-Message: ``` ab.d(6): Error: variable name expe

Re: Cannot instantiate ReturnType with lambda

2025-07-26 Thread monkyyy via Digitalmars-d-learn
On Saturday, 26 July 2025 at 23:08:35 UTC, luafyn wrote: alias U = ReturnType!fn; `ReturnType!(fn!T)` works id avoid being this explicit with types tho, type inference is unidirectional in d, its best to lean into it and follow the natural flow

Re: Examples from "Programming in D" book

2025-07-26 Thread Andy Valencia via Digitalmars-d-learn
On Saturday, 26 July 2025 at 20:35:14 UTC, Brother Bill wrote: I think that if someone is starting with "Programming in D", that sample code that is exhaustive would be helpful. It'll be great to see what you come up with. Thanks for taking such a hands-on approach! Andy

Cannot instantiate ReturnType with lambda

2025-07-26 Thread luafyn via Digitalmars-d-learn
Why doesn't this work? ```d import std; struct Optional(T) { T value; bool hasValue; } auto map(alias fn, T)(Optional!T m) { alias U = ReturnType!fn; if (m.hasValue) { return Optional!U(fn(m.value), true); } else { return Optional!U(); } } void main() {

Re: Examples from "Programming in D" book

2025-07-26 Thread thinkunix via Digitalmars-d-learn
Brother Bill via Digitalmars-d-learn wrote: I think that if someone is starting with "Programming in D", that sample code that is exhaustive would be helpful. I am one of those where code snippets are not an effective way to learn. I need real working code that I can "play&quo

Re: Examples from "Programming in D" book

2025-07-26 Thread Brother Bill via Digitalmars-d-learn
On Saturday, 26 July 2025 at 17:48:43 UTC, Monkyyy wrote: On Friday, 25 July 2025 at 21:27:55 UTC, Brother Bill wrote: On Friday, 25 July 2025 at 18:47:19 UTC, Ali Çehreli wrote: On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https:/

Re: Examples from "Programming in D" book

2025-07-26 Thread Monkyyy via Digitalmars-d-learn
On Friday, 25 July 2025 at 21:27:55 UTC, Brother Bill wrote: On Friday, 25 July 2025 at 18:47:19 UTC, Ali Çehreli wrote: On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https://ddili.org/ders/d.en/index.html >> under "Code samples as a

Re: Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 18:47:19 UTC, Ali Çehreli wrote: On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https://ddili.org/ders/d.en/index.html >> under "Code samples as a .zip file" > > Checked that out. These are not in order, nor

Re: How do I pass a variables as data with gtkd signals ?

2025-07-25 Thread Dejan Lekic via Digitalmars-d-learn
On Friday, 25 July 2025 at 16:44:13 UTC, huangyy wrote: I want to write a small program with gtkd. I need to use Signals.connectData to transfer an int type parameter to the callback function. I don't know how to write it. I hope someone can help me. It would be best if you can provide a sample

Re: Examples from "Programming in D" book

2025-07-25 Thread Ali Çehreli via Digitalmars-d-learn
On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https://ddili.org/ders/d.en/index.html >> under "Code samples as a .zip file" > > Checked that out. These are not in order, nor exhaustive. > > I'll create my own code samples, then post t

Re: Inherited constructor

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 03:57:34 UTC, Andy Valencia wrote: On Friday, 25 July 2025 at 02:40:35 UTC, H. S. Teoh wrote: In D, constructors are not inherited, so yes, unfortunately you have to write a forwarding ctor that passes the arguments along to the base class. My OO worldview goes bac

Re: Inherited constructor

2025-07-25 Thread Jerry via Digitalmars-d-learn
Another way to forward any constructor call is to do this: import std.stdio; class A { int x; this(int x) { this.x = x; } } class B : A { this(Args...)(Args args) { super(args); } } void main() { auto b = new B(42); b.x.writeln; }

How do I pass a variables as data with gtkd signals ?

2025-07-25 Thread huangyy via Digitalmars-d-learn
I want to write a small program with gtkd. I need to use Signals.connectData to transfer an int type parameter to the callback function. I don't know how to write it. I hope someone can help me. It would be best if you can provide a sample code. Thank!

Re: Eiffel like reports for Design by Contract contracts

2025-07-25 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Some notes: 1. The ``Identifier :`` syntax is used for labels within a statement list. 2. The feature in question you are asking about is assertion clauses. D does not have this. https://www.eiffel.org/doc/solutions/Design_by_Contract_and_Assertions https://www.eiffel.org/doc/eiffel/Eiffel_pr

Re: Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: check https://ddili.org/ders/d.en/index.html under "Code samples as a .zip file" Checked that out. These are not in order, nor exhaustive. I'll create my own code samples, then post them here first.

Re: Examples from "Programming in D" book

2025-07-25 Thread novicetoo via Digitalmars-d-learn
check https://ddili.org/ders/d.en/index.html under "Code samples as a .zip file"

Eiffel like reports for Design by Contract contracts

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
In Eiffel, it is trivial to get a report for Subject Matter Experts (SMEs) that will provide feedback that the DbC contracts are what they agreed to. It would be nice to have this in D. Does D already have this, or should this be added to DIP Ideas forum? Imagine a sample contract for Vats

Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
Has anyone already published the D examples from the "Programming in D" book? If not, I'll do it, and publish it here first. It would be good to have this on dlang.org for D newbies.

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 07:16:55 UTC, evilrat wrote: On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote: From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your proj

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-25 Thread evilrat via Digitalmars-d-learn
On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote: From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your project."); } Running it generates: phobos64.lib

Re: Inherited constructor

2025-07-24 Thread Andy Valencia via Digitalmars-d-learn
On Friday, 25 July 2025 at 02:40:35 UTC, H. S. Teoh wrote: In D, constructors are not inherited, so yes, unfortunately you have to write a forwarding ctor that passes the arguments along to the base class. My OO worldview goes back to Smalltalk, where constructors are "just" methods and thus

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-24 Thread monkyyy via Digitalmars-d-learn
On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote: _D3std6random__T15bcryptGenRandomTmZQuFNbNiNeJmZb linking is different then a runtime crash; restart your computer, reinstall, pray to dark gods, double check your install method was the intended way, try the backup install script,

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-24 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 25, 2025 at 01:04:31AM +, Brother Bill via Digitalmars-d-learn wrote: > From "Programming in D" book: > > import std.stdio; > import std.random; > > void main() { > int number = uniform(1, 101); > > writeln(&qu

Re: Inherited constructor

2025-07-24 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 24, 2025 at 05:19:17PM +, Andy Valencia via Digitalmars-d-learn wrote: > What is considered the "clean" way to address this error: > > ``` > tst60.d(7): Error: class `tst60.B` cannot implicitly generate a > default constructor when base class `tst6

Re: Inherited constructor

2025-07-24 Thread Brother Bill via Digitalmars-d-learn
On Thursday, 24 July 2025 at 17:19:17 UTC, Andy Valencia wrote: What is considered the "clean" way to address this error: ``` tst60.d(7): Error: class `tst60.B` cannot implicitly generate a default constructor when base class `tst60.A` is missing a default constructor ``` Yes, this is a toy

std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-24 Thread Brother Bill via Digitalmars-d-learn
From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your project."); } Running it generates: phobos64.lib(random_6ea_855.obj) : error LNK2019: unresolved external sym

Re: How can one close issues fransferred from Bugzilla

2025-07-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 24 July 2025 at 18:31:58 UTC, Quirin Schroll wrote: For example, I originally filed [DMD#19271](https://github.com/dlang/dmd/issues/19271), but as far as GitHub is concerned, I’m not the author of that issue so I can’t close it. What’s the process for that? I can comment on that

Re: How can one close issues fransferred from Bugzilla

2025-07-24 Thread 0xEAB via Digitalmars-d-learn
On Thursday, 24 July 2025 at 18:31:58 UTC, Quirin Schroll wrote: I can comment on that issue, but how would anyone know I did? Luckily, GitHub has notifications! (Obviously that still requires people to have them enabled and actually check them out.)

How can one close issues fransferred from Bugzilla

2025-07-24 Thread Quirin Schroll via Digitalmars-d-learn
For example, I originally filed [DMD#19271](https://github.com/dlang/dmd/issues/19271), but as far as GitHub is concerned, I’m not the author of that issue so I can’t close it. What’s the process for that? I can comment on that issue, but how would anyone know I did?

Inherited constructor

2025-07-24 Thread Andy Valencia via Digitalmars-d-learn
What is considered the "clean" way to address this error: ``` tst60.d(7): Error: class `tst60.B` cannot implicitly generate a default constructor when base class `tst60.A` is missing a default constructor ``` Yes, this is a toy example, but it reflects something I'm doing in actual code. Th

Re: How to use D on M2 macOS?

2025-07-23 Thread Serg Gini via Digitalmars-d-learn
On Wednesday, 23 July 2025 at 14:12:30 UTC, Brian Callahan wrote: I know you got things going with LDC, but I use GDC for all my D needs on macOS. I have a tarball that's a simple extract, add When I tried it last time - it was magnitude slower than LDC solution

Re: How to use D on M2 macOS?

2025-07-23 Thread Brian Callahan via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: How to use D on M2 macOS?

2025-07-23 Thread Christian Köstlin via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: Sorting arrays of objects, for instance JSONValue's?

2025-07-22 Thread Andy Valencia via Digitalmars-d-learn
On Tuesday, 22 July 2025 at 21:24:04 UTC, Andy Valencia wrote: I'm trying to convince the library's sort() to order an array of JSON objects, where the "name" field is the key for the sort. The following is the closest I've come, but it's not very close! Closer than I thought. I just had to

Sorting arrays of objects, for instance JSONValue's?

2025-07-22 Thread Andy Valencia via Digitalmars-d-learn
I'm trying to convince the library's sort() to order an array of JSON objects, where the "name" field is the key for the sort. The following is the closest I've come, but it's not very close! TIA (as always), Andy ```d import std.json : JSONValue; import std.algorithm.sorting : sort; void ma

Re: python like datastructures as databases code examples

2025-07-22 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 22 July 2025 at 07:32:00 UTC, Serg Gini wrote: On Monday, 21 July 2025 at 16:13:44 UTC, monkyyy wrote: On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some req

Re: python like datastructures as databases code examples

2025-07-22 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:13:44 UTC, monkyyy wrote: On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some requests for the data) - this looks more like some Tree struct

Re: How to use D on M2 macOS?

2025-07-21 Thread Sergey via Digitalmars-d-learn
On Monday, 21 July 2025 at 17:21:58 UTC, Albert wrote: On Monday, 21 July 2025 at 17:08:17 UTC, Albert wrote: How do I build & run the executable though? Anyway with some perseverance I managed to build & run hello world app. Thank you guys for your help. Though I do think D could do so muc

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 17:08:17 UTC, Albert wrote: How do I build & run the executable though? Anyway with some perseverance I managed to build & run hello world app. Thank you guys for your help. Though I do think D could do so much better with onboarding first time users...

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:42:31 UTC, Albert wrote: Sorry to be blunt, but not great first impression so far. I'm still trying to make this work, but stuck with no clue... I think setting sodlib path in settings helped somewhat. At least errors are gone and seems to have detected the build

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 16:24:31 UTC, Luna wrote: The script works by adding a special startup script to your shell session; as such you may need to restart your mac for it to fully work. I've tried everything I can think of, now getting the following errors: ``` Could not initialize dub

Re: How to use D on M2 macOS?

2025-07-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:25:57 UTC, Albert wrote: Thanks, how do I get the beta/nightly version? Only one I see is 0.23.1 from 2021. Thanks It's an option in the code-d extension settings.

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:32:49 UTC, Albert wrote: On Monday, 21 July 2025 at 14:16:29 UTC, Luna wrote: [...] Thank you. This seems to have worked better! Though I am still getting errors: ``` Could not initialize DCD for ``` and in the output get a lot of: ``` 2025-07-21T15:30:59.455

Re: python like datastructures as databases code examples

2025-07-21 Thread monkyyy via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote: But array doesn't look right.. If you want a balanced ("always sorted") structure with "filter" (ability to make some requests for the data) - this looks more like some Tree structure Your thinking in classical theory and textbook read

Re: python like datastructures as databases code examples

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:15:07 UTC, Monkyyy wrote: On Monday, 21 July 2025 at 08:31:42 UTC, Serg Gini wrote: That filter is not aware of the data structure nor is that array maintaining a sort I'm not sure what you are trying to do. But array doesn't look right.. If you want a balanced (

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:16:29 UTC, Luna wrote: The script I posted automates some of these steps by the way; so you'll just have to set the paths correctly in the plugin (/opt/SDKs/serve-d/bin/serve-d, /opt/SDKs/dcd/bin/dcd-server, /opt/SDKs/dcd/bin/dcd-client); then set the serve-d versi

Re: How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:10:44 UTC, Serg Gini wrote: Also don't forget to switch the version of the "code-d" extension to "beta/nightly". Stable is very old and not updating properly. Thanks, how do I get the beta/nightly version? Only one I see is 0.23.1 from 2021. Thanks

Re: How to use D on M2 macOS?

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: python like datastructures as databases code examples

2025-07-21 Thread Monkyyy via Digitalmars-d-learn
On Monday, 21 July 2025 at 08:31:42 UTC, Serg Gini wrote: On Friday, 18 July 2025 at 18:35:40 UTC, monkyyy wrote: `shapes.filter(isnt:shapeenum.isstatic)` https://forum.dlang.org/thread/apbcqxiifbsqdlrsl...@forum.dlang.org I know its possible to make complex, datastructure aware filters, but I

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 14:10:44 UTC, Serg Gini wrote: On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: [...] I agree with Luna that installing from official GitHub Releases are the easiest way. There is also this project: https://code.dlang.org/packages/ldcup regarding serve-d -

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and

Re: How to use D on M2 macOS?

2025-07-21 Thread Luna via Digitalmars-d-learn
On Monday, 21 July 2025 at 13:52:52 UTC, Luna wrote: On Monday, 21 July 2025 at 13:29:23 UTC, Albert wrote: Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile ev

How to use D on M2 macOS?

2025-07-21 Thread Albert via Digitalmars-d-learn
Hi all, I am completely new to D, wished to try it out and write a small app in it. However, for the last couple hours I am ready to pull my hair out as I have no idea how to compile even a simplest hello world app. I installed ldc and dub (nowhere on the download page did it even mention t

Re: python like datastructures as databases code examples

2025-07-21 Thread Serg Gini via Digitalmars-d-learn
On Friday, 18 July 2025 at 18:35:40 UTC, monkyyy wrote: `shapes.filter(isnt:shapeenum.isstatic)` https://forum.dlang.org/thread/apbcqxiifbsqdlrsl...@forum.dlang.org I know its possible to make complex, datastructure aware filters, but I never done it what patterns do people use? lets say you

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote: I want the program to end with the F6 key on my keyboard instead of the tilde. I use Windows as the platform. Thank you for all your responses. I checked the ASCII table, and 0x1A is indeed the character I was looking for. I'm not su

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 21:59:48 UTC, Steven Schveighoffer wrote: There is no F6 Unicode character. Are you seeing tildes when you press F6 and thinking it’s an actual tilde in the stream? When I press the F6 key, ^Z characters appear on the screen. I want the program to terminate using t

Re: stdInputRange

2025-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote: On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote: No problem here either. Where are you running the program from (embedded terminal in an editor ? a terminal emulator ?). Are you on Windows or Linux ? I want the program to en

Re: stdInputRange

2025-07-20 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote: No problem here either. Where are you running the program from (embedded terminal in an editor ? a terminal emulator ?). Are you on Windows or Linux ? I want the program to end with the F6 key on my keyboard instead of the tilde. I use

  1   2   3   4   5   6   7   8   9   10   >