Re: Bug?

2020-05-04 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 5 May 2020 at 04:02:06 UTC, RazvanN wrote: truct K { ~this() nothrow {} } void main() { static class C { this(K, int) {} } static int foo(bool flag) { if (flag) throw new Exception("hello"); return 1; } try {

Bug?

2020-05-04 Thread RazvanN via Digitalmars-d-learn
truct K { ~this() nothrow {} } void main() { static class C { this(K, int) {} } static int foo(bool flag) { if (flag) throw new Exception("hello"); return 1; } try { new C(K(), foo(true)); }

Re: Compilation memory use

2020-05-04 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 4 May 2020 at 17:00:21 UTC, Anonymouse wrote: TL;DR: Is there a way to tell what module or other section of a codebase is eating memory when compiling? I'm keeping track of compilation memory use using zsh `time` with some environmental variables. It typically looks like this.

Re: countUntil with negated pre-defined predicate?

2020-05-04 Thread Robert M. Münch via Digitalmars-d-learn
On 2020-05-03 21:59:54 +, Harry Gillanders said: I'm unsure as to which part is unclear, Well, I was trapped by this formatting/syntax: size_t drawableCharacterCount (CodePoints) (auto ref CodePoints codePoints) if (isInputRange!CodePoints && is(ElementType!CodePoints :

Compilation memory use

2020-05-04 Thread Anonymouse via Digitalmars-d-learn
TL;DR: Is there a way to tell what module or other section of a codebase is eating memory when compiling? I'm keeping track of compilation memory use using zsh `time` with some environmental variables. It typically looks like this. ``` $ time dub build -c dev Performing "debug" build using

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread kinke via Digitalmars-d-learn
On Monday, 4 May 2020 at 11:50:49 UTC, Steven Schveighoffer wrote: I'm not sure if Ali is referring to this, but the usage of scope to allocate on the stack was at one time disfavored by the maintainers. This is why std.typecons.scoped was added (to hopefully remove that feature). Though, if

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, May 04, 2020 at 09:33:27AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > Now it's news to me that 'new' does not allocate on the heap when > 'scope' is used. I'm not sure I'm comfortable with it but that's true. > Is this unique? Otherwise, 'new' always allocates on the heap,

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/4/20 12:33 PM, Ali Çehreli wrote: Now it's news to me that 'new' does not allocate on the heap when 'scope' is used. I'm not sure I'm comfortable with it but that's true. Is this unique? Otherwise, 'new' always allocates on the heap, no? This feature was in D1 AFAIK. So it's really old

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 5/4/20 2:47 AM, Olivier Pisano wrote: On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote: On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote: > I think you want to use scope rather than auto which will put the class > on the stack

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/4/20 5:47 AM, Olivier Pisano wrote: On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote: On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote: > I think you want to use scope rather than auto which will put the class > on the stack

Re: How can I check if an element is iterable?

2020-05-04 Thread Marcone via Digitalmars-d-learn
On Monday, 4 May 2020 at 01:49:28 UTC, Ali Çehreli wrote: On 5/3/20 1:44 PM, Marcone wrote: [...] Still, the type of a variable would determine whether whether it's iterable. As an improvement, the following program can be changed to call use() recursively to visit all members of e.g.

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Olivier Pisano via Digitalmars-d-learn
On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote: On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote: > I think you want to use scope rather than auto which will put the class > on the stack and call its destructor: >

Re: Idomatic way to guarantee to run destructor?

2020-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote: > I think you want to use scope rather than auto which will put the class > on the stack and call its destructor: > https://dlang.org/spec/attribute.html#scope That is correct about

Re: countUntil with negated pre-defined predicate?

2020-05-04 Thread Ali Çehreli via Digitalmars-d-learn
On 5/3/20 2:59 PM, Harry Gillanders wrote:> On Sunday, 3 May 2020 at 12:19:30 UTC, Robert M. Münch wrote: > an `auto ref` parameter[1] in a > function template is essentially a parameter that receives the > argument by reference if the templated type is a value-type, Please replace "a