Re: Some thoughts about C and D, return data through parameters

2017-12-21 Thread Nick Treleaven via Digitalmars-d
On Tuesday, 19 December 2017 at 08:54:38 UTC, Petar Kirov [ZombineDev] wrote: Reminds me of C#7's out variable declarations: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#out-variables However multiple return values are much better implemented through language-integrated tu

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread Steven Schveighoffer via Digitalmars-d
On 12/19/17 9:35 AM, ketmar wrote: Steven Schveighoffer wrote: I insist that auto is a storage qualifier what is the rationale to have `auto` as storage qualifier? except of keeping it in line with the ancient C feature (and most C programmers don't even know what `auto` does in C). Becau

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread ketmar via Digitalmars-d
Steven Schveighoffer wrote: I insist that auto is a storage qualifier what is the rationale to have `auto` as storage qualifier? except of keeping it in line with the ancient C feature (and most C programmers don't even know what `auto` does in C). i bet that most people are sure that `aut

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread Steven Schveighoffer via Digitalmars-d
On 12/19/17 6:27 AM, ketmar wrote: note that D devs stubbornly insists that `auto` is not a type placeholder, but a storage qualifier, like `static`, so you can't write `foreach (auto c; ...)` (and compiler rejects such code). yet, `if (auto c = ...)` is perfectly allowed, and here `auto` is t

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread ketmar via Digitalmars-d
cosinus wrote: So my question is would it be a good idea to have some kind of implicit declarations of variables that are used as parameters: ```D int add(decl ref int c, int a, int b); // ... // c is unknown here if(add(c, 123, 456)) { writeln("error!"); } // c is implicit declared at

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread Petar via Digitalmars-d
On Tuesday, 19 December 2017 at 01:01:57 UTC, cosinus wrote: [snip] A second thought that came up was: Shouldn't there be a compiler-error if someone is ignoring the return-value of a function? I saw this C-code: ```C (void)printf("Hello World!"); ``` It cast's the return-value to void to t

Re: Some thoughts about C and D, return data through parameters

2017-12-19 Thread Petar via Digitalmars-d
On Tuesday, 19 December 2017 at 01:01:57 UTC, cosinus wrote: Recently I've asked my self why `C` isn't capable of returning multiple values at once. And I thought that the return-statement was primarally used only for error-handling and all the valuable data has been returned through the param

Some thoughts about C and D, return data through parameters

2017-12-18 Thread cosinus via Digitalmars-d
Recently I've asked my self why `C` isn't capable of returning multiple values at once. And I thought that the return-statement was primarally used only for error-handling and all the valuable data has been returned through the parameter-list. If this was true then all `C`-like languages had abu