Re: How to pass noncopyable variadic arguments with ref?

2022-11-03 Thread tchaloupka via Digitalmars-d-learn
On Friday, 21 October 2022 at 12:05:28 UTC, ryuukk_ wrote: On Thursday, 20 October 2022 at 14:03:10 UTC, tchaloupka wrote: void test(Foo..)(Foo foos) I don't know if that's the 1:1 alternative, but that doesn't compile onlineapp.d(23): Error: struct `onlineapp.Foo` is not copyable b

How to pass noncopyable variadic arguments with ref?

2022-10-20 Thread tchaloupka via Digitalmars-d-learn
Hi, I've found strange behavior where: ```D import std.stdio; struct Foo { @disable this(this); int x; } void test(Foo[] foos...) { foreach (ref f; foos) { writeln(&f, ": ", f.x); f.x = 0; } } void main() { Foo f1 = Foo(1); Foo f2 = Foo(2); writeln("

Re: auto ref function parameter causes that non copyable struct is copied?

2021-11-09 Thread tchaloupka via Digitalmars-d-learn
On Monday, 8 November 2021 at 23:26:39 UTC, tchaloupka wrote: Bug or feature? :) I've reported it in https://issues.dlang.org/show_bug.cgi?id=22498.

Re: auto ref function parameter causes that non copyable struct is copied?

2021-11-08 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 9 November 2021 at 02:43:55 UTC, jfondren wrote: On Tuesday, 9 November 2021 at 02:41:18 UTC, jfondren wrote: The expectation is probably that `f.move` set `f` to `Foo.init`, but the docs say: Posted too fast. Foo qualifies with its @disable: ```d struct A { int x; } struct B { in

auto ref function parameter causes that non copyable struct is copied?

2021-11-08 Thread tchaloupka via Digitalmars-d-learn
Lets have this code: ```D import core.lifetime : forward; import core.stdc.stdio; import std.algorithm : move; struct Value(T) { private T storage; this()(auto ref T val) { storage = forward!val; } ref inout(T) get() inout { return storage; } } Value!T valu

Problem using struct with copy constructor with betterC

2021-11-06 Thread tchaloupka via Digitalmars-d-learn
After a long fiddling with a code that won't compile I've got this test case: ```D struct Foo { this(ref return scope Foo rhs) {} ~this() {} } struct Bar { @disable this(this); Foo[2] foos; } extern (C) void main() {} ``` When built with `-betterC` switch (dmd as ldc2 works wi

Re: GC memory fragmentation

2021-04-14 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 13 April 2021 at 12:30:13 UTC, tchaloupka wrote: I'm not so sure if pages of small objects (or large) that are not completely empty can be reused as a new bucket or only free pages can be reused. Does anyone has some insight of this? Some kind of GC memory dump and analyzer tool a

Re: GC memory fragmentation

2021-04-13 Thread tchaloupka via Digitalmars-d-learn
On Monday, 12 April 2021 at 07:03:02 UTC, Sebastiaan Koppe wrote: We have similar problems, we see memory usage alternate between plateauing and then slowly growing. Until it hits the configured maximum memory for that job and the orchestrator kills it (we run multiple instances and have good

Re: GC memory fragmentation

2021-04-11 Thread tchaloupka via Digitalmars-d-learn
On Sunday, 11 April 2021 at 12:20:39 UTC, Nathan S. wrote: One thing that comes to mind: is your application compiled as 32-bit? The garbage collector is much more likely to leak memory with a 32-bit address space since it much more likely for a random int to appear to be a pointer to the int

GC memory fragmentation

2021-04-11 Thread tchaloupka via Digitalmars-d-learn
Hi, we're using vibe-d (on Linux) for a long running REST API server and have problem with constantly growing memory until system kills it with OOM killer. First guess was some memory leak so we've added periodic call to: ```D GC.collect(); GC.minimize(); malloc_trim(0); ``` And when called

Re: Struct field destructor not called when exception is thrown in the main struct destructor

2020-10-17 Thread tchaloupka via Digitalmars-d-learn
On Friday, 16 October 2020 at 16:00:07 UTC, Steven Schveighoffer wrote: On 10/16/20 9:12 AM, tchaloupka wrote: So when the exception is thrown within Foo destructor (and it's bad on it's own but can easily happen as destructors aren't nothrow @nogc by default). Is this behavior expected? I

Struct field destructor not called when exception is thrown in the main struct destructor

2020-10-16 Thread tchaloupka via Digitalmars-d-learn
Found a pretty nasty bug in vibe-d: https://github.com/vibe-d/vibe.d/issues/2484 And it's caused by this behavior. ```D import std; struct Foo { Bar bar; bool err; ~this() { // scope(failure) destroy(bar); // < this fixes the Bar destructor call enforce(!err, "Te

Re: std.datetime & timzone specifier: 2018-11-06T16:52:03+01:00

2020-03-08 Thread tchaloupka via Digitalmars-d-learn
On Sunday, 8 March 2020 at 17:28:33 UTC, Robert M. Münch wrote: On 2020-03-07 12:10:27 +, Jonathan M Davis said: DateTime dt = DateTime.fromISOExtString(split("2018-11-06T16:52:03+01:00", regex("\\+"))[0]); IMO such a string should be feedable directly to the function. You just need to

Re: SQLite 3 support?

2020-02-26 Thread tchaloupka via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 20:06:20 UTC, mark wrote: There seems to be some support for SQLite 3 in std. lib. etc when looking at the stable docs: https://dlang.org/phobos/etc_c_sqlite3.html But this isn't visible when looking at stable (ddox). Is this the best SQLite 3 library to use o

Re: D create many thread

2020-02-06 Thread tchaloupka via Digitalmars-d-learn
On Wednesday, 5 February 2020 at 13:05:59 UTC, Eko Wahyudin wrote: Hi all, I'm create a small (hallo world) application, with DMD. But my program create 7 annoying threads when create an empty class. If you don't want the parallel sweep enabled for your app, you can turn it of ie with: `

Re: Calling D library from other languages on linux using foreign threads

2019-03-25 Thread tchaloupka via Digitalmars-d-learn
On Saturday, 23 March 2019 at 17:33:31 UTC, tchaloupka wrote: I've no idea what should be done with C's main thread as it can't be attached because it'll hang. In one of forum threads I've also read the idea to not using foreign threads with GC but somehow delegate their work to D's thread. Can

Re: Calling D library from other languages on linux using foreign threads

2019-03-23 Thread tchaloupka via Digitalmars-d-learn
On Saturday, 23 March 2019 at 15:28:34 UTC, Ali Çehreli wrote: On 03/22/2019 12:34 PM, tchaloupka wrote: > I've searched a lot at it should be working at least on linux, but > apparently is not or I'm doing something totally wrong.. > > Our use case is to call shared D library from C# (.Net Core)

Re: Shared library loading and static constructor

2019-03-23 Thread tchaloupka via Digitalmars-d-learn
On Saturday, 23 March 2019 at 15:58:07 UTC, Sobaya wrote: What I am saying is that it can not be read when a code importing (a.d) a code including the static constructor (b.d) is compiled into shared library. Hi. I've tried to add your case to the repository and at it seems to be working for

Re: Calling D library from other languages on linux using foreign threads

2019-03-23 Thread tchaloupka via Digitalmars-d-learn
On Saturday, 23 March 2019 at 09:47:55 UTC, Andre Pany wrote: On Friday, 22 March 2019 at 19:34:14 UTC, tchaloupka wrote: Just to make sure, could you test it with dmd 2.78? Actually when I remove the explicit GC call within unregistered thread (which is fixed in https://github.com/dlang/drun

Calling D library from other languages on linux using foreign threads

2019-03-22 Thread tchaloupka via Digitalmars-d-learn
I've searched a lot at it should be working at least on linux, but apparently is not or I'm doing something totally wrong.. Our use case is to call shared D library from C# (.Net Core) and from different threads. What I've read about this, is that foreign thread should be registered by `thre

Strange appender behavior

2019-03-13 Thread tchaloupka via Digitalmars-d-learn
Is this expected?: ``` import std.stdio; import std.algorithm; import std.array; void main() { auto d = Appender!string(); //auto d = appender!string(); // works string[] arr = ["foo", "bar", "baz"]; arr.joiner("\n").copy(d); writeln(d.data); } ``` Using Appender outpust no

Re: SysTime bug or feature?

2015-10-05 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:54:44 UTC, Jonathan M Davis wrote: It is by design, albeit undesirable. When SysTime was originally written, it was impossible to have a default value for a class reference other than null. So, unless SysTime was going to take the performance hit of constantly c

SysTime bug or feature?

2015-10-05 Thread tchaloupka via Digitalmars-d-learn
This code: import std.stdio; import std.datetime; void main() { SysTime t = SysTime.init; writeln(t); } results in segfault with dmd-2.068.2 Is it ok? Backtrace: #0 0x004733f3 in std.datetime.SysTime.adjTime() const () #1 0x004730b9 in std.datetime.SysTime.toSimpleS

Contracts with interface

2015-09-19 Thread tchaloupka via Digitalmars-d-learn
This bites me again: import std.stdio; interface ITest { void test(); void test2() in { writeln("itest2"); } void test3() in { writeln("itest3"); } void test4() in { writeln("itest4"); assert(false); } } class Test: ITest { void test() in { writeln("ctest"

Re: Should this compile?

2015-08-26 Thread tchaloupka via Digitalmars-d-learn
On Tuesday, 25 August 2015 at 18:29:08 UTC, Vladimir Panteleev wrote: I think this is a bug, but is easily worked around with: auto test(string a) { return .test(a, "b"); } Thanks, this worked. Filled it: https://issues.dlang.org/show_bug.cgi?id=14965

Should this compile?

2015-08-25 Thread tchaloupka via Digitalmars-d-learn
import std.stdio; import std.range : chain; auto test(string a) { return test(a, "b"); } auto test(string a, string b) { return chain(a, b); } void main() { writeln(test(a)); } Ends with: Error: forward reference to inferred return type of function call 'test' I know this exact

Re: Speed of horizontal flip

2015-04-01 Thread tchaloupka via Digitalmars-d-learn
On Wednesday, 1 April 2015 at 16:08:14 UTC, John Colvin wrote: On Wednesday, 1 April 2015 at 13:52:06 UTC, tchaloupka wrote: I'm pretty sure that the flipping happens in GDI+ as well. You might be writing C#, but the code your calling that's doing all the work is C and/or C++, quite possibly

Re: Speed of horizontal flip

2015-04-01 Thread tchaloupka via Digitalmars-d-learn
On Wednesday, 1 April 2015 at 14:00:52 UTC, bearophile wrote: tchaloupka: Am I doing something utterly wrong? If you have to perform performance benchmarks then use ldc or gdc. I tried it on my slower linux box (i5-2500K vs i7-2600K) without change with these results: C# (mono with it

Speed of horizontal flip

2015-04-01 Thread tchaloupka via Digitalmars-d-learn
Hi, I have a bunch of square r16 and png images which I need to flip horizontally. My flip method looks like this: void hFlip(T)(T[] data, int w) { import std.datetime : StopWatch; StopWatch sw; sw.start(); foreach(int i; 0..w) { auto row = data[i*w..(i+1)*w]