Idiomatic D

2014-01-10 Thread NoUseForAName
ings. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someone please just give me the cliff notes on how to D properly?

Re: Idiomatic D

2014-01-10 Thread qznc
away by just looking up a few basic syntax/standard library things. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someo

Re: Idiomatic D

2014-01-10 Thread Paulo Pinto
few basic syntax/standard library things. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someone please just give me the

Re: Idiomatic D

2014-01-10 Thread Ali Çehreli
On 01/10/2014 02:52 PM, NoUseForAName wrote: I would like to write idiomatic D code, not "C++ in D". I like this style: http://wiki.dlang.org/Component_programming_with_ranges Ali

Re: Idiomatic D

2014-01-10 Thread Kelet
away by just looking up a few basic syntax/standard library things. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someo

Re: Idiomatic D

2014-01-10 Thread Kelet
On Friday, 10 January 2014 at 23:16:10 UTC, Kelet wrote: foreach(immutable i = 0; 0..20) OR Oops, meant foreach(immutable i; 0..20)

Re: Idiomatic D

2014-01-10 Thread Brad Anderson
away by just looking up a few basic syntax/standard library things. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someo

Re: Idiomatic D

2014-01-10 Thread qznc
On Friday, 10 January 2014 at 23:16:10 UTC, Kelet wrote: - Many of the examples on Rosetta Code are well-written http://rosettacode.org/wiki/Category:D I think bearophile did many of them. Contributing to Rosetta Code is a great way to learn idiomatic code. Write one of the missing programs [

Re: Idiomatic D

2014-01-10 Thread deadalnix
away by just looking up a few basic syntax/standard library things. However, I would like to write idiomatic D code, not "C++ in D". Is there any guide for this? If not, I would like to say that I think having one would be very useful. Assuming a lack of an extensive guide could someo

Re: Idiomatic D

2014-01-10 Thread NoUseForAName
On Friday, 10 January 2014 at 22:52:36 UTC, NoUseForAName wrote: [snip] Wow, that is a lot of information to process. Thanks everyone!

C++ Expected converted to idiomatic D

2018-08-16 Thread Per Nordlöw via Digitalmars-d
In https://www.youtube.com/watch?v=nVzgkepAg5Y Andrei describes his proposal for STL `Expected` planned to be included in C++20. Have anybody converted the C++ proposal to idiomatic D, yet? Hopefully without the pointer-legacy which unfortunately was allowed into `std:optional`. Andrei

Compilation times and idiomatic D code

2017-07-05 Thread H. S. Teoh via Digitalmars-d
Over time, what is considered "idiomatic D" has changed, and nowadays it seems to be leaning heavily towards range-based code with UFCS chains using std.algorithm and similar reusable pieces of code. D (well, DMD specifically) is famed for its lightning speed compilation times. So th

Re: C++ Expected converted to idiomatic D

2018-08-27 Thread Paul Backus via Digitalmars-d
On Thursday, 16 August 2018 at 20:37:33 UTC, Per Nordlöw wrote: In https://www.youtube.com/watch?v=nVzgkepAg5Y Andrei describes his proposal for STL `Expected` planned to be included in C++20. Have anybody converted the C++ proposal to idiomatic D, yet? Hopefully without the pointer-legacy

Re: C++ Expected converted to idiomatic D

2018-08-28 Thread John Colvin via Digitalmars-d
On Thursday, 16 August 2018 at 20:37:33 UTC, Per Nordlöw wrote: In https://www.youtube.com/watch?v=nVzgkepAg5Y Andrei describes his proposal for STL `Expected` planned to be included in C++20. Have anybody converted the C++ proposal to idiomatic D, yet? Hopefully without the pointer-legacy

Re: C++ Expected converted to idiomatic D

2018-08-28 Thread Per Nordlöw via Digitalmars-d
On Tuesday, 28 August 2018 at 10:18:29 UTC, John Colvin wrote: I get the feeling from the talk that Andrei has some opinions about how it should be done that aren't completely in line with what has been proposed for the C++ standard. Anyhow my implementation at https://github.com/nordlow/phob

Re: Compilation times and idiomatic D code

2017-07-05 Thread Stefan Koch via Digitalmars-d
On Wednesday, 5 July 2017 at 20:12:40 UTC, H. S. Teoh wrote: I vaguely remember there was talk about compressing symbols when they get too long... is there any hope of seeing this realized in the near future? Yes there is. Rainer Schuetze is quite close to a solution. Which reduces the symb

Re: Compilation times and idiomatic D code

2017-07-05 Thread kinke via Digitalmars-d
On Wednesday, 5 July 2017 at 20:12:40 UTC, H. S. Teoh wrote: I vaguely remember there was talk about compressing symbols when they get too long... is there any hope of seeing this realized in the near future? LDC has an experimental feature replacing long names by their hash; ldc2 -help: ...

Re: Compilation times and idiomatic D code

2017-07-05 Thread jmh530 via Digitalmars-d
On Wednesday, 5 July 2017 at 20:32:08 UTC, Stefan Koch wrote: Yes there is. Rainer Schuetze is quite close to a solution. Which reduces the symbol-name bloat significantly. See https://github.com/dlang/dmd/pull/5855 A table in the comments [1] shows a significant reduction in bloat when c

Re: Compilation times and idiomatic D code

2017-07-05 Thread H. S. Teoh via Digitalmars-d
On Wed, Jul 05, 2017 at 09:18:45PM +, jmh530 via Digitalmars-d wrote: > On Wednesday, 5 July 2017 at 20:32:08 UTC, Stefan Koch wrote: > > > > Yes there is. > > Rainer Schuetze is quite close to a solution. Which reduces the > > symbol-name bloat significantly. > > See https://github.com/dlang/

Re: Compilation times and idiomatic D code

2017-07-05 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, July 05, 2017 13:12:40 H. S. Teoh via Digitalmars-d wrote: [...] > IOW, the very range-based idiom that has become one of the defining > characteristics of modern D is negating the selling point of fast > compilation. > > I vaguely remember there was talk about compressing symbols whe

Re: Compilation times and idiomatic D code

2017-07-06 Thread Jacob Carlborg via Digitalmars-d
On 2017-07-05 22:12, H. S. Teoh via Digitalmars-d wrote: Over time, what is considered "idiomatic D" has changed, and nowadays it seems to be leaning heavily towards range-based code with UFCS chains using std.algorithm and similar reusable pieces of code. It's not UFCS per say

Re: Compilation times and idiomatic D code

2017-07-06 Thread Atila Neves via Digitalmars-d
On Thursday, 6 July 2017 at 12:00:29 UTC, Jacob Carlborg wrote: On 2017-07-05 22:12, H. S. Teoh via Digitalmars-d wrote: [...] It's not UFCS per say that causes the problem. If you're using the traditional calling syntax it would generate the same symbols. [...] Yeah, it's usually all t

Re: Compilation times and idiomatic D code

2017-07-06 Thread H. S. Teoh via Digitalmars-d
On Thu, Jul 06, 2017 at 01:32:04PM +, Atila Neves via Digitalmars-d wrote: > On Thursday, 6 July 2017 at 12:00:29 UTC, Jacob Carlborg wrote: [...] > > Yeah, it's usually all these D specific compile time features that > > is slowing down compilation. > > > > DWT and Tango are two good examples

Re: Compilation times and idiomatic D code

2017-07-06 Thread John Colvin via Digitalmars-d
On Wednesday, 5 July 2017 at 20:32:08 UTC, Stefan Koch wrote: On Wednesday, 5 July 2017 at 20:12:40 UTC, H. S. Teoh wrote: I vaguely remember there was talk about compressing symbols when they get too long... is there any hope of seeing this realized in the near future? Yes there is. Rainer

Re: Compilation times and idiomatic D code

2017-07-07 Thread Steven Schveighoffer via Digitalmars-d
On 7/5/17 5:24 PM, H. S. Teoh via Digitalmars-d wrote: On Wed, Jul 05, 2017 at 09:18:45PM +, jmh530 via Digitalmars-d wrote: On Wednesday, 5 July 2017 at 20:32:08 UTC, Stefan Koch wrote: Yes there is. Rainer Schuetze is quite close to a solution. Which reduces the symbol-name bloat signifi

Re: Compilation times and idiomatic D code

2017-07-07 Thread H. S. Teoh via Digitalmars-d
On Fri, Jul 07, 2017 at 09:32:24AM -0400, Steven Schveighoffer via Digitalmars-d wrote: > On 7/5/17 5:24 PM, H. S. Teoh via Digitalmars-d wrote: > > On Wed, Jul 05, 2017 at 09:18:45PM +, jmh530 via Digitalmars-d wrote: > > > On Wednesday, 5 July 2017 at 20:32:08 UTC, Stefan Koch wrote: [...] >

Re: Compilation times and idiomatic D code

2017-07-13 Thread H. S. Teoh via Digitalmars-d
On Wed, Jul 05, 2017 at 09:45:55PM -0600, Jonathan M Davis via Digitalmars-d wrote: [...] > In this case, I think that it's more that Voldemort types are biting > us than that ranges are biting us (though the Voldemort types are > typically ranges, so in practice, using ranges ends up biting you).

Re: Compilation times and idiomatic D code

2017-07-13 Thread Steven Schveighoffer via Digitalmars-d
On 7/13/17 3:23 PM, H. S. Teoh via Digitalmars-d wrote: Today, I decided to sit down and refactor my code. I've heard tell that Voldemort types tend to cause an explosion in symbol size, and today I thought it'd be interesting to see just how big of a difference this actually makes. I could not

Re: Compilation times and idiomatic D code

2017-07-13 Thread H. S. Teoh via Digitalmars-d
On Thu, Jul 13, 2017 at 04:16:50PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] > http://www.schveiguy.com/blog/2016/05/have-your-voldemort-types-and-keep-your-disk-space-too/ > > I was surprised as well at the reduction. I only noticed the problem > because when I was debugging my

Re: Compilation times and idiomatic D code

2017-07-14 Thread H. S. Teoh via Digitalmars-d
On Thu, Jul 13, 2017 at 03:27:31PM -0700, H. S. Teoh via Digitalmars-d wrote: > On Thu, Jul 13, 2017 at 04:16:50PM -0400, Steven Schveighoffer via > Digitalmars-d wrote: > [...] > > http://www.schveiguy.com/blog/2016/05/have-your-voldemort-types-and-keep-your-disk-space-too/ > [...] > > Whoa. I

Re: Compilation times and idiomatic D code

2017-07-14 Thread Stefan Koch via Digitalmars-d
On Friday, 14 July 2017 at 22:45:44 UTC, H. S. Teoh wrote: On Thu, Jul 13, 2017 at 03:27:31PM -0700, H. S. Teoh via Digitalmars-d wrote: [...] [...] Here's a further update to the saga of combating ridiculously large symbol sizes. [...] You will be excited to hear that my template work wi

Re: Compilation times and idiomatic D code

2017-07-14 Thread H. S. Teoh via Digitalmars-d
On Fri, Jul 14, 2017 at 03:45:44PM -0700, H. S. Teoh via Digitalmars-d wrote: [...] > Here's a further update to the saga of combating ridiculously large > symbol sizes. [...] >.wrapWithInterface // <--- type erasure happens here [...] Some further thoughts about type erasure and UFCS

Re: Compilation times and idiomatic D code

2017-07-14 Thread Seb via Digitalmars-d
On Friday, 14 July 2017 at 22:45:44 UTC, H. S. Teoh wrote: Result: 8MB executable size (!). Of course, this comes at a runtime cost of an added level of indirection (now you have to call a virtual function through the interface to integrate with earlier components in the pipeline). But at a

Re: Compilation times and idiomatic D code

2017-07-15 Thread Enamex via Digitalmars-d
On Friday, 14 July 2017 at 22:45:44 UTC, H. S. Teoh wrote: Here's a further update to the saga of combating ridiculously large symbol sizes. So yesterday I wrote a new module that also heavily uses UFCS chains. My initial draft of the module, once I linked it with the main program, particular

Re: Compilation times and idiomatic D code

2017-07-15 Thread Stefan Koch via Digitalmars-d
On Saturday, 15 July 2017 at 11:10:32 UTC, Enamex wrote: On Friday, 14 July 2017 at 22:45:44 UTC, H. S. Teoh wrote: [...] I have some stupid questions: - What does everyone mean when they say 'symbol' here? I'm probably misunderstanding symbols gravely or it's something that DMD in particul

Re: Compilation times and idiomatic D code

2017-07-15 Thread Jonathan M Davis via Digitalmars-d
ushed as a great way to encapsulate the range types that result from function calls and really shouldn't be used by name makes the situation that much worse. So, idiomatic D code currently results in very large symbol names, and while in many cases, you don't notice, some people (like H.S. Te

Re: Compilation times and idiomatic D code

2017-07-15 Thread Enamex via Digitalmars-d
On Saturday, 15 July 2017 at 15:58:12 UTC, Jonathan M Davis wrote: On Saturday, July 15, 2017 11:10:32 Enamex via Digitalmars-d wrote: [...] The issue has to do with how each invocation of a range-based function tends to result in a new template instantiation, and it's common practice in D to

Re: Compilation times and idiomatic D code

2017-07-17 Thread jmh530 via Digitalmars-d
On Saturday, 15 July 2017 at 15:58:12 UTC, Jonathan M Davis wrote: int[] a; auto b = a.map!(a => a / 2)(); pragma(msg, typeof(b)); then it prints out MapResult!(__lambda1, int[]) If you have int[] a; auto b = a.map!(a => a / 2)().map!(a => a)(); pragma(msg, typeof

Re: Compilation times and idiomatic D code

2017-07-17 Thread Stefan Koch via Digitalmars-d
On Monday, 17 July 2017 at 12:51:37 UTC, jmh530 wrote: On Saturday, 15 July 2017 at 15:58:12 UTC, Jonathan M Davis wrote: int[] a; auto b = a.map!(a => a / 2)(); pragma(msg, typeof(b)); then it prints out MapResult!(__lambda1, int[]) If you have int[] a; auto b = a.m

Re: Compilation times and idiomatic D code

2017-07-17 Thread Steven Schveighoffer via Digitalmars-d
On 7/14/17 7:30 PM, H. S. Teoh via Digitalmars-d wrote: On Fri, Jul 14, 2017 at 03:45:44PM -0700, H. S. Teoh via Digitalmars-d wrote: [...] Here's a further update to the saga of combating ridiculously large symbol sizes. [...] .wrapWithInterface // <--- type erasure happens here

Re: Compilation times and idiomatic D code

2017-07-17 Thread H. S. Teoh via Digitalmars-d
On Sat, Jul 15, 2017 at 07:11:54PM +, Enamex via Digitalmars-d wrote: [...] > All that time I'd assumed that 'symbols' as linkers used them were > constant length :T They may have been once upon a time, many decades ago. :-D But modern linkers support symbols of arbitrary length (well, up to

Re: Compilation times and idiomatic D code

2017-07-18 Thread Olivier FAURE via Digitalmars-d
On Monday, 17 July 2017 at 18:42:36 UTC, H. S. Teoh wrote: Besides the symbol problem though, does the template instantiation explosion problem imply as many duplicated function bodies corresponding to the new type symbols? That's a different, though somewhat related, issue. I have some idea

Talk proposal (kinda): D Programming in D (Or: Writing idiomatic D code)

2012-11-21 Thread Leandro Motta Barros
Hello everyone! Well, this is actually a "talk proposal for someone else". I'd be the audience, not the speaker. TITLE: D Programming in D (Or: Writing idiomatic D code) ABSTRACT: Every language has its own sanctified idioms. Beginners learning a new language tend to use th

Re: Talk proposal (kinda): D Programming in D (Or: Writing idiomatic D code)

2012-11-21 Thread Joshua Niehus
On Wednesday, 21 November 2012 at 18:42:55 UTC, Leandro Motta Barros wrote: Well, this is actually a "talk proposal for someone else". I'd be the audience, not the speaker. TITLE: D Programming in D (Or: Writing idiomatic D code) +1 I'd like to add, maybe put some focus

Re: Talk proposal (kinda): D Programming in D (Or: Writing idiomatic D code)

2012-11-21 Thread Era Scarecrow
On Wednesday, 21 November 2012 at 22:47:02 UTC, Joshua Niehus wrote: On Wednesday, 21 November 2012 at 18:42:55 UTC, Leandro Motta Barros wrote: Well, this is actually a "talk proposal for someone else". I'd be the audience, not the speaker. TITLE: D Programming in D (Or: Writ

Re: Talk proposal (kinda): D Programming in D (Or: Writing idiomatic D code)

2012-11-21 Thread Tavi Cacina
On Wednesday, 21 November 2012 at 18:42:55 UTC, Leandro Motta Barros wrote: TITLE: D Programming in D (Or: Writing idiomatic D code) ABSTRACT: Every language has its own sanctified idioms. Beginners learning a new language tend to use the idioms of the languages they already know in the new

Re: Talk proposal (kinda): D Programming in D (Or: Writing idiomatic D code)

2012-11-22 Thread Joseph Rushton Wakeling
On 11/22/2012 03:13 AM, Era Scarecrow wrote: Perhaps a part on how to properly use D without involving the GC. ... perhaps a part on keeping memory use effectively under control _with_ the GC? (Avoiding all those dangling references, etc...:-)