Re: an extremely naive question regarding synchronized...

2016-11-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/14/16 12:43 PM, WhatMeWorry wrote: I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if (

Re: static array internal & dangling reference

2016-11-14 Thread Picaud Vincent via Digitalmars-d-learn
On Monday, 14 November 2016 at 17:15:43 UTC, Steven Schveighoffer wrote: What has happened is that the stack allocated for f() (and since released) is still referenced by sb[]. In a weird way, since you haven't called any other functions, that data is still "valid"! Thank you for the clarif

an extremely naive question regarding synchronized...

2016-11-14 Thread WhatMeWorry via Digitalmars-d-learn
I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if (instance_ is null) { instance_ = n

Re: static array internal & dangling reference

2016-11-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/14/16 12:53 AM, Picaud Vincent wrote: On Sunday, 13 November 2016 at 23:39:37 UTC, Steven Schveighoffer wrote: Note that he is declaring an int[10] inside the function and then returning it. The compiler must see that the int[10] will be returned, and so it reuses the pre-allocated buffer

Re: Variable-Length Bit-Level Encoding

2016-11-14 Thread Arafel via Digitalmars-d-learn
On Saturday, 12 November 2016 at 19:13:13 UTC, Nordlöw wrote: I'm looking for libraries/snippets (either in D or similar languages) that perform variable-length encoding of unsigned integers onto a bit-stream. Requirement is that smaller inputs (integer values) should be encoded with equal or f

Re: Vibe.d diet template reuse

2016-11-14 Thread Jot via Digitalmars-d-learn
On Monday, 14 November 2016 at 08:28:24 UTC, Sönke Ludwig wrote: Am 03.11.2016 um 06:31 schrieb Jot: [...] The example above should basically work - the included template is inserted into the outer context and can access any functions or variables declared there. Alternatively, you can also

Re: Vibe.d diet template reuse

2016-11-14 Thread Sönke Ludwig via Digitalmars-d-learn
Am 03.11.2016 um 06:31 schrieb Jot: I would like to create some generic diet templates for different html functionality. Some code in the template will need to be setup/changed for it to function properly. How can I write code that allows for one to express generic statements in the template bu