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: Return values from auto function

2020-11-06 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 6 November 2020 at 15:06:18 UTC, Andrey Zherikov wrote: On Friday, 6 November 2020 at 14:58:40 UTC, Jesse Phillips wrote: On Friday, 6 November 2020 at 14:20:40 UTC, Andrey Zherikov wrote: This issue seems hit the inability to implicitly convert custom types. May be it makes more sen

Re: Return values from auto function

2020-11-06 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 6 November 2020 at 20:05:36 UTC, Ferhat Kurtulmuş wrote: On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: I have auto function 'f' that might return either an error (with some text) or a result (with some value). The problem is that the type of the error is not the

Re: Return values from auto function

2020-11-06 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: I have auto function 'f' that might return either an error (with some text) or a result (with some value). The problem is that the type of the error is not the same as the type of result so compilation fails. [...] Sounds li

Re: Switch between two structs with csvreader

2020-11-06 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 06, 2020 at 07:17:53PM +, Selim Ozel via Digitalmars-d-learn wrote: > On Thursday, 5 November 2020 at 22:36:36 UTC, Anonymouse wrote: > > If I'm not mistaken the `csvReader` function returns a range struct, > > and the full type is something long and unwieldy like > > `CsvReader!(s

How to load a dll which is written by dlang with a c interface from a c program static/dynamic link on windows?

2020-11-06 Thread ll via Digitalmars-d-learn
e.g. mydll.d: import core.sys.windows.windows; import core.sys.windows.dll; extern (C) export int foo(ref int a[10],ref int b[10],ref int c[10]) { for(int i=0;i<10;i++) { c[10]=a[10]-b[10]; } return 0; } mixin SimpleDllMain; test.c: How to write i

Re: Switch between two structs with csvreader

2020-11-06 Thread Selim Ozel via Digitalmars-d-learn
On Thursday, 5 November 2020 at 22:36:36 UTC, Anonymouse wrote: If I'm not mistaken the `csvReader` function returns a range struct, and the full type is something long and unwieldy like `CsvReader!(struct_type1, cast(Malformed)1, string, dchar, string[])`. So just think of `records` as being t

Re: Return values from auto function

2020-11-06 Thread Mike Parker via Digitalmars-d-learn
On Friday, 6 November 2020 at 15:06:18 UTC, Andrey Zherikov wrote: To clarify my statement: Yes, Result!void and Result!int are different types but I couldn't find a way to implicitly convert one to another. You can't. Structs do not implicitly convert to each other, templated or otherwise.

Re: Implicit conversion to templatized type

2020-11-06 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 06, 2020 at 03:36:46PM +, Paul Backus via Digitalmars-d-learn wrote: [...] > User-defined implicit conversions are one of the most error-prone > features of C++, and have been deliberately excluded from D, with the > exception of `alias this`. And Walter is already expressing regr

Re: Implicit conversion to templatized type

2020-11-06 Thread Paul Backus via Digitalmars-d-learn
On Friday, 6 November 2020 at 15:01:21 UTC, Andrey Zherikov wrote: But how can I achieve the same result if S1 is a template "struct S1(T) {}" and S2 should be convertible to S1!T with any T? Also why neither "opCast" struct S2 { S1 opCast(T)() const if(is(T == S1)) { return S1(); } }

Re: Vibe.d build on LDC error

2020-11-06 Thread Vino via Digitalmars-d-learn
On Friday, 6 November 2020 at 10:30:03 UTC, Mathias LANG wrote: On Friday, 6 November 2020 at 05:52:56 UTC, Vino wrote: [...] Which Linux distribution ? Which version of Vibe.d ? A recent enough Vibe.d should detect OpenSSL based on 1) pkg-config 2) the openssl binary. Make sure you have the

Re: Return values from auto function

2020-11-06 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 6 November 2020 at 14:58:40 UTC, Jesse Phillips wrote: On Friday, 6 November 2020 at 14:20:40 UTC, Andrey Zherikov wrote: This issue seems hit the inability to implicitly convert custom types. May be it makes more sense to ask in a separate thread. The return type must be the same

Implicit conversion to templatized type

2020-11-06 Thread Andrey Zherikov via Digitalmars-d-learn
There is a way to implicitly convert non-template user type, for example: struct S2 { @property S1 s1() { return S1(); } alias s1 this; } struct S1 {} S1 f() { return S2(); } // implicit conversion from S2 to S1 But how can I achieve the same

Re: Return values from auto function

2020-11-06 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 6 November 2020 at 14:20:40 UTC, Andrey Zherikov wrote: On Friday, 6 November 2020 at 12:03:01 UTC, Paul Backus wrote: You can't. Both return values have to have the same type, which means the failure function has to be able to return more than one type, which means it has to be a te

Re: Return values from auto function

2020-11-06 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 6 November 2020 at 12:03:01 UTC, Paul Backus wrote: You can't. Both return values have to have the same type, which means the failure function has to be able to return more than one type, which means it has to be a template. This issue seems hit the inability to implicitly convert c

Re: Return values from auto function

2020-11-06 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 6 November 2020 at 13:59:58 UTC, gbram wrote: On Friday, 6 November 2020 at 12:03:01 UTC, Paul Backus wrote: On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: How can I make the original code compilable without templatizing `failure` function? You can't. Both ret

Re: Return values from auto function

2020-11-06 Thread gbram via Digitalmars-d-learn
On Friday, 6 November 2020 at 12:03:01 UTC, Paul Backus wrote: On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: How can I make the original code compilable without templatizing `failure` function? You can't. Both return values have to have the same type, which means the fa

Re: Return values from auto function

2020-11-06 Thread Paul Backus via Digitalmars-d-learn
On Friday, 6 November 2020 at 10:51:20 UTC, Andrey Zherikov wrote: I can make it work if I add a type to `failure` function but this remove brevity in usage: - auto failure(T)(string error) { return Result!T(Result!T.Failure(error)); } auto f(int i) { return i > 0 ? succe

Return values from auto function

2020-11-06 Thread Andrey Zherikov via Digitalmars-d-learn
I have auto function 'f' that might return either an error (with some text) or a result (with some value). The problem is that the type of the error is not the same as the type of result so compilation fails. Here is my code: -- struct Result(T) { struct Success { stati

Re: Vibe.d build on LDC error

2020-11-06 Thread Mathias LANG via Digitalmars-d-learn
On Friday, 6 November 2020 at 05:52:56 UTC, Vino wrote: Hi All, When we try to build vide.d using ldc (dub build) we are getting the below error, openssl is already been installed (OpenSSL 1.0.2j-fips 26 Sep 2016), hence request your help on the same. openssl.d:84: error: undefined refer

Re: why `top` report is not consistent with the memory freed by core.stdc.stdlib : free?

2020-11-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 6 November 2020 at 06:17:42 UTC, mw wrote: https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation using core.stdc.stdlib : malloc and free to manually manage memory, I tested two scenarios: -- malloc & free -- malloc only and I use Linux command `top` to chec

Re: why `top` report is not consistent with the memory freed by core.stdc.stdlib : free?

2020-11-06 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 6 November 2020 at 06:17:42 UTC, mw wrote: Hi, I'm trying this: https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation using core.stdc.stdlib : malloc and free to manually manage memory, I tested two scenarios: -- malloc & free -- malloc only and I use Linux

A GtkD question: Is there an explicit public function to get D Classes from StructCtype*?

2020-11-06 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
For instance, I have extern (C) int sortList1(GtkListBoxRow* _row1, GtkListBoxRow* _row2, void* userData) I pass it as listbox.setSortFunc(&sortList1, cast(void*)this, &_destroy2); In the sortList1 function I want to access derived members of my ListBoxRowWithData such as: auto row1 = c