Re: exporting function from betterc to windows dll

2020-03-14 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 14 March 2020 at 20:53:45 UTC, Abby wrote: I would like to export some functions from my bettec dll for dotnet core application in windows. Right now I have compiled dll using dmd v2.091.0-dirty simply by ´dub build´ this is the function I have extern(C) char*

How catch any error in Dlang like Python try-except?

2020-03-14 Thread Marcone via Digitalmars-d-learn
How catch any error in Dlang like Python tray-except? It is very useful when making tests. But only who came from interpreted languages can understand. Exemple: import std; void main() { try { writelnX("try function that not exist"); } catch (Throwable

Re: How catch any error in Dlang like Python try-except?

2020-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 15 March 2020 at 02:11:21 UTC, Marcone wrote: It is very useful when making tests. But only who came from interpreted languages can understand. The compiler catches all compile errors. It is impossible to even run a program if there is even a single compile error. Thus they cannot

Re: exporting function from betterc to windows dll

2020-03-14 Thread User via Digitalmars-d-learn
On Saturday, 14 March 2020 at 20:53:45 UTC, Abby wrote: I would like to export some functions from my bettec dll for dotnet core application in windows. [...] It is the calling convention.

Re: How does one read file line by line / upto a specific delimeter of an MmFile?

2020-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Mar 14, 2020 at 10:37:37PM +, Adnan via Digitalmars-d-learn wrote: > https://dlang.org/library/std/mmfile/mm_file.html doesn't seem to > specify anything similar to lines() or byLine() or byLineCopy() etc. That's because a memory-mapped file appears directly in your program's memory

Re: Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adnan via Digitalmars-d-learn
On Sunday, 15 March 2020 at 00:04:09 UTC, Adnan wrote: On Saturday, 14 March 2020 at 23:54:44 UTC, Adam D. Ruppe wrote: On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote: Full code this worked for me when i copy/pasted it... are you sure that has the error? if so what compiler version

Re: Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adnan via Digitalmars-d-learn
On Saturday, 14 March 2020 at 23:54:44 UTC, Adam D. Ruppe wrote: On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote: Full code this worked for me when i copy/pasted it... are you sure that has the error? if so what compiler version you on? This is indeed very strange, godbolt says

Re: Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote: Full code this worked for me when i copy/pasted it... are you sure that has the error? if so what compiler version you on?

Re: Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adnan via Digitalmars-d-learn
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote: In the following code the compiler says the type is Array!()(string): if (key in wordTable) wordTable[key] ~= word; else

Re: Pattern matching via switch?

2020-03-14 Thread 12345swordy via Digitalmars-d-learn
On Saturday, 14 March 2020 at 20:52:30 UTC, aliak wrote: On Saturday, 14 March 2020 at 19:04:28 UTC, 12345swordy wrote: [...] You can use the sumtype package (https://code.dlang.org/packages/sumtype): [...] That simply to much verbiage.

Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adnan via Digitalmars-d-learn
In the following code the compiler says the type is Array!()(string): if (key in wordTable) wordTable[key] ~= word; else wordTable[key] = Array!string(word); source/app.d(29,36):

How does one read file line by line / upto a specific delimeter of an MmFile?

2020-03-14 Thread Adnan via Digitalmars-d-learn
https://dlang.org/library/std/mmfile/mm_file.html doesn't seem to specify anything similar to lines() or byLine() or byLineCopy() etc.

Re: Pattern matching via switch?

2020-03-14 Thread aliak via Digitalmars-d-learn
On Saturday, 14 March 2020 at 19:04:28 UTC, 12345swordy wrote: I.E. switch (object) case Type1 t1: case Type2 t2: case Type3 t3: You can use the sumtype package (https://code.dlang.org/packages/sumtype): alias T = SumType!(Type1, Type2, Type3); T(object).match!( (Type1 t1)

Re: Pattern matching via switch?

2020-03-14 Thread Luhrel via Digitalmars-d-learn
On Saturday, 14 March 2020 at 19:04:28 UTC, 12345swordy wrote: I.E. switch (object) case Type1 t1: case Type2 t2: case Type3 t3: As far as I know, there's no way to do that in a switch. However, you can do something like this: --- void main() { auto i = new Type1();

exporting function from betterc to windows dll

2020-03-14 Thread Abby via Digitalmars-d-learn
I would like to export some functions from my bettec dll for dotnet core application in windows. Right now I have compiled dll using dmd v2.091.0-dirty simply by ´dub build´ this is the function I have extern(C) char* test_echo(const(char)* line, size_t len, ref size_t resLen) { enum

Pattern matching via switch?

2020-03-14 Thread 12345swordy via Digitalmars-d-learn
I.E. switch (object) case Type1 t1: case Type2 t2: case Type3 t3:

Re: Is it possible to dynamically load a @safe function from a shared library ?

2020-03-14 Thread wjoe via Digitalmars-d-learn
On Friday, 13 March 2020 at 20:31:16 UTC, Steven Schveighoffer wrote: On 3/13/20 4:22 PM, wjoe wrote: I would expect that something could be written to turn a signature string into a mangling and also provide the correct type upon return. Something like: auto f = getFunction!(@safe void

need help to get member function const address

2020-03-14 Thread Calvin P via Digitalmars-d-learn
I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static function address: = struct A { void d(){};