digitalmars.D.announce - Article: The surprising thing you can do in the D programming language
- aberba (2/2) Aug 20 2020 Wrote something on OpenSource.com
- user1234 (10/12) Aug 20 2020 I'm not sure. A few notes on nesting.
- H. S. Teoh (12/23) Aug 20 2020 The point is not to pollute module namespace with implementation details
- Martin Tschierschke (2/4) Aug 20 2020 Nice article! +1 up-vote!
- MrSmith (3/5) Aug 20 2020 The only nitpick, is that nested functions need to be declared
- aberba (4/10) Aug 20 2020 You're right. Missed that. Copy-pasting and using D and
- Walter Bright (2/5) Aug 21 2020 Very nice! Thank you, Lawrence!
Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-d
Aug 20 2020
On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dI'm not sure. A few notes on nesting. 1. context pointer can prevent inlining. you can nest static funcs, but then what is the point 2. bad complexity. you can make the nested funcs static and factor them out. The code is more readable. 3. lambda. If you want to nest lambda are better. Solves point 2 but not point 1. But otherwie still nice to see a bit of D promotion here and there ;)
Aug 20 2020
On Thu, Aug 20, 2020 at 10:20:59AM +0000, user1234 via Digitalmars-d-announce wrote:On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:The point is not to pollute module namespace with implementation details that are only relevant to that one function. Also, if you're worried about inlining, use LDC instead of DMD. LDC is well able to inline nested functions. Don't make judgments based on the DMD backend; it's well-known that its optimizer is ... sub-optimal...Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dI'm not sure. A few notes on nesting. 1. context pointer can prevent inlining. you can nest static funcs, but then what is the point2. bad complexity. you can make the nested funcs static and factor them out. The code is more readable.[...] The point is not to pollute module namespace with functions that are only relevant as implementation details of one function. T -- First Rule of History: History doesn't repeat itself -- historians merely repeat each other.
Aug 20 2020
On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dNice article! +1 up-vote!
Aug 20 2020
On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dThe only nitpick, is that nested functions need to be declared before use, in order to compile.
Aug 20 2020
On Thursday, 20 August 2020 at 11:22:53 UTC, MrSmith wrote:On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:You're right. Missed that. Copy-pasting and using D and JavaScript at the same time. I've notified that editors, it'll hopefully be corrected soon.Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dThe only nitpick, is that nested functions need to be declared before use, in order to compile.
Aug 20 2020
On 8/20/2020 3:12 AM, aberba wrote:Wrote something on OpenSource.com https://opensource.com/article/20/8/nesting-dVery nice! Thank you, Lawrence!
Aug 21 2020