Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Monday, 17 May 2021 at 00:27:01 UTC, SealabJaster wrote: On Sunday, 16 May 2021 at 23:52:06 UTC, Adam D. Ruppe wrote: ... I've opened a PR (https://github.com/dlang/dmd/pull/12526) with a super hacked together proof-of-concept. As I say in the PR I don't know if I'm actually capable of

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 00:27:01 UTC, SealabJaster wrote: I've opened a PR (https://github.com/dlang/dmd/pull/12526) with a super hacked together proof-of-concept. oh very good! I was going to add something similar to my own todo list but who knows when I'd get around to it. This kind of

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 23:52:06 UTC, Adam D. Ruppe wrote: ... I've opened a PR (https://github.com/dlang/dmd/pull/12526) with a super hacked together proof-of-concept. As I say in the PR I don't know if I'm actually capable of pushing it forward if the idea gets accepted, but I've

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:43:51 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Error: undefined identifier 'SetDCBrushColor' Did you include gdi32.lib on the command line? I got this error: C:\Users\Usuario\Arquivos\dm\lib\gdi32.lib Error 43: Not a

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
Thanks to everyone who has replied. You've given me a lot to think about, and since I'm not yet fluent in D it will take a bit to digest it all, though one thing is clear. This community is one of the strong features of D. I will mention it to others as a selling point. Best,

Re: struct destructor

2021-05-16 Thread cc via Digitalmars-d-learn
On Saturday, 15 May 2021 at 18:24:19 UTC, Alain De Vos wrote: Thanks, good idea but, It does not initiate a GC cycle or free any GC memory. Personally I wish D would re-implement "delete" and make it "just work" like one would assume, but from what I've seen there have been many many debates

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote: If you post your code (or at least a self-contained subset of it) someone can probably help you figure out where you're running into trouble. The error messages by themselves do not provide enough information--all I can say from

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 16 May 2021 at 07:20:52 UTC, Chris Piker wrote: On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote: If you post your code (or at least a self-contained subset of it) someone can probably help you figure out where you're running into trouble. The error messages by

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: Maybe that's eminently reasonable to those with deep knowledge, but it seems crazy to a new D programmer. It breaks a general assumption about programming when copying and pasting a definition yields two things that aren't the same

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking

Re: struct destructor

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote: If the goal is to absolutely squeeze the GC back down after using new or dynamic arrays, I find destroy + GC.free often fails to do the trick (e.g. GC.stats.usedSize remains high). destroy + GC.free has a quirk - GC.free only works on what

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking at the code :) So, honest question. Does it strike you as

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 20:32:08 UTC, SealabJaster wrote: ... You could even make a helper function that lets the compiler infer the lambda's type for you: ```d struct S(T) { alias FT = T function(T); FT func; } S!T s(T)(T function(T) func) { return S!T(func); } void main() {

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Error: undefined identifier 'SetDCBrushColor' Did you include gdi32.lib on the command line?

Re: property functions

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually makes it required for the range empty and front things!) But

Re: ugly and/or useless features in the language.

2021-05-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, May 15, 2021 at 02:31:08PM +, Alain De Vos via Digitalmars-d-learn wrote: > Which parts in dlang don't you use and why ? > > Personally i have no need for enum types, immutable is doing fine. > Auto return types i find dangerous to use. > Voldermont types. > Named initialiser. >

Re: property functions

2021-05-16 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:47:55 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually

stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
Why doesn't this program dups core ? Is s not recycled ? ``` import std.stdio:writeln; void main(){ //I point to the heap int[] p=[1,2,3]; { int[3]s=[1,2,3]; //I point to the stack p=s; } //Why do I still live ?

Re: stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
This works also, ``` import std.stdio:writeln; int [] fun(){ int[3]s=[1,2,3]; int[] r=s; return r; } void main(){ writeln(fun()[0]); } ```

Re: stack out of scope ?

2021-05-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, May 16, 2021 at 04:40:53PM +, Alain De Vos via Digitalmars-d-learn wrote: > This works also, > > ``` > import std.stdio:writeln; > > int [] fun(){ > int[3]s=[1,2,3]; > int[] r=s; > return r; > } > > void main(){ > writeln(fun()[0]); > } > ```

Re: stack out of scope ?

2021-05-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/21 12:32 PM, Alain De Vos wrote: Why doesn't this program dups core ? Is s not recycled ? ``` import std.stdio:writeln; void main(){ //I point to the heap int[] p=[1,2,3]; {     int[3]s=[1,2,3];     //I point to the stack     p=s; } //Why do I still live ?

Re: stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
On Sunday, 16 May 2021 at 16:58:15 UTC, H. S. Teoh wrote: On Sun, May 16, 2021 at 04:40:53PM +, Alain De Vos via Digitalmars-d-learn wrote: This works also, ``` import std.stdio:writeln; int [] fun(){ int[3]s=[1,2,3]; int[] r=s; return r; } void main(){

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:43:51 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Error: undefined identifier 'SetDCBrushColor' Did you include gdi32.lib on the command line? Yes, I did it. But not work. I get this error: Error: undefined identifier

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Jack via Digitalmars-d-learn
On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Well, I program in D as a hobby for just over a year, and I like to learn and explore this wonderful programming language. Now I found the DMC compiler that compiles C ++ code. So I decided to test it. Creating a program with a win32api

Re: stack out of scope ?

2021-05-16 Thread ag0aep6g via Digitalmars-d-learn
On 16.05.21 19:24, Alain De Vos wrote: On Sunday, 16 May 2021 at 16:58:15 UTC, H. S. Teoh wrote: [...] Though I believe if you compile with -dip25 -dip1000 the compiler should emit an error for the above code.  If not, please file a bug against -dip1000. T I use ldc2. No dip flags here.

Re: stack out of scope ?

2021-05-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, May 16, 2021 at 05:24:40PM +, Alain De Vos via Digitalmars-d-learn wrote: > On Sunday, 16 May 2021 at 16:58:15 UTC, H. S. Teoh wrote: > > On Sun, May 16, 2021 at 04:40:53PM +, Alain De Vos via > > Digitalmars-d-learn wrote: > > > This works also, > > > > > > ``` > > > import

Re: stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
the flag dip1000 was not shown in the help file. And indeed for the second program compiling with dip1000 results in, test.d(6): Error: scope variable r may not be returned But the first program still compiles and runs without problem, even with dip1000.

Re: stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
Is there a list of compiler flags not shown ?

Re: stack out of scope ?

2021-05-16 Thread Alain De Vos via Digitalmars-d-learn
On Sunday, 16 May 2021 at 18:27:40 UTC, H. S. Teoh wrote: On Sun, May 16, 2021 at 05:24:40PM +, Alain De Vos via Digitalmars-d-learn wrote: On Sunday, 16 May 2021 at 16:58:15 UTC, H. S. Teoh wrote: > On Sun, May 16, 2021 at 04:40:53PM +, Alain De Vos via > Digitalmars-d-learn wrote: >

Re: struct destructor

2021-05-16 Thread mw via Digitalmars-d-learn
On Sunday, 16 May 2021 at 11:42:19 UTC, Adam D. Ruppe wrote: On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote: If the goal is to absolutely squeeze the GC back down after using new or dynamic arrays, I find destroy + GC.free often fails to do the trick (e.g. GC.stats.usedSize remains high).

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn
On Sunday, 16 May 2021 at 18:06:40 UTC, Jack wrote: On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Well, I program in D as a hobby for just over a year, and I like to learn and explore this wonderful programming language. Now I found the DMC compiler that compiles C ++ code. So I

Re: stack out of scope ?

2021-05-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, May 16, 2021 at 06:33:04PM +, Alain De Vos via Digitalmars-d-learn wrote: > On Sunday, 16 May 2021 at 18:27:40 UTC, H. S. Teoh wrote: [...] > > -snip- > > import std.stdio:writeln; > > > > int [] fun() @safe {// N.B.: need @safe > >

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread SealabJaster via Digitalmars-d-learn
On Sunday, 16 May 2021 at 12:54:19 UTC, Chris Piker wrote: ... If all you need is a single type for the parameter(s) and return type, then it can be simplified a bit to save you some typing: ```d struct S(T) { alias FT = T function(T); FT func; } void main() { auto a = S!int(a =>

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 10:10:54 UTC, SealabJaster wrote: It's due to a quirk with passing lambdas as template arguments. Each lambda is actually separated into its own function. Hey that was a very well laid out example. Okay, I think the light is starting do dawn. So if I use lambdas

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 12:54:19 UTC, Chris Piker wrote: a = b; // Lambdas as arguments instead of types works Wait a sec, when you do the ```d auto a = S!(a => a*2)(); ``` That's not actually passing a type. That's passing the (hidden) name of a on-the-spot-created function template

DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Marcone via Digitalmars-d-learn
Well, I program in D as a hobby for just over a year, and I like to learn and explore this wonderful programming language. Now I found the DMC compiler that compiles C ++ code. So I decided to test it. Creating a program with a win32api graphical interface I run into this error: Error:

property functions

2021-05-16 Thread Nick via Digitalmars-d-learn
The [Property Functions](https://dlang.org/spec/function.html#property-functions) documentation reads: WARNING: The definition and usefulness of property functions is being reviewed, and the implementation is currently incomplete. Using property functions is not recommended until the

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, May 15, 2021 at 11:25:10AM +, Chris Piker via Digitalmars-d-learn wrote: [...] > Basically the issue is that if one attempts to make a range based > pipeline aka: > > ```d > auto mega_range = range1.range2!(lambda2).range3!(lambda3); > ``` > Then the type definition of mega_range is

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 16 May 2021 at 13:35:02 UTC, Adam D. Ruppe wrote: Wait, what's the bug there? The typeof DOES tell you they are separate. Error: cannot implicitly convert expression `b` of type `S!(func2)` to `S!(func1)` Sorry, it's a forum post, so I really should have been more explicit. It

Re: stack out of scope ?

2021-05-16 Thread Kyle via Digitalmars-d-learn
On Sunday, 16 May 2021 at 18:30:49 UTC, Alain De Vos wrote: Is there a list of compiler flags not shown ? ldc2 -help-hidden

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 22:17:16 UTC, Chris Piker wrote: It seems there's a broken symmetry in compiler error reporting for the following, ostensibly identical, cases: Oh yes, I completely agree with you. Sometimes error messages even use the name but it is from a different module so it is