digitalmars.D.learn - What's the purpose of the 'in' keyword ?
- loloof64 (9/9) May 27 2018 Hello everyone,
- rikki cattermole (2/15) May 27 2018 https://dlang.org/spec/function.html#parameters
- loloof64 (2/17) May 27 2018 Thank you very much : I'm going to look at it right now.
- Adam D. Ruppe (5/7) May 27 2018 It means you are taking the parameter in to look at, but not
- Russel Winder (14/23) May 27 2018 Is there an easy set of "rules" as to when to use 'const' and when to us...
- Jonathan M Davis (34/50) May 27 2018 Honestly, I'd suggest that folks never use in at this point. There's zer...
- eastanon (6/20) May 28 2018 I really find these type of descriptions to be really useful and
- Q. Schroll (3/7) May 30 2018 Exactly. If you intend const, just write const. If you intend
- aberba (4/10) May 30 2018 Jonathan, which font were you using in your DConf powerpoint
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/16) May 30 2018 The pdf file has that information in it:
- Jonathan M Davis (10/25) May 30 2018 Well, that's cool - especially since properly telling someone what the f...
- Jonathan M Davis (8/20) May 30 2018 I'd point you to my reply to Ali, since what he figured out will probabl...
Hello everyone, I've just completed the language tour, and I am starting a tutorial in order to use Gtk binding. But somewhere, they use the 'in' keyword for the constructor : (https://sites.google.com/site/gtkdtutorial/#chapter2 : in section 3 for Buttons and Callbacks, main.d snippet). What's the purpose of this 'in' keyword ? I could not process a good Google request to get an answer. Regards
May 27 2018
On 28/05/2018 1:02 AM, loloof64 wrote:Hello everyone, I've just completed the language tour, and I am starting a tutorial in order to use Gtk binding. But somewhere, they use the 'in' keyword for the constructor : (https://sites.google.com/site/gtkdtutorial/#chapter2 : in section 3 for Buttons and Callbacks, main.d snippet). What's the purpose of this 'in' keyword ? I could not process a good Google request to get an answer. Regardshttps://dlang.org/spec/function.html#parameters
May 27 2018
On Sunday, 27 May 2018 at 13:04:54 UTC, rikki cattermole wrote:On 28/05/2018 1:02 AM, loloof64 wrote:Thank you very much : I'm going to look at it right now.Hello everyone, I've just completed the language tour, and I am starting a tutorial in order to use Gtk binding. But somewhere, they use the 'in' keyword for the constructor : (https://sites.google.com/site/gtkdtutorial/#chapter2 : in section 3 for Buttons and Callbacks, main.d snippet). What's the purpose of this 'in' keyword ? I could not process a good Google request to get an answer. Regardshttps://dlang.org/spec/function.html#parameters
May 27 2018
On Sunday, 27 May 2018 at 13:02:23 UTC, loloof64 wrote:What's the purpose of this 'in' keyword ? I could not process a good Google request to get an answer.It means you are taking the parameter in to look at, but not modify or store. Basically "const". (well, for now, literally "const" but that can change with other details)
May 27 2018
On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:On Sunday, 27 May 2018 at 13:02:23 UTC, loloof64 wrote:Is there an easy set of "rules" as to when to use 'const' and when to use 'in'? In a situation where there are multiple ways of expressing the same concept there needs to be idioms to guide people to do the right thing in a given context. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t:+44 20 7585 2200 41 Buckmaster Road m:+44 7770 465 077 London SW11 1EN, UK w: www.russel.org.ukWhat's the purpose of this 'in' keyword ? I could not process a=20 good Google request to get an answer.=20 It means you are taking the parameter in to look at, but not=20 modify or store. =20 Basically "const". (well, for now, literally "const" but that can=20 change with other details)
May 27 2018
On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:Honestly, I'd suggest that folks never use in at this point. There's zero benefit to it. In principle, in was supposed to be const scope, but scope has never really done anything for anything other than delegates, so there has been no reason to use it over const. However, many folks seem to like it based on the idea that it was the opposite of out - and some folks used it based n what they expected scope to end up meaning whenever it finally got implemented for more than just delegates. Either way, it didn't actually buy them anything as long as scope has done nothing. Now with DIP 1000, scope is actually starting to mean something, but there's the concern that enabling scope for all of the places that in was used would break a lot of code. So, the spec now says that in means const rather than const scope, and as I undertand it, for the most part, the compiler doesn't treat it as scope anywhere aside from a a few buggy cases (even when -dip1000 is used). Some folks are not happy about that, and the situation may yet change (heck, we haven't even figured out how to switch to -dip1000 being the default without breaking everyone in the process yet - e.g. it's not ABI compatible with code that's not compiled with -dip1000, because it mangles differently). So, we can't really say what in is going to end up meaning when the dust settles. Ultimately, it may permanently just be const, or it may end up actually being const scope. But it's never actually bought you anything over using const (other than being shorted), and if it does end up becoming const scope, you're almost certainly going to have to fix a lot of the code that you wrote using in. So, I really don't think that it's a good idea to use in at all, but there are definitely folks who disagree with me, some of whom very much hope that it ends up meaning const scope and who want it to break their code if/when it does if there's any kind of escaping in their code - though given how confusing -dip1000 seems to be for many folks, I seriously question that much code using in would just work if it's changed to properly mean const scope or that all that many programmers using in understand scope well enough to use it correctly. - Jonathan M DavisOn Sunday, 27 May 2018 at 13:02:23 UTC, loloof64 wrote:Is there an easy set of "rules" as to when to use 'const' and when to use 'in'? In a situation where there are multiple ways of expressing the same concept there needs to be idioms to guide people to do the right thing in a given context.What's the purpose of this 'in' keyword ? I could not process a good Google request to get an answer.It means you are taking the parameter in to look at, but not modify or store. Basically "const". (well, for now, literally "const" but that can change with other details)
May 27 2018
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:I really find these type of descriptions to be really useful and insightful. Going through the D textbooks can leave someone a little confused on when to use what and where? D has so many keywords and as a beginner it can be overwhelming. Thank you for your insights.[...]Honestly, I'd suggest that folks never use in at this point. There's zero benefit to it. In principle, in was supposed to be const scope, but scope has never really done anything for anything other than delegates, so there has been no reason to use it over const. However, many folks seem to like it based on the idea that it was the opposite of out - and some folks used it based n what they expected scope to end up meaning whenever it finally got implemented for more than just delegates. Either way, it didn't actually buy them anything as long as scope has done nothing. [...]
May 28 2018
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:[...] Honestly, I'd suggest that folks never use in at this point. There's zero benefit to it. [...]Exactly. If you intend const, just write const. If you intend const scope, write const scope.
May 30 2018
On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:Jonathan, which font were you using in your DConf powerpoint presentation for source code? It made the code look really nice...and also you have good naming skills.On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn- Jonathan M Davis
May 30 2018
On 05/30/2018 03:16 PM, aberba wrote:On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:The pdf file has that information in it: http://www.identifont.com/similar?76H AliOn Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:Jonathan, which font were you using in your DConf powerpoint presentation for source code? It made the code look really nice...and also you have good naming skills.On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn- Jonathan M Davis
May 30 2018
On Wednesday, May 30, 2018 15:28:53 Ali Çehreli via Digitalmars-d-learn wrote:On 05/30/2018 03:16 PM, aberba wrote:Well, that's cool - especially since properly telling someone what the font was is kind of hard anyway, since I used latex to generate the slides, and you don't normally select a font directly with latex (rather, normally, you select a font family). I used the beamer package to generate the slides and the listings package for the code blocks. The code blocks were then configured to use \ttfamily for the font, so it's whatever gets selected for the ttfamily family of fonts. - Jonathan M DavisOn Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:The pdf file has that information in it: http://www.identifont.com/similar?76HOn Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:Jonathan, which font were you using in your DConf powerpoint presentation for source code? It made the code look really nice...and also you have good naming skills.On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn- Jonathan M Davis
May 30 2018
On Wednesday, May 30, 2018 22:16:28 aberba via Digitalmars-d-learn wrote:On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote:I'd point you to my reply to Ali, since what he figured out will probably tell you better than I could.On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote:Jonathan, which font were you using in your DConf powerpoint presentation for source code? It made the code look really nice...On Sun, 2018-05-27 at 13:10 +0000, Adam D. Ruppe via Digitalmars-d-learn- Jonathan M Davisand also you have good naming skills.Thanks. I'm glad that someone thinks so. Naming is pretty much the king of bikeshedding in programming, and I've been in far too many arguments on that topic before. Far too often, it seems like no matter what you name something, someone is going to think that the name is terrible. - Jonathan M Davis
May 30 2018