Re: What's the purpose of the 'in' keyword ?
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: > > On Sunday, May 27, 2018 16:28:56 Russel Winder via > > > > Digitalmars-d-learn wrote: > >> On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via > >> Digitalmars-d-learn > > > > - Jonathan M Davis > > Jonathan, which font were you using in your DConf powerpoint > presentation for source code? It made the code look really > nice... I'd point you to my reply to Ali, since what he figured out will probably tell you better than I could. > and 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
Re: What's the purpose of the 'in' keyword ?
On Wednesday, May 30, 2018 15:28:53 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/30/2018 03:16 PM, aberba wrote: > > 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: > >>> On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via > >>> Digitalmars-d-learn > >> > >> - Jonathan M Davis > > > > 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. > > The pdf file has that information in it: > >http://www.identifont.com/similar?76H 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 Davis
Re: What's the purpose of the 'in' keyword ?
On 05/30/2018 03:16 PM, aberba wrote: 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: On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn - Jonathan M Davis 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. The pdf file has that information in it: http://www.identifont.com/similar?76H Ali
Re: What's the purpose of the 'in' keyword ?
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: On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn - Jonathan M Davis 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.
Re: What's the purpose of the 'in' keyword ?
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.
Re: What's the purpose of the 'in' keyword ?
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: [...] 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. [...] 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.
Re: What's the purpose of the 'in' keyword ?
On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote: > On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn > > wrote: > > 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) > > 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. 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 Davis
Re: What's the purpose of the 'in' keyword ?
On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn wrote: > 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) 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. -- Russel. = Dr Russel Winder t:+44 20 7585 2200 41 Buckmaster Road m:+44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: What's the purpose of the 'in' keyword ?
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)
Re: What's the purpose of the 'in' keyword ?
On Sunday, 27 May 2018 at 13:04:54 UTC, rikki cattermole wrote: 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. Regards https://dlang.org/spec/function.html#parameters Thank you very much : I'm going to look at it right now.
Re: What's the purpose of the 'in' keyword ?
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. Regards https://dlang.org/spec/function.html#parameters