Re: Encapsulate return value in scoped

2015-06-18 Thread Yuxuan Shui via Digitalmars-d-learn
On Friday, 19 June 2015 at 00:00:50 UTC, Ali Çehreli wrote: On 06/18/2015 04:53 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 21:38:59 UTC, Ali Çehreli wrote: About returning scoped!C, I think it works: I just find out that the document of scoped says that It's Thanks for fixing the

Re: Encapsulate return value in scoped

2015-06-18 Thread Ali Çehreli via Digitalmars-d-learn
On 06/18/2015 05:25 PM, Yuxuan Shui wrote: What problem can moving a scoped cause when there's no reference to its inner class? I am curious as well. Could it be related to the object's 'monitor'? Perhaps some other code may have a reference to monitor? And that reference does not

Re: Encapsulate return value in scoped

2015-06-18 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 21:38:59 UTC, Ali Çehreli wrote: On 06/11/2015 12:51 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 19:23:49 UTC, Ali Çehreli wrote: [...] Can you explain more about why the destructor is not called when returning a struct? Are you asking in general or

Re: Encapsulate return value in scoped

2015-06-18 Thread Ali Çehreli via Digitalmars-d-learn
On 06/18/2015 04:53 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 21:38:59 UTC, Ali Çehreli wrote: About returning scoped!C, I think it works: I just find out that the document of scoped says that It's Thanks for fixing the typo there. (The documentations has lower case: it's. ;) )

Re: Encapsulate return value in scoped

2015-06-11 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A x = scoped!A(10); use auto x = scoped!A(10);

Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
Is there a way to encapsulate return value into scoped? Say I have a function that returns a new object: X new_x(T t...) { //Super complex input processing return new X(something); } And I want to encapsulate the result using scoped, is that possible? Can I just do: return scoped

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 08:48:22 UTC, Yuxuan Shui wrote: Is there a way to encapsulate return value into scoped? Say I have a function that returns a new object: X new_x(T t...) { //Super complex input processing return new X(something); } And I want to encapsulate the result

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A x = scoped!A(10); use auto x = scoped!A(10); Thanks! Curious question, why doesn't compiler reject

Re: Encapsulate return value in scoped

2015-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A x = scoped!A(10); use auto x = scoped!A(10); Thanks! Curious

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: A

Re: Encapsulate return value in scoped

2015-06-11 Thread Ali Çehreli via Digitalmars-d-learn
On 06/11/2015 11:43 AM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11 Jun 2015 09:01:04 + Yuxuan Shui via Digitalmars-d-learn

Re: Encapsulate return value in scoped

2015-06-11 Thread Yuxuan Shui via Digitalmars-d-learn
On Thursday, 11 June 2015 at 19:23:49 UTC, Ali Çehreli wrote: On 06/11/2015 11:43 AM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 17:34:56 UTC, Steven Schveighoffer wrote: On 6/11/15 1:28 PM, Yuxuan Shui wrote: On Thursday, 11 June 2015 at 09:11:47 UTC, Daniel Kozák wrote: On Thu, 11