Re: auto vectorization notes

2020-03-28 Thread Crayo List via Digitalmars-d-learn
On Saturday, 28 March 2020 at 06:56:14 UTC, Bruce Carneal wrote: On Saturday, 28 March 2020 at 05:21:14 UTC, Crayo List wrote: On Monday, 23 March 2020 at 18:52:16 UTC, Bruce Carneal wrote: [snip] (on the downside you have to guard against compiler code-gen performance regressions) auto

Re: auto vectorization notes

2020-03-28 Thread Bruce Carneal via Digitalmars-d-learn
On Saturday, 28 March 2020 at 05:21:14 UTC, Crayo List wrote: On Monday, 23 March 2020 at 18:52:16 UTC, Bruce Carneal wrote: [snip] (on the downside you have to guard against compiler code-gen performance regressions) auto vectorization is bad because you never know if your code will get

Re: auto vectorization notes

2020-03-27 Thread Crayo List via Digitalmars-d-learn
On Monday, 23 March 2020 at 18:52:16 UTC, Bruce Carneal wrote: When speeds are equivalent, or very close, I usually prefer auto vectorized code to explicit SIMD/__vector code as it's easier to read. (on the downside you have to guard against compiler code-gen performance regressions) One

auto vectorization notes

2020-03-23 Thread Bruce Carneal via Digitalmars-d-learn
When speeds are equivalent, or very close, I usually prefer auto vectorized code to explicit SIMD/__vector code as it's easier to read. (on the downside you have to guard against compiler code-gen performance regressions) One oddity I've noticed is that I sometimes need to use pragma(inline

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 23 February 2020 at 18:40:03 UTC, Adam D. Ruppe wrote: The error I currently get when clicking the documentation link https://phobos-next.dpldocs.info/ is try it now. I've been tweaking the time out and retry numbers lately so it is less likely to do this but still sometimes does

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 23 February 2020 at 18:20:19 UTC, Per Nordlöw wrote: The error I currently get when clicking the documentation link https://phobos-next.dpldocs.info/ is try it now. I've been tweaking the time out and retry numbers lately so it is less likely to do this but still sometimes does

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 23 February 2020 at 18:18:25 UTC, Per Nordlöw wrote: On Sunday, 23 February 2020 at 17:18:48 UTC, Andre Pany wrote: If your Dub package is registered on code.dlang.org, this is automatically provided. Example: http://code.dlang.org/packages/arsd-official Click on the documentation

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:18:48 UTC, Andre Pany wrote: If your Dub package is registered on code.dlang.org, this is automatically provided. Example: http://code.dlang.org/packages/arsd-official Click on the documentation link. Beside that you can use e.g. Github Actions to create

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Basile B. via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:14:33 UTC, Per Nordlöw wrote: I would like to setup auto-generation of online documentation for my public D libraries residing on Github and Gitlab. What alternatives do I have? for gitlab they have a system of pages that's quite easy to setup: something

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:38:35 UTC, Per Nordlöw wrote: On Sunday, 23 February 2020 at 17:18:48 UTC, Andre Pany wrote: Example: http://code.dlang.org/packages/arsd-official Click on the documentation link. Beside that you can use e.g. Github Actions to create documentation. Kind

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:18:48 UTC, Andre Pany wrote: Example: http://code.dlang.org/packages/arsd-official Click on the documentation link. Beside that you can use e.g. Github Actions to create documentation. Kind regards Andre Thanks! How do I check which dmd or dub command

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:14:33 UTC, Per Nordlöw wrote: I would like to setup auto-generation of online documentation for my public D libraries residing on Github and Gitlab. What alternatives do I have? If your Dub package is registered on code.dlang.org, this is automatically

Re: Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 23 February 2020 at 17:14:33 UTC, Per Nordlöw wrote: I would like to setup auto-generation of online documentation for my public D libraries residing on Github and Gitlab. What alternatives do I have? I'm thinking something like http://ddocs.org announced here https

Auto-generation of online documentation for my open libraries

2020-02-23 Thread Per Nordlöw via Digitalmars-d-learn
I would like to setup auto-generation of online documentation for my public D libraries residing on Github and Gitlab. What alternatives do I have?

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Thanks for the excellent replies.

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote: Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D? Yes assuming that the expression is bool evaluable. This includes - pointers: `if (auto p

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
: string[string] dict; if (auto p = "key" in dict) { writeln(*p); } That works because the 'in' operator on aa's returns a pointer, which can be compared to bool.

Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D?

Re: auto keyword

2020-01-30 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 30, 2020 at 09:37:40AM +, Michael via Digitalmars-d-learn wrote: [...] > auto elements = buf.to!string.strip.split(" ").filter!(a => a != ""); > > That line strips white space from buf, splits it, removes empty > elements and returns an arra

Re: auto keyword

2020-01-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 30, 2020 2:37:40 AM MST Michael via Digitalmars-d-learn wrote: > auto is surely a nice feature. Nonetheless I'd prefer to use > explicit types. So when reading a code and I see the auto keyword > I also have to find out what kind of type is meant. > > I have

auto keyword

2020-01-30 Thread Michael via Digitalmars-d-learn
auto is surely a nice feature. Nonetheless I'd prefer to use explicit types. So when reading a code and I see the auto keyword I also have to find out what kind of type is meant. I have a line of code that looks like this: auto elements = buf.to!string.strip.split(" &quo

Re: Unexpectedly nice case of auto return type

2019-12-06 Thread mipri via Digitalmars-d-learn
On Friday, 6 December 2019 at 23:25:30 UTC, Johannes Loher wrote: On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have

Re: Unexpectedly nice case of auto return type

2019-12-06 Thread Johannes Loher via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be

Re: Unexpectedly nice case of auto return type

2019-12-06 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 12:54:34 UTC, Basile B. wrote: On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe wrote: On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe wrote: On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody should write an article about it to raise awareness of it. :-D

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
via > > Digitalmars-d- learn wrote: >> I wish something like this was possible, until I change the >> return type of `alwaysReturnNull` from `void*` to `auto`. >> >> >> --- >> class A {} >> class B {} >> >> auto alwaysReturnNull() // void

Re: Unexpectedly nice case of auto return type

2019-12-04 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: On Tuesday, 3 December 2019 at 10:13:30 UTC, mipri wrote: Speaking of nice stuff and aliases, suppose you want to return a nice tuple with named elements? Option 1: auto auto option1() { return tuple!(int, "apples&

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote: typeof(return) is one of the lesser known cool things about D that make it so cool. Somebody should write an article about it to raise awareness of it. :-D you know i probably will write about that next week. so be sure to

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 04, 2019 at 01:01:04AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: > > Option 4: typeof(return) > > typeof(return) is super cool for like option type things too! typeof(return) is one of the lesser known cool things

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote: Option 4: typeof(return) typeof(return) is super cool for like option type things too!

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread mipri via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:13:30 UTC, mipri wrote: Speaking of nice stuff and aliases, suppose you want to return a nice tuple with named elements? Option 1: auto auto option1() { return tuple!(int, "apples", int, "oranges")(1, 2); } Option 2: redu

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 22:11:39 UTC, Meta wrote: On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. Not *quite* correct. void is not a bottom type; it's a unit

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. Not *quite* correct. void is not a bottom type; it's a unit type, meaning that it's a type with only 1 value (as is

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 09:08:55PM +, Paul Backus via Digitalmars-d-learn wrote: > On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: > > The thing is, `void` means "no return type" (or "no type" in some > > contexts), i.e., void == TBottom in that case. > > This is incorrect.

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 17:45:27 UTC, H. S. Teoh wrote: The thing is, `void` means "no return type" (or "no type" in some contexts), i.e., void == TBottom in that case. This is incorrect. `void` as a return type is a unit type; that is, a type with exactly one value. A function with a

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 03, 2019 at 03:19:02AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- > learn wrote: [...] > > [...] maybe we should be able to name the type of null. I think this > > relates to TBottom too a bit. > >

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 3, 2019 3:23:20 AM MST Basile B. via Digitalmars-d- learn wrote: > On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis > > wrote: > > On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via > > > > Digitalmars-d- learn wrote: > >> [...] > > > > There isn't much

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via Digitalmars-d- learn wrote: [...] There isn't much point in giving the type of null an explicit name given that it doesn't come up very often, and typeof(null) is

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
> >> I wish something like this was possible, until I change the > >> return type of `alwaysReturnNull` from `void*` to `auto`. > >> > >> > >> --- > >> class A {} > >> class B {} > >> > >> auto alwaysReturnNull() /

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread mipri via Digitalmars-d-learn
`auto` or `typeof(null)`. You can still create an alias anyway :) alias TypeNull = typeof(null); Speaking of nice stuff and aliases, suppose you want to return a nice tuple with named elements? Option 1: auto auto option1() { return tuple!(int, "apples", int, "

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote: On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote: That's interesting details of D developement. Since you reply to the first message I think you have not followed but in the last reply I told that maybe we should be able to name the type of null. I think this relates to TBottom

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:48:39 UTC, Basile B. wrote: You see what surprises me here is that we cannot express the special type that is `TypeNull` and that can only have one value (`null`) so instead we have to use `auto` or `typeof(null)`. You can still create an alias anyway

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis wrote: On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via Digitalmars-d- learn wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via Digitalmars-d- learn wrote: > I wish something like this was possible, until I change the > return type of `alwaysReturnNull` from `void*` to `auto`. > > > --- > class A {} > class B {} > > auto alwaysReturnNul

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
to A } still nice tho. Why not [1]? [1] typeof(null) alwaysReturnNull() { ... } Andrea Yeah nice, that works instead of auto. That reminds me of the discussion about TBottom. You see what surprises me here is that we cannot express the special type that is `TypeNull` and that can only have one

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Basile B. via Digitalmars-d-learn
) alwaysReturnNull() { ... } Andrea Yeah nice, that works instead of auto. That reminds me of the discussion about TBottom.

Re: Unexpectedly nice case of auto return type

2019-12-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote: A testA() { return alwaysReturnNull(); // Tnull can be implictly converted to A } still nice tho. Why not [1]? [1] typeof(null) alwaysReturnNull() { ... } Andrea

Re: Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 3 December 2019 at 07:12:18 UTC, Basile B. wrote: I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null

Unexpectedly nice case of auto return type

2019-12-02 Thread Basile B. via Digitalmars-d-learn
I wish something like this was possible, until I change the return type of `alwaysReturnNull` from `void*` to `auto`. --- class A {} class B {} auto alwaysReturnNull() // void*, don't compile { writeln(); return null; } A testA() { return alwaysReturnNull(); } B testB

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 16:22:27 UTC, Jonathan M Davis wrote: [...] Thanks very much again, very helpful explain. I use pass by ref scope instead "return TreeRange.__ctor();" to workround this issue.

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 8:14:52 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: > > It is not possible to prevent moving in D as things currently > > stand. DIP 1014 will need to be implemented to either hook into > > moves

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: It is not possible to prevent moving in D as things currently stand. DIP 1014 will need to be implemented to either hook into moves or to prevent them. However, once DIP 1014 has been implemented, I would expect the result to

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
@disable this() ; > > @disable this(this) ; > > > > } > > struct Tree { > > > > ref auto getRange() return scope { > > > > return TreeRange!T(_root); > > > > } > > > > } > > Tree tree; > > auto range

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote: I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root

ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root); } } Tree tree; auto range = tree.getRange

Re: Building GDC with auto-generated header files

2019-07-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 30 Jul 2019 15:19:44 +1200 schrieb rikki cattermole: > On 30/07/2019 4:11 AM, Eduard Staniloiu wrote: >> Cheers, everybody >> >> I'm working on this as part of my GSoC project [0]. >> >> I'm working on building gdc with the auto-generated `frontend.h` [

Re: Building GDC with auto-generated header files

2019-07-29 Thread rikki cattermole via Digitalmars-d-learn
On 30/07/2019 4:11 AM, Eduard Staniloiu wrote: Cheers, everybody I'm working on this as part of my GSoC project [0]. I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues There are functions in dmd that don't have an `extern (C)` or `extern (C

Building GDC with auto-generated header files

2019-07-29 Thread Eduard Staniloiu via Digitalmars-d-learn
Cheers, everybody I'm working on this as part of my GSoC project [0]. I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues There are functions in dmd that don't have an `extern (C)` or `extern (C++)` but they are used by gdc (are exposed in `.h

Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-12 Thread aliak via Digitalmars-d-learn
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: [...] Here's a much reduces test case: struct W(T) {} struct S { int* data; } template match1(alias handler) { auto ref match1(T)(inout auto ref W!T w) { return handler(); } } template match2(alias handler

Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-12 Thread aliak via Digitalmars-d-learn
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: Hi, I have an error that says "Error: returning `match1(opt)` escapes a reference to parameter `opt`, perhaps annotate with `return`". [...] Ok, I've found out something else. It only happens when you're returning a type that has an

inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-11 Thread aliak via Digitalmars-d-learn
I don't go through the "match2" template? Any help would be much appreciated. --- template match1(handlers...) { auto ref match1(T)(inout auto ref Optional!T opt) { // remove inout, it works if (opt.empty) { return handlers[1](); } else {

Re: Auto keyword and when to use it

2018-08-22 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 21:37:00 UTC, QueenSvetlana wrote: I had a misunderstanding about the keyword auto because I wrongfully believed that it made the code like Python Exactly, you are thinking still like D is Python or also dynamically typed. :) You will get when compiling errors

Re: Auto keyword and when to use it

2018-08-21 Thread QueenSvetlana via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 18:44:15 UTC, Jim Balter wrote: Python is not statically typed; D is. Why are you talking about Python? You asked whether D's auto is like C#'s var ... it is, but it doesn't have C#'s pointless restriction of not being allowed for non-local declarations. I think

Re: Auto keyword and when to use it

2018-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 21, 2018 12:22:42 PM MDT QueenSvetlana via Digitalmars-d- learn wrote: > On Monday, 20 August 2018 at 17:55:11 UTC, JN wrote: > > class Foo > > { > > > > auto bar; > > > > } > > > > because now the compiler doesn't k

Re: Auto keyword and when to use it

2018-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 21, 2018 9:04:31 AM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 8/20/18 9:15 PM, Mike Parker wrote: > > I tend to use type inference liberally, almost always with > > const/immutbale locals, though I tend to use auto only when the type > >

Re: Auto keyword and when to use it

2018-08-21 Thread Jim Balter via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 18:18:25 UTC, QueenSvetlana wrote: On Tuesday, 21 August 2018 at 16:15:32 UTC, XavierAP wrote: Only if someone likes "Type x = new Type()" instead of "auto x = new Type()" I would say they're clearly wrong. As you stated it's up to the progra

Re: Auto keyword and when to use it

2018-08-21 Thread QueenSvetlana via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:55:11 UTC, JN wrote: class Foo { auto bar; } because now the compiler doesn't know what type 'bar' is supposed to be. Just to clarify, even if I set bar in the constructor, I can't declare it with auto first, correct? I would have to declare a specific

Re: Auto keyword and when to use it

2018-08-21 Thread QueenSvetlana via Digitalmars-d-learn
On Tuesday, 21 August 2018 at 16:15:32 UTC, XavierAP wrote: Only if someone likes "Type x = new Type()" instead of "auto x = new Type()" I would say they're clearly wrong. As you stated it's up to the programmer to decided. I'm in favor of Type x = new Type() b

Re: Auto keyword and when to use it

2018-08-21 Thread XavierAP via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: So I can't declare class level variables with auto, correct? only local method variables? One difference between D's auto and C#'s var or C++'s auto is that the latter languages allow automatically typed declarations only

Re: Auto keyword and when to use it

2018-08-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/20/18 9:15 PM, Mike Parker wrote: I tend to use type inference liberally, almost always with const/immutbale locals, though I tend to use auto only when the type name is longer than four characters. For me, it's a nice way to save keystrokes. Some take a dim view of that approach

Re: Auto keyword and when to use it

2018-08-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:24:19 UTC, QueenSvetlana wrote: I'm struggling to understand what the auto keyword is for and it's appropriate uses. From research, it seems to share the same capabilities as the var keyword in C#. auto is one of the most misunderstood understood features

Re: Auto keyword and when to use it

2018-08-20 Thread JN via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: Great! So I can't declare class level variables with auto, correct? only local method variables? You can, globals, class members: class Foo { auto bar = "hi"; } Foo.bar will be of string type here, because "

Re: Auto keyword and when to use it

2018-08-20 Thread Colin via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: Great! So I can't declare class level variables with auto, correct? only local method variables? You can use auto if you're setting the class level variable to a default. class X { auto i = 42; // i will be an int }

Re: Auto keyword and when to use it

2018-08-20 Thread QueenSvetlana via Digitalmars-d-learn
Great! So I can't declare class level variables with auto, correct? only local method variables?

Re: Auto keyword and when to use it

2018-08-20 Thread JN via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:24:19 UTC, QueenSvetlana wrote: I'm new to D programming, but have I have a background with Python. I'm struggling to understand what the auto keyword is for and it's appropriate uses. From research, it seems to share the same capabilities as the var keyword

Auto keyword and when to use it

2018-08-20 Thread QueenSvetlana via Digitalmars-d-learn
I'm new to D programming, but have I have a background with Python. I'm struggling to understand what the auto keyword is for and it's appropriate uses. From research, it seems to share the same capabilities as the var keyword in C#. From the C# documentation, it states: https

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
n the compiler. > > I could not find any elucidation of the meaning of > > auto > > when used as a return type of a function. It's not valid D code. The ddoc version of the documentation shows the actual signature: https://dlang.org/phobos/std_stdio.html#byChunk If t

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:27:07 UTC, Adam D. Ruppe wrote: But remember, this is documentation that just happens to look like code, so it is intended to be legible by people rather than the compiler. I could not find any elucidation of the meaning of auto when used as a return type

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:16:14 UTC, kdevel wrote: But that indented "code" is not syntactically valid D. Isn't it? Right, it would give an error if actually compiled. But remember, this is documentation that just happens to look like code, so it is intended to be legible by people

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:06:16 UTC, Adam D. Ruppe wrote: On Friday, 3 August 2018 at 16:58:26 UTC, kdevel wrote: What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? It looks like ddox trying

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 16:58:26 UTC, kdevel wrote: What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? It looks like ddox trying to tell you what the auto actually is. But it returns

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Alex via Digitalmars-d-learn
On Friday, 3 August 2018 at 16:58:26 UTC, kdevel wrote: What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? Is that a (forward) declaration of a function named byChunk taking a single ulong argument

What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread kdevel via Digitalmars-d-learn
What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? Is that a (forward) declaration of a function named byChunk taking a single ulong argument name chunkSize. But what does that function return?

Re: Is there any tool that will auto publish my changes.

2018-07-16 Thread Venkat via Digitalmars-d-learn
Thankyou Ali. Timoses. I did try DiamondMVC for a bit, but I found that there is more help out there for Vibe.d. So I reverted back to using that. And the Dependency Injection in Diamond MVC brings all the obscurity that spring has which makes debugging more of a guessing game than a

Re: Is there any tool that will auto publish my changes.

2018-07-16 Thread aliak00 via Digitalmars-d-learn
On Monday, 16 July 2018 at 08:28:06 UTC, Timoses wrote: On Sunday, 15 July 2018 at 00:25:22 UTC, Venkat wrote: [...] I don't believe there currently exists a tool to rebuild the Diet templates on the fly. The Diet templates require a step during compilation (I think), so that the entire

Re: Is there any tool that will auto publish my changes.

2018-07-16 Thread Timoses via Digitalmars-d-learn
On Sunday, 15 July 2018 at 00:25:22 UTC, Venkat wrote: I am writing a simple vibe.d app. The following is what I do right now. - I make changes. - build - Restart the server. Is there any tool that will auto publish my changes as I save them ? I am using Visual Studio Code. Thanks Venkat

Re: Is there any tool that will auto publish my changes.

2018-07-16 Thread evilrat via Digitalmars-d-learn
On Sunday, 15 July 2018 at 00:25:22 UTC, Venkat wrote: I am writing a simple vibe.d app. The following is what I do right now. - I make changes. - build - Restart the server. Is there any tool that will auto publish my changes as I save them ? I am using Visual Studio Code. Thanks Venkat

Re: Is there any tool that will auto publish my changes.

2018-07-15 Thread Venkat via Digitalmars-d-learn
An extension to the question. Is something like auto publish that even possible ? Or the dumb guy from java world don't know what he talkin' 'bout ?

Is there any tool that will auto publish my changes.

2018-07-14 Thread Venkat via Digitalmars-d-learn
I am writing a simple vibe.d app. The following is what I do right now. - I make changes. - build - Restart the server. Is there any tool that will auto publish my changes as I save them ? I am using Visual Studio Code. Thanks Venkat

Re: Inference of auto storage classes for interface function return type

2018-07-04 Thread ag0aep6g via Digitalmars-d-learn
On 07/04/2018 05:59 PM, Timoses wrote: There's an empty 19.10.10 point without content[3] : D. Maybe a placeholder? [...] [3]: https://dlang.org/spec/function.html#inout-functions Just a bug. https://github.com/dlang/dlang.org/pull/2407

Re: Inference of auto storage classes for interface function return type

2018-07-04 Thread Timoses via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 15:12:15 UTC, Jonathan M Davis wrote: You can make opIndex inout instead of const. That way, inout applies to the invisible this reference, just like it would with const. Awww, thanks! I was kinda hovering around this[1] section and didn't quite see the

Re: Inference of auto storage classes for interface function return type

2018-07-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 04, 2018 14:07:35 Timoses via Digitalmars-d-learn wrote: > How can I return inferred storage class from interface functions? > I can't use auto as return value in interface. Neither can I use > "inout" as I don't pass a parameter. > > // Re

Re: Inference of auto storage classes for interface function return type

2018-07-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 14:07:35 UTC, Timoses wrote: How can I return inferred storage class from interface functions? I can't use auto as return value in interface. Neither can I use "inout" as I don't pass a parameter. // Ref Type inte

Inference of auto storage classes for interface function return type

2018-07-04 Thread Timoses via Digitalmars-d-learn
How can I return inferred storage class from interface functions? I can't use auto as return value in interface. Neither can I use "inout" as I don't pass a parameter. // Ref Type interface IRef { Ref opIndex(size_t idx) const; }

Re: auto & class members

2018-05-22 Thread Steven Schveighoffer via Digitalmars-d-learn
hat may make more sense (both for type sanity and for code reuse) is to wrap your call to filter into one place so it can be used wherever you need it: auto wrapStream(S)(S str) { return str.filter!(x => x == myMessage); } class b {     typeof(wrapStream(a.init.myStream)()) mySubStream; } void myF

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:40:55 Robert M. Münch via Digitalmars-d-learn wrote: > This would require one wrap function per different lambda, right? > Assume I have 50-100 of these. Maybe the myMessage value can be given > as parameter and with this becomes more like a "filter factory". Not >

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:43:38 Robert M. Münch via Digitalmars-d-learn wrote: > On 2018-05-21 20:17:04 +, Jonathan M Davis said: > > On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- > > > > learn wrote: > >> Well one thing that seems clear from this example -- we

Re: auto & class members

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
and for code reuse) is to wrap your call to filter into one place so it can be used wherever you need it: auto wrapStream(S)(S str) { return str.filter!(x => x == myMessage); } class b { typeof(wrapStream(a.init.myStream)()) mySubStream; } void myFunc() { a myA = new a; b myB = ne

Re: auto & class members

2018-05-22 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 20:17:04 +, Jonathan M Davis said: On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- learn wrote: Well one thing that seems clear from this example -- we now have __traits(isSame) to tell if lambdas are the same, but it looks like the compiler doesn't

<    1   2   3   4   5   6   7   >