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(){ > Someone x=new Someone("Bob"); > }

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 > > ``` > extern int r; > > int main() > { >