Re: Automatic function body writing howto?

2017-08-17 Thread Oleg B via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 22:48:59 UTC, Meta wrote: It's hard to tell offhand but I would recommend that you extract the inner string into a function that generates that string, allowing you to print out the finished product before mixing it in. It's have a same result...

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-17 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 13:14:55 UTC, Steven Schveighoffer wrote: But that isn't a concern for Variant. It is only calling the postblit, which does work. Shouldn't it call destructor when it goes out of scope?

Re: Implicit conversion from const to mutable

2017-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/17 3:24 PM, Balagopal Komarath wrote: Is it possible to make structs containing slices support implicit conversion from const to mutable? This should "work". I don't think your static assert will pass, but the main function below should run. struct A { int[] a; A dup() const

Re: Implicit conversion from const to mutable

2017-08-17 Thread Balagopal Komarath via Digitalmars-d-learn
On Thursday, 17 August 2017 at 20:22:09 UTC, Steven Schveighoffer wrote: This should "work". I don't think your static assert will pass, but the main function below should run. Thanks. But, isn't my static assert testing for exactly this?

Re: Implicit conversion from const to mutable

2017-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/17 5:28 PM, Balagopal Komarath wrote: On Thursday, 17 August 2017 at 20:22:09 UTC, Steven Schveighoffer wrote: This should "work". I don't think your static assert will pass, but the main function below should run. Thanks. But, isn't my static assert testing for exactly this? I

GtkD: How to respond to cell edit's?

2017-08-17 Thread Johnson Jones via Digitalmars-d-learn
Trying to setup a callback that will propagate changes from a cell(and editable GtkCellRendererText) to my model. Can't seem to find any way to get the actual GtkCellRendererText CellRendererText has an addOnEdited but I can't find a way to get the CellRendererTExt for a TreeViewColumn ;/

Re: GtkD: How to respond to cell edit's?

2017-08-17 Thread Johnson Jones via Digitalmars-d-learn
On Friday, 18 August 2017 at 00:27:05 UTC, Johnson Jones wrote: I should also mention that when I use an ID to do what I want(again, something I don't want to do), I also need to get the column that was edited. This is because I'm using one delegate for all the edits. auto cb =

real simple delegate question.

2017-08-17 Thread WhatMeForget via Digitalmars-d-learn
Can someone explain what is the difference between the two? Thanks. module gates; import std.stdio; import std.random; alias Calculator = int delegate(int); Calculator makeCalculator() { static int context = 0; int randy = uniform(1, 7); context++; writeln("context = ",

Re: D outperformed by C++, what am I doing wrong?

2017-08-17 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote: Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++

Re: GtkD: How to respond to cell edit's?

2017-08-17 Thread Johnson Jones via Digitalmars-d-learn
I should also mention that when I use an ID to do what I want(again, something I don't want to do), I also need to get the column that was edited. This is because I'm using one delegate for all the edits. auto cb = delegate(string index, string text, CellRendererText r) { // How to get

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-17 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 23:15:10 UTC, crimaniak wrote: I wonder if it possible and usable to make some template to support this pattern, where we give mutex(es), shared object(s) and delegate to operate with objects as non-shared. https://dpaste.dzfl.pl/8b3b05c8ec0a like this? Not

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/17 8:41 AM, Kagamin wrote: On Wednesday, 16 August 2017 at 13:14:55 UTC, Steven Schveighoffer wrote: But that isn't a concern for Variant. It is only calling the postblit, which does work. Shouldn't it call destructor when it goes out of scope? You're right, and it does. It uses the

Implicit conversion from const to mutable

2017-08-17 Thread Balagopal Komarath via Digitalmars-d-learn
Is it possible to make structs containing slices support implicit conversion from const to mutable? I tried adding a postblit that dupes the member 'a'. That didn't work. struct A { int[] a; } void main() { static assert (is(const(A) : A)); // fails }