Are JSONOptions broken?

2020-11-28 Thread frame via Digitalmars-d-learn
I need to encode a key as string through json. This throws an UTF-exception: auto json = JSONValue(cast(char[])[0x00, 0x7D, 0xFE, 0xFF, 0x14, 0x32, 0x43, 0x10]); writeln(json.toString(JSONOptions.escapeNonAsciiChars)); Makes no sense. Either the bytes should be properly escaped or there shou

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 19:51:24 UTC, Vino wrote: the moment we enable parallelism, it is throwing an error on the SQL part (Fetch the username/ password from the table for each account), as it could not execute the SQL query in parallel for different account. I see no reason for a S

Re: Calling function within class.

2020-11-19 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 19:25:06 UTC, Vino wrote: The above code is a sample code, but the logic is same, correct me if my understanding is wrong, in the above code "obj" is a an object for the class GetDirlist, so we are accessing the class member using "obj.listFile(st)" , so why

Re: Can't pass [] to extern function object method

2020-11-19 Thread frame via Digitalmars-d-learn
On Thursday, 19 November 2020 at 07:46:20 UTC, Bastiaan Veelo wrote: On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote: I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context. W

Re: Calling function within class.

2020-11-18 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 17:55:36 UTC, Vino wrote: I made the changes as below , still not working auto fltask = task!listFile(st); to auto fltask = task!({listFile(st);})(this).executeInNewThread(); The syntax is just wrong: auto fltask = task!({listFile(st);})(this).executeInNe

Re: Calling function within class.

2020-11-18 Thread frame via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 15:01:53 UTC, Vino wrote: Hi All, Request your help on how to call a function(listFile) from another function(getFilelist) within the same class(GetDirlist), below is an example code. I think it's basically the same issue like that recently opened topic:

Re: Can't pass [] to extern function object method

2020-11-18 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 22:22:42 UTC, frame wrote: On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote: What is the function prototype like and how are you declaring that struct? The struct is very simple, it contains: I found the "bug". It was caused by a debug {} statement with

Re: Can't pass [] to extern function object method

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 21:58:44 UTC, Jack wrote: What is the function prototype like and how are you declaring that struct? The struct is very simple, it contains: struct S { SysTime a; ulong b; double c; ubyte[] d; string e; } And I tried: bool foo(S[] params);

Can't pass [] to extern function object method

2020-11-16 Thread frame via Digitalmars-d-learn
I have a DLL in D-code which returns an object and want to pass a struct S[] to a member function of that object. The first element is passed correctly, the rest is just garbage. In fact the next item is just a single byte with value 0x11 following some 0x00. It doesn't matter if I'm using S[]

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 13:38:11 UTC, frame wrote: On Monday, 16 November 2020 at 13:12:02 UTC, data pulverizer wrote: Not seeing an error in Developer Tools. I don't expect to because the loading sign remains there as if it is continuously trying to load and doesn't display any errors

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 13:12:02 UTC, data pulverizer wrote: Not seeing an error in Developer Tools. I don't expect to because the loading sign remains there as if it is continuously trying to load and doesn't display any errors. You have to inspect the Console-Tab inside the DevTools

Re: Issue with opening files on VSCode "D Language utility extension pack"

2020-11-16 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 01:38:10 UTC, data pulverizer wrote: Hi All, On VS Code "D Language utility extension pack", I notice that if I open a random D file, on the bottom left of the IDE, a message says "D: workspace/(0.0%): starting up...". It stays at 0.0% and doesn't go away and gi

Re: How can I wrap SSL on Dlang Socket?

2020-11-15 Thread frame via Digitalmars-d-learn
On Monday, 16 November 2020 at 01:25:01 UTC, Marcone wrote: How can I wrap SSL on Dlang Socket like I wrap in Python? There is no functionality in the standard library. If you are just looking for a HTTP client, use std.net.curl. If you want your own thing or need a server application you nee

Re: How can execute method in new Thread?

2020-11-15 Thread frame via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:21:15 UTC, Marcone wrote: Error: D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): Error: struct `Fruit` does not overload () You can't. Because everything that can run in a new thread must be a (separate) function. If you are using an object (y

extern(C) Variant: attempting to use incompatible types int and int

2020-11-15 Thread frame via Digitalmars-d-learn
I know the problem that TypeInfo != TypeInfo in main and library context. Is there are a hack to get the data from the Variant even if the TypeInfo-check fails? I assume the only workaround is using an own struct or serializer to achieve the same functionality?

Windows DLL Exception catching status?

2020-11-12 Thread frame via Digitalmars-d-learn
Is there still no way to catch an exception thrown from own DLL in main runtime?

Re: Is there a similar library to FreeMarker like in Java

2020-11-11 Thread frame via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 08:13:23 UTC, Namal wrote: Hello, I want to do a small project but I need a text replacement tool/lib like Apache's FreeMarker. Is there something similar for D? Thx Maybe not so powerful but useful: mustache-d

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 19:29:39 UTC, frame wrote: On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static struc

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static struct S { string characteristicValue; } foreach (ref j; pa

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 05:07:54 UTC, frame wrote: Something wrong with this library. Well, we need an edit function here. The library has no TCP_NODELAY flag enabled. This fix speeds it up to 10x and solves the 44ms problem to 400us https://github.com/mysql-d/mysql-native/pull/221/file

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 12:29:46 UTC, Andre Pany wrote: Maybe mysql native is slower, but maybe this isn't the case, just the way performance measurements was done was incorrectly. I have tried mysql-native and it tooks way to long for simple things. My test setup is a remote linux vm

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 16:37:22 UTC, Vino wrote: , Trying to improve the above code hence request your help on how to use array container instead of array, tried as per the example below but not working. I think you can just use a static array as ubyte[1024] if you want a fixed bu

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-07 Thread frame via Digitalmars-d-learn
On Saturday, 7 November 2020 at 14:57:39 UTC, Vino wrote: After further analysis we suspect that the issue is at the package std.net.curl the flow of the program is as below Establishing a new connection may vary in duration of +200ms or more.

Re: Comparison : mysql-native + asdf and hunt-database + asdf

2020-11-06 Thread frame via Digitalmars-d-learn
On Friday, 6 November 2020 at 04:58:05 UTC, Vino wrote: Component : mysql-native + asdf Executable size : 17 MB Execution time : 10 secs, 189 ms, 919 μs, and 3 hnsecs Component : hunt-database + asdf Executable size : 81 MB Execution time : 5 secs, 916 ms, 418 μs, and 3 hnsecs Interesting bu

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 11:30:53 UTC, frame wrote: On Tuesday, 27 October 2020 at 10:41:06 UTC, Jacob Carlborg wrote: if (_arguments[i] == typeid(ubyte[])) { auto foo = va_arg!(ubyte[])(_argptr); } The same is working with variadic template. I am missing something? Never mind, I wa

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 10:41:06 UTC, Jacob Carlborg wrote: On Tuesday, 27 October 2020 at 09:40:33 UTC, frame wrote: Hmm, a question of design. Is there also a convenient way to pass the arguments to a template or get a Variant[] from it? Convenient, no not that I know of. You can use

Re: this T / variadic template and interfaces

2020-10-27 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 13:02:33 UTC, Jacob Carlborg wrote: On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote: Is there any way to get this working? I know, I could use a known object to feed the arguments and use that instead - but I want to keep things simple as possible. As Si

Re: Template pattern delegate?

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 09:25:03 UTC, Jacob Carlborg wrote: On Monday, 26 October 2020 at 00:56:26 UTC, frame wrote: If you pass the delegate as a template parameter/alias parameter, it's more likely to be inlined: auto myStuff(alias fn)() { try return fn(); catch (Exception e)

Re: this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:48:48 UTC, Simen Kjærås wrote: This makes sense if you consider that the user of the interface has no knowledge of the types that implement it, and vice versa: the implementing class has no idea which instantiations to make, and the user has no idea which imp

this T / variadic template and interfaces

2020-10-26 Thread frame via Digitalmars-d-learn
Did not find this topic: I have an interface and some wrapper classes that use it. The wrapper's methods should accept variadic arguments. The runtime should only work with the interface, trying casting to a wrapper is not an option, because it's a plugin design. - defining a variadic templa

Re: Template pattern delegate?

2020-10-25 Thread frame via Digitalmars-d-learn
On Sunday, 25 October 2020 at 12:02:10 UTC, Ali Çehreli wrote: On 10/25/20 4:30 AM, frame wrote: Is there a possibility to write templated code / custom trait pattern with usage like a delegate? I have a try-catch block with different types and don't want to repeat myself in every method agai

Template pattern delegate?

2020-10-25 Thread frame via Digitalmars-d-learn
Is there a possibility to write templated code / custom trait pattern with usage like a delegate? I have a try-catch block with different types and don't want to repeat myself in every method again. It's always the same, just what's tried changes, eg.: pseudo code: template myStuff(mixin co

Re: Edit

2020-10-24 Thread frame via Digitalmars-d-learn
On Monday, 5 October 2020 at 11:28:56 UTC, ryuukk_ wrote: On Monday, 5 October 2020 at 11:14:47 UTC, frame wrote: So I found out that there is nothing wrong with the method as in a test environment the allocated memory block is removed after GC.minimize(). Still need to find out why other blo

Edit

2020-10-05 Thread frame via Digitalmars-d-learn
So I found out that there is nothing wrong with the method as in a test environment the allocated memory block is removed after GC.minimize(). Still need to find out why other blocks are not released. However, is there a way to debug currently allocated variables by the GC?

GC and sensible data read by File

2020-10-04 Thread frame via Digitalmars-d-learn
Hello, I'm new to D and try to find out a memory leak in my program. I inspected the private bytes with VmMap on Windows to see which data is still kept. Besides the actual memory leak I was surprised to find out there are contents of my previoulsy read configuration INI file. So my questi

Re: How to find the content of core.sys.* ?

2017-10-28 Thread Ryan Frame via Digitalmars-d-learn
On Tuesday, 17 May 2016 at 06:56:36 UTC, rikki cattermole wrote: On 17/05/2016 6:55 PM, chmike wrote: Hello, The nice and handy documentation of dlang doesn't provide any info on the core.sys. How can I find out all the things that are in there ? https://github.com/dlang/druntime/tree/maste

Re: std.path.buildPath

2017-06-11 Thread Ryan Frame via Digitalmars-d-learn
On Sunday, 4 June 2017 at 18:15:36 UTC, Russel Winder wrote: On Sun, 2017-06-04 at 17:56 +0200, Jacob Carlborg via Digitalmars-d- learn wrote: On 2017-06-04 07:44, Jesse Phillips wrote: > What is your expected behavior? Throw an exception? You can't > really > append an absolute path to another

Re: Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
On Sunday, 10 April 2016 at 19:02:06 UTC, Alex Parrill wrote: A parameter declared as `lazy T` has the type `T delegate()`, which, when called, evaluates the expression that was passed into the function. So effectively, this: void foo(lazy int x) { auto i = x(); } foo(a+b); Is the same as

Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
Greetings. The following code works: void main() { passfunc(&func); } void passfunc(void function(string) f) { f("Hello"); } void func(string str) { import std.stdio : writeln; writeln(str); } Now if I change passfunc's signature to "void passfunc(lazy void function(string) f

<    1   2   3   4