Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:53:02 UTC, Vijay Nayar wrote: This particular use of "scope" I overheard at the last DConf, and I believe it has been added to the official documentation here: https://dlang.org/spec/expression.html#new_expressions If a NewExpression is used as an

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Ali Çehreli via Digitalmars-d-learn
On 10/17/2018 01:53 PM, Vijay Nayar wrote: > https://dlang.org/spec/expression.html#new_expressions > > If a NewExpression is used as an initializer for a function local > variable with > scope storage class, and the ArgumentList to new is empty, then the > instance is > allocated

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:41:24 UTC, Ali Çehreli wrote: On 10/17/2018 01:24 PM, Vijay Nayar wrote: I have a snippet of code like this:     scope chordAngle = new S1ChordAngle(_center, other._center);     return _radius + other._radius >= chordAngle; The reason the "scope"

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:51:29 UTC, Stanislav Blinov wrote: On Wednesday, 17 October 2018 at 20:24:56 UTC, Vijay Nayar wrote: I have a snippet of code like this: scope chordAngle = new S1ChordAngle(_center, other._center); return _radius + other._radius >= chordAngle; The

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 20:24:56 UTC, Vijay Nayar wrote: I have a snippet of code like this: scope chordAngle = new S1ChordAngle(_center, other._center); return _radius + other._radius >= chordAngle; The reason the "scope" temporary variable exists is to avoid a heap

Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Vijay Nayar via Digitalmars-d-learn
I have a snippet of code like this: scope chordAngle = new S1ChordAngle(_center, other._center); return _radius + other._radius >= chordAngle; The reason the "scope" temporary variable exists is to avoid a heap allocation and instead prefer a value be created on the stack. Is there a

Re: Can Scope Be Used for Anonymous Objects?

2018-10-17 Thread Ali Çehreli via Digitalmars-d-learn
On 10/17/2018 01:24 PM, Vijay Nayar wrote: I have a snippet of code like this:     scope chordAngle = new S1ChordAngle(_center, other._center);     return _radius + other._radius >= chordAngle; The reason the "scope" temporary variable exists is to avoid a heap allocation and instead prefer