This doesn't work:
template A() {
void B() {};
}
template B() {
mixin A!();
}
void main() {
B!()();
}
Is this intentional?
On Saturday, 4 August 2018 at 21:10:32 UTC, Steven Schveighoffer
wrote:
On 8/4/18 4:10 PM, Yuxuan Shui wrote:
This doesn't work:
template A() {
void B() {};
}
template B() {
mixin A!();
}
void main() {
B!()();
}
Is this intentional?
I believe mixin templates introduce a new sy
file1.d:
import std.stdio;
file2.d:
import file1;
pragma(msg, __traits(getProtection, __traits(getMember, m1,
"std"))); // public
pragma(msg, __traits(getProtection, m1.std)); // private
Bug? Intended?
The offending code base is a little big and hard to reduce. I'll
try if code is required, but here is the gist of the problem:
This snippet of code in my project:
...
alias tmp = genCode!T;
enum str = tmp.str; // This line here
...
Generate a circular reference error.
However,
On Saturday, 25 August 2018 at 14:13:18 UTC, rikki cattermole
wrote:
On 26/08/2018 2:10 AM, Yuxuan Shui wrote:
The offending code base is a little big and hard to reduce.
I'll try if code is required, but here is the gist of the
problem:
This snippet of code in my project:
...
alia
Issue filed: https://issues.dlang.org/show_bug.cgi?id=19190
This surprised me A LOT:
https://d.godbolt.org/z/82a_GZ
So if I call something.map!().array, I get an array of delegates?
That makes no sense to me.
In this example:
const(AliasSeq!(int, int)) a;
pragma(msg, typeof(a)); // (int, int)
This kind of make sense, since AliasSeq is not a "single" type.
But silently dropping const seems bad, the compiler should
probably report an error/warning in this case?
On Wednesday, 31 May 2017 at 08:18:07 UTC, Vasileios
Anagnostopoulos wrote:
Hi,
after reading various articles bout the "supposed" drawbacks of
checked exceptions I started to have questions on @nothrow. Why
there exists and not a @throws annotation enforced by the
compiler? I understand that
On Wednesday, 31 May 2017 at 09:31:48 UTC, Jonathan M Davis wrote:
On Wednesday, May 31, 2017 08:18:07 Vasileios Anagnostopoulos
via Digitalmars-d-learn wrote:
[...]
Well, if you're not doing checked exceptions, the interesting
question is really what _doesn't_ throw rather than what
throws,
On Friday, 19 February 2016 at 20:45:23 UTC, jmh530 wrote:
On Friday, 19 February 2016 at 15:00:51 UTC, jmh530 wrote:
This works.
But when I re-write foo to take that into account as in below,
I get an error that I can't implicitly convert int
function(int x) to int function(int x, int y).
On Friday, 19 February 2016 at 21:58:24 UTC, user001 wrote:
Well struct don't have it, but i would like something like it
but only for data, i don't need functions or anything like that
just data.
[...]
How about
struct A
{
int valueA;
}
struct B
{
A a;
int valueB;
alias a
Will typeid(a) is typeid(b) yield different results than
typeid(a) == typeid(b)?
On Thursday, 3 March 2016 at 23:51:16 UTC, Adam D. Ruppe wrote:
On Thursday, 3 March 2016 at 23:46:50 UTC, Yuxuan Shui wrote:
Will typeid(a) is typeid(b) yield different results than
typeid(a) == typeid(b)?
No. Indeed, opEquals on TypeInfo just calls is itself.
But opEquals also has extra co
On Thursday, 3 March 2016 at 23:58:39 UTC, Yuxuan Shui wrote:
On Thursday, 3 March 2016 at 23:51:16 UTC, Adam D. Ruppe wrote:
On Thursday, 3 March 2016 at 23:46:50 UTC, Yuxuan Shui wrote:
Will typeid(a) is typeid(b) yield different results than
typeid(a) == typeid(b)?
No. Indeed, opEquals on
On Friday, 4 March 2016 at 15:18:55 UTC, Steven Schveighoffer
wrote:
On 3/3/16 6:58 PM, Yuxuan Shui wrote:
On Thursday, 3 March 2016 at 23:51:16 UTC, Adam D. Ruppe wrote:
On Thursday, 3 March 2016 at 23:46:50 UTC, Yuxuan Shui wrote:
Will typeid(a) is typeid(b) yield different results than
type
For example
struct A{}
@safe void main(){
import std.stdio;
A a, b;
auto y = typeid(a);
y.name = "Nope, I'm not A";
auto x = typeid(b);
writeln(x);
}
Make changes to TypeInfo will affect all the future typeid()
results! And D is OK with that?
IM
On Saturday, 5 March 2016 at 14:18:31 UTC, Atila Neves wrote:
With a small number of threads, things work as intended in the
code below. But with 1000, on my machine it either crashes or
throws an exception:
import std.stdio;
import std.parallelism;
import std.range;
void main() {
stdou
On Monday, 7 March 2016 at 16:13:45 UTC, Steven Schveighoffer
wrote:
On 3/4/16 4:30 PM, Yuxuan Shui wrote:
On Friday, 4 March 2016 at 15:18:55 UTC, Steven Schveighoffer
wrote:
[...]
Thanks for answering. But I still don't understand why
TypeInfo would
need to be allocated. Aren't typeid() ju
On Tuesday, 8 March 2016 at 23:13:32 UTC, Anon wrote:
On Tuesday, 8 March 2016 at 20:26:04 UTC, Yuxuan Shui wrote:
[...]
[Note: I phrase my answer in terms of Linux shared libraries
(*.so) because D doesn't actually have proper Windows DLL
support yet. The same would apply to DLLs, it just f
On Wednesday, 9 March 2016 at 22:26:38 UTC, Ali Çehreli wrote:
On 03/09/2016 07:05 AM, Yuxuan Shui wrote:
> Can we left TypeInfo symbol undefined in the shared
libraries? i.e. D
> compiler will strip out TypeInfo definition when creating .so.
> (Alternatively, we can have TypeInfo always undefin
On Thursday, 10 March 2016 at 02:14:19 UTC, H. S. Teoh wrote:
On Thu, Mar 10, 2016 at 01:33:41AM +, Yuxuan Shui via
Digitalmars-d-learn wrote:
[...]
You can't rely on invoking the compiler to link these objects,
because if you're using shared libraries, it will be the OS&
Say:
module one;
void func(int a){}
/
module two;
import one;
void func(float a){}
Is there a way to get both func() in module two?
On Thursday, 24 March 2016 at 13:55:31 UTC, Adam D. Ruppe wrote:
On Thursday, 24 March 2016 at 12:11:33 UTC, Marc Schütz wrote:
On Wednesday, 23 March 2016 at 20:54:20 UTC, Yuxuan Shui wrote:
module one;
void func(int a){}
/
module two;
import one;
void func(float a){}
Add
On Thursday, 24 March 2016 at 15:52:49 UTC, Adam D. Ruppe wrote:
On Thursday, 24 March 2016 at 15:07:09 UTC, Yuxuan Shui wrote:
Is there a way to do this automatically?
No. You have to decide to bring them together if you want them
to overload.
Oh, sorry, this is not what I meant.
What I w
My code looks something like this:
bool[ulong][ulong] edge;
foreach(u; from)
foreach(v; to_)
edge[u][v] = true;
foreach(u; edge.keys) {
auto adj = edge[u];
//
}
And sometimes edge[u] would give Range violation error.
On Wednesday, 30 March 2016 at 00:26:49 UTC, Yuxuan Shui wrote:
My code looks something like this:
bool[ulong][ulong] edge;
foreach(u; from)
foreach(v; to_)
edge[u][v] = true;
foreach(u; edge.keys) {
auto adj = edge[u];
//
}
And sometimes edge[u] would give Range violati
Why?
This is annoying when I need to feed it into a function that
requires hasLength.
On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote:
On Sunday, April 03, 2016 23:46:10 John Colvin via
Digitalmars-d-learn wrote:
On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis
wrote:
> [...]
Maybe
aa.byKey().takeExactly(aa.length)
Yeah, that's a clever workaround.
I have encountered a weird bug.
I defined a Set class, which has a opBinary!"-". And somehow this:
auto tmp = set_a-set_b;
produces different results as this:
set_a = set_a-set_b;
the latter will produce an empty set.
I tried to reduce the source code to get a test case. But this
problem ju
On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote:
I have encountered a weird bug.
I defined a Set class, which has a opBinary!"-". And somehow
this:
auto tmp = set_a-set_b;
produces different results as this:
set_a = set_a-set_b;
the latter will produce an empty set.
I tried to
On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote:
I have encountered a weird bug.
I defined a Set class, which has a opBinary!"-". And somehow
this:
auto tmp = set_a-set_b;
produces different results as this:
set_a = set_a-set_b;
the latter will produce an empty set.
I tried to
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote:
On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote:
I have encountered a weird bug.
I defined a Set class, which has a opBinary!"-". And somehow
this:
auto tmp = set_a-set_b;
produces different results as this:
set_a = set
On Monday, 4 April 2016 at 21:31:08 UTC, Ali Çehreli wrote:
On 04/04/2016 09:36 AM, Anonymouse wrote:
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote:
[...]
assert(x.aa.length > 0); // <-- boom
[...]
No idea myself but that's where it seems to go wrong.
Looks like
I have a D shared library which is loaded by a C shared library,
which is in turn loaded by my main program.
When the D library tries to allocate something, the whole program
get an SIGSEGV in __GI___pthread_mutex_lock.
Stack trace:
(gdb) bt
#0 __GI___pthread_mutex_lock (mutex=0x7fffc1b
On Thursday, 7 April 2016 at 01:42:54 UTC, rikki cattermole wrote:
On 07/04/2016 1:38 PM, Yuxuan Shui wrote:
[...]
Have you started D's runtime?
How to start D's runtime? I followed the examples found here:
https://dlang.org/dll-linux.html#dso9, which doesn't say anything
about starting th
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote:
On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote:
[...]
The runtime is needed if you are going to use any of its
features, like the GC. If you restrict yourself strictly to C
in D (and that means avoiding thinks like b
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote:
On Thursday, 7 April 2016 at 01:50:31 UTC, Yuxuan Shui wrote:
[...]
The runtime is needed if you are going to use any of its
features, like the GC. If you restrict yourself strictly to C
in D (and that means avoiding thinks like b
On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole wrote:
On 07/04/2016 3:18 PM, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote:
[...]
static this/static ~this should work, right?
They execute when the runtime is started.
So now I add call rt_init
On Thursday, 7 April 2016 at 03:37:39 UTC, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole
wrote:
On 07/04/2016 3:18 PM, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote:
[...]
static this/static ~this should work, right?
They e
On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 03:37:39 UTC, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 03:19:58 UTC, rikki cattermole
wrote:
On 07/04/2016 3:18 PM, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 02:01:31 UTC, Mike Parker wrote:
On Thursday, 7 April 2016 at 04:36:02 UTC, Yuxuan Shui wrote:
On Thursday, 7 April 2016 at 04:24:48 UTC, Yuxuan Shui wrote:
[...]
Looks like _d_arrayappendcTX asked for a enormous amount of
memory and it fails, can't figure out why
Just find out it's my own fault.
BTW, memory block allocat
On Thursday, 21 April 2016 at 23:05:38 UTC, deed wrote:
Often I find myself wanting to alias an expression, such as
verbose fields, possibly nested. AFAIK, the with statement
makes it easier, but not as good as it could have been. What
I'd like to express is for example something like this:
[
I find this difficult because I can't passing data via
Fiber.yield/Fiber.call pair. e.g. I want something like:
void fiberFunc() {
//Add some file descriptor to main loop
string y = Fiber.yield();
writeln(y);
}
auto f = new Fiber(&fiberFunc);
f.call();
mainloop {
if (fd_readable)
On Thursday, 19 May 2016 at 23:42:03 UTC, Ali Çehreli wrote:
On 05/19/2016 12:57 PM, Yuxuan Shui wrote:
[...]
You can use a delegate that takes a ref parameter:
import std.stdio;
import core.thread;
void fiberFunc(ref string y) {
y = "produced_by_fiberFunc";
Fiber.yield();
}
void ma
On Friday, 20 May 2016 at 06:40:42 UTC, Jacob Carlborg wrote:
On 2016-05-20 04:14, Yuxuan Shui wrote:
Hmm... This could work. But I'm not satisfied with this
solution. What
if I have multiple yield sites in the fiber, and each have
different
return types?
Maybe I should use a Variant?
I th
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
Is it possible to have a class which has a variable which can
be seen from the outside, but which can only be modified from
the inside?
Something like:
class C {
int my_var = 3; // semi_const??
void do_something() { my_var = 4; }
}
Is there any reasons/difficulties for not implementing named
parameters?
There is clearly a need:
http://forum.dlang.org/thread/wokfqqbexazcguffw...@forum.dlang.org#post-pxndhoskpjxvnoacajaz:40forum.dlang.org
On Wednesday, 10 June 2015 at 19:59:17 UTC, Atila Neves wrote:
On Linux:
foo.d:
import std.stdio;
void main() { writeln(import("dir/bar.txt")); }
dmd -J. foo.d # ok
On Windows:
Error: file "dir/bar.txt" cannot be found or not in a path
specified with -J
I tried the obvious buildPath("dir",
I want to know exactly what is considered to be 'throw'.
I'm able to use dynamic arrays (which can throw 'Range
violation') and asserts in a nothrow function. Shouldn't those be
considered 'throw'?
On Thursday, 11 June 2015 at 00:27:36 UTC, Ali Çehreli wrote:
On 06/10/2015 05:06 PM, Yuxuan Shui wrote:
I want to know exactly what is considered to be 'throw'.
I'm able to use dynamic arrays (which can throw 'Range
violation') and
asserts in a nothrow function. Shouldn't those be considered
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!
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 usin
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
wrote:
A x = scoped!A(10);
use auto x = scoped!A(10);
Thanks!
Curious question, why doesn't compiler reject this code?
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
wrote:
A x = scoped!A(10);
use auto x
Jun 2015 09:01:04 +
Yuxuan Shui via Digitalmars-d-learn
wrote:
A x = scoped!A(10);
use auto x = scoped!A(10);
Thanks!
Curious question, why doesn't compiler reject this code?
Because scoped!A implicitly casts to A.
-Steve
Thanks!
I just found that out myself. Learned '
Is it possible to apply some operation on every member of a
TypeTuple, then get the result back?
Say I have a TypeTuple of array types, and I want a TypeTuple of
their element types, how could I do that?
I have a template class which is derived from a base class. Is it
possible to extract the template parameter from a reference to
the base class?
Can is() operate on TypeInfo?
On Monday, 15 June 2015 at 18:30:55 UTC, Steven Schveighoffer
wrote:
On 6/15/15 2:10 PM, Yuxuan Shui wrote:
I have a template class which is derived from a base class. Is
it
possible to extract the template parameter from a reference to
the base
class?
No. You can't get compile-time informat
On Monday, 15 June 2015 at 22:56:57 UTC, Yuxuan Shui wrote:
On Monday, 15 June 2015 at 18:30:55 UTC, Steven Schveighoffer
wrote:
[...]
Well I don't have a serious use case of this. I just started
using D couple of weeks ago, and is now experimenting with it
by writing a toy compiler.
What
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
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
Try to compile this code snippet:
import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
}
template b(alias R) {
int b(S)(S i) {
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
Try to compile this code snippet:
import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
}
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't
understand.
But R is not a parameter on the function itself. It comes from
the outside template.
Move it to the i
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't
understand.
But R is not a parameter on the function itself. It comes from
the outside template.
Move it to the i
On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer
wrote:
On 6/20/15 10:26 PM, Yuxuan Shui wrote:
On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
auto ref R) is indeed a template function, so I don't
underst
On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
Try to compile this code snippet:
import std.traits;
template a(R) {
auto a(S)(auto ref R i) {
return cast(S)i*2;
}
}
template ReturnTypeEx(alias A, B) {
alias ReturnTypeEx = ReturnType!(A!B);
}
On Wednesday, 1 July 2015 at 08:30:23 UTC, Yuxuan Shui wrote:
How do I express a mutable reference to a const object in D?
What I want to do is to define a variable, which refers a
constant object, but I can change which constant object it is
referring. Is this possible?
I wonder will someth
How do I express a mutable reference to a const object in D?
What I want to do is to define a variable, which refers a
constant object, but I can change which constant object it is
referring. Is this possible?
How can I do something like this?
const(A) x;
if (condition) {
x = func1();
} else {
x = func2();
}
This is a valid use case, and to make this work I'll have to use
Rebindable, which is really inconvenient.
On Monday, 13 July 2015 at 07:43:16 UTC, Marc Schütz wrote:
On Monday, 13 July 2015 at 07:11:33 UTC, Yuxuan Shui wrote:
How can I do something like this?
const(A) x;
if (condition) {
x = func1();
} else {
x = func2();
}
This is a valid use case, and to make this work I'll have to
use Rebi
On Monday, 13 July 2015 at 08:55:00 UTC, ketmar wrote:
On Mon, 13 Jul 2015 07:11:32 +, Yuxuan Shui wrote:
How can I do something like this?
const(A) x;
if (condition) {
x = func1();
} else {
x = func2();
}
This is a valid use case, and to make this work I'll have to
use Rebindable,
On Monday, 13 July 2015 at 09:05:25 UTC, ketmar wrote:
On Mon, 13 Jul 2015 08:56:05 +, Yuxuan Shui wrote:
On Monday, 13 July 2015 at 07:43:16 UTC, Marc Schütz wrote:
On Monday, 13 July 2015 at 07:11:33 UTC, Yuxuan Shui wrote:
[...]
const(A) = condition ? func1() : func2();
Well I sho
On Monday, 13 July 2015 at 17:18:53 UTC, Jesse Phillips wrote:
On Monday, 13 July 2015 at 14:41:36 UTC, Steven Schveighoffer
wrote:
You can also do a temporary lambda that you call immediately,
but I'm not 100% sure of the syntax. Someone will chime in
with the answer :)
-Steve
Syntax is ea
On Wednesday, 15 July 2015 at 21:57:50 UTC, badlink wrote:
Hello, I can't figure how to write a template function that
accept either strings or array of strings.
This is my current code:
bool hasItemParent(T)(const(char)[] itemId, const(T)[] parentId)
if (is(typeof(T) == char) || (isArray!T &&
Is there a way to have dub pack the library along with all its
dependencies into a single .a?
On Thursday, 30 July 2015 at 00:14:23 UTC, Yuxuan Shui wrote:
Is there a way to have dub pack the library along with all its
dependencies into a single .a?
And if not, is there any D build system capable of doing this?
reggae maybe?
Here is a small program
(https://gist.github.com/yshui/a426f73be77d1d699555) that uses
taskPool to parallely reading from /proc// and sum the swap
usage.
Individual tasks has zero dependency between each other, but when
I remove the 'defaultPoolThreads(1)' line, the programs takes 8x
more CP
On Wednesday, 12 August 2015 at 23:15:48 UTC, Adam D. Ruppe wrote:
On Wednesday, 12 August 2015 at 23:06:32 UTC, Yuxuan Shui wrote:
What is wrong here?
I didn't look too closely, but there's some memory allocations
going on there which have the potential of locking all the
threads any time o
Why is reduce defined as 'auto reduce(S, R)(S seed, R r)',
instead of reduce(R r, S seed)? I can't chain it.
Maybe provide both?
I was trying to use allocators in a @nogc function.
I tried FreeList!Mallocator and it works fine. But
AllocatorList!Mallocator doesn't work. dmd complains that
AllocatorList.allocate is not @nogc, even when
BookkeepingAllocator is NullAllocator. But if I add '@nogc' to
AllocatorList.allocate
Is there a way to use a range defined with disabled post-blit in
foreach? In other words, is there a way to prevent foreach from
copying the range?
Should I use move()?
On Tuesday, 30 August 2016 at 20:30:12 UTC, Ali Çehreli wrote:
On 08/30/2016 12:06 PM, Yuxuan Shui wrote:
Is there a way to use a range defined with disabled post-blit
in
foreach? In other words, is there a way to prevent foreach
from copying
the range?
It's not possible. You can't do much w
On Wednesday, 31 August 2016 at 15:52:18 UTC, Cauterite wrote:
On Wednesday, 31 August 2016 at 15:10:11 UTC, Seb wrote:
AssumeNogc is potentially dangerous, so I don't know whether
it can make it directly, but only if you try you know ;-)
So is assumeUnique
No. When you use assumeUnique, you
On Wednesday, 31 August 2016 at 18:07:46 UTC, Cauterite wrote:
On Wednesday, 31 August 2016 at 16:17:51 UTC, Yuxuan Shui wrote:
No. When you use assumeUnique, you know something the compiler
does know, and have to use assumeUnique to tell the compiler
that (at least when you use it correctly).
On Wednesday, 31 August 2016 at 19:39:36 UTC, ag0aep6g wrote:
On 08/31/2016 09:23 PM, Yuxuan Shui wrote:
Correct me if I'm wrong. But I believe this is only true when
the source
code of function is not available. Otherwise the compiler
should always
know if a function is actually @nogc or not.
On Wednesday, 31 August 2016 at 18:28:20 UTC, Ali Çehreli wrote:
On 08/31/2016 07:03 AM, Yuxuan Shui wrote:
> I want to make a hash table that uses
> std.experiment.allocator. The bucket is allocated from an
> allocator, and freed in ~this(). I don't want to copy the
whole
> bucket in this(this)
I just figured out how to store a reference:
@safe:
auto x(ref int a) {
struct A {
ref int xa() { return a; }
}
return A();
}
void main() {
import std.stdio;
int b = 10;
auto a = x(b);
a.xa = 20;
writeln(b); //Prints
On Thursday, 1 September 2016 at 20:28:03 UTC, Rene Zwanenburg
wrote:
On Thursday, 1 September 2016 at 19:37:25 UTC, Yuxuan Shui
wrote:
[...]
This will allocate a closure. A struct definition inside a
function has a hidden context / closure pointer, unless it's a
static struct.
There is no
On Thursday, 1 September 2016 at 21:07:36 UTC, Steven
Schveighoffer wrote:
On 9/1/16 4:38 PM, Yuxuan Shui wrote:
[...]
Referring to a null object is not a problem. Your program
crashes ungracefully, but does not corrupt memory. However, in
either approach, it can easily end up being a dangli
I have a little data processing program which makes heavy use of
associative arrays, and GC almost doubles the runtime of it (~2m
with GC disabled -> ~4m).
I just want to ask what's the best practice in this situation? Do
I just use GC.disable and manually run GC.collect periodically?
On Wednesday, 7 September 2016 at 22:54:14 UTC, Basile B. wrote:
On Wednesday, 7 September 2016 at 21:20:30 UTC, Yuxuan Shui
wrote:
I have a little data processing program which makes heavy use
of associative arrays, and GC almost doubles the runtime of it
(~2m with GC disabled -> ~4m).
I jus
Hi,
I wonder if there's standardized way to gather which files are
imported by a source file. I know I can run "dmd -v" and look for
lines start with "import", but I don't know if this is the best
way to do it.
On Thursday, 8 September 2016 at 06:33:00 UTC, Jacob Carlborg
wrote:
On 2016-09-08 07:39, Yuxuan Shui wrote:
Hi,
I wonder if there's standardized way to gather which files are
imported
by a source file. I know I can run "dmd -v" and look for lines
start
with "import", but I don't know if this
On Friday, 9 September 2016 at 10:03:01 UTC, wobbles wrote:
On Thursday, 8 September 2016 at 07:20:52 UTC, Yuxuan Shui
wrote:
On Thursday, 8 September 2016 at 06:33:00 UTC, Jacob Carlborg
wrote:
On 2016-09-08 07:39, Yuxuan Shui wrote:
Hi,
I wonder if there's standardized way to gather which f
I recently noticed nested struct capture its context by reference
(which, BTW, is not mentioned at all here:
https://dlang.org/spec/struct.html#nested). And bliting a struct
obviously doesn't do a deep copy of its context.
So my question is, is there a way to deep copy the context of a
struct
On Tuesday, 13 September 2016 at 01:32:19 UTC, Steven
Schveighoffer wrote:
On 9/12/16 4:11 PM, Ali Çehreli wrote:
On 09/10/2016 10:44 PM, Yuxuan Shui wrote:
I recently noticed nested struct capture its context by
reference
(which, BTW, is not mentioned at all here:
https://dlang.org/spec/struc
On Tuesday, 13 September 2016 at 20:00:40 UTC, Steven
Schveighoffer wrote:
On 9/13/16 3:42 PM, Yuxuan Shui wrote:
[...]
There's nothing in the language to prevent this optimization.
[...]
Again, could be clearer. But the fact that both the function
and the struct affect the same data kind
On Tuesday, 13 September 2016 at 20:36:22 UTC, Steven
Schveighoffer wrote:
On 9/13/16 4:11 PM, Yuxuan Shui wrote:
On Tuesday, 13 September 2016 at 20:00:40 UTC, Steven
Schveighoffer wrote:
Not familiar with C++ lambda. You can always "specify" how to
capture
the data by directly declaring it:
1 - 100 of 129 matches
Mail list logo