Endianness - How to test code for portability

2021-03-11 Thread Preetpal via Digitalmars-d-learn
In the portability section of the language spec, they talk about endianness (https://dlang.org/spec/portability.html#endianness) which refers "to the order in which multibyte types are stored." IMO if you wanted to actually be sure your code is portable across both big endian and little

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: module xlutils; import core.stdc.string : strlen, strcpy; //import std.conv : to;

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
On Thursday, 11 March 2021 at 18:35:37 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote: On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn

Re: Static initialization of associative arrays

2021-03-11 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 11 March 2021 at 18:41:08 UTC, Ali Çehreli wrote: On 3/11/21 10:06 AM, Chris Piker wrote: >https://dlang.org/spec/hash-map.html#static_initialization > > that this feature is not yet implemented. I use a shared static this() block: immutable string[int] aa; shared static

Re: Static initialization of associative arrays

2021-03-11 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 11 March 2021 at 19:12:34 UTC, H. S. Teoh wrote: On Thu, Mar 11, 2021 at 06:06:35PM +, Chris Piker via immutable int[string] aa; shared static this() { aa = [ "abc": 123, "def": 456, /* ... */ ]; } Hi H.S.T Yes, I'm using static if, but do

Re: Static initialization of associative arrays

2021-03-11 Thread Chris Piker via Digitalmars-d-learn
On Thursday, 11 March 2021 at 18:41:08 UTC, Ali Çehreli wrote: On 3/11/21 10:06 AM, Chris Piker wrote: >https://dlang.org/spec/hash-map.html#static_initialization > > that this feature is not yet implemented. I use a shared static this() block: immutable string[int] aa; shared static

Re: Static initialization of associative arrays

2021-03-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 11, 2021 at 06:06:35PM +, Chris Piker via Digitalmars-d-learn wrote: [...] > Today I ran across a situation where an immutable associative array > would be handy. While perusing the language spec I noticed here: > > https://dlang.org/spec/hash-map.html#static_initialization >

Re: Static initialization of associative arrays

2021-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 3/11/21 10:06 AM, Chris Piker wrote: >https://dlang.org/spec/hash-map.html#static_initialization > > that this feature is not yet implemented. I use a shared static this() block: immutable string[int] aa; shared static this() { aa = [ 1: "one" ]; } void main() { assert(aa.length

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote: On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David

Static initialization of associative arrays

2021-03-11 Thread Chris Piker via Digitalmars-d-learn
Hi D At work I've begun writing programs in D that I would typically write in python. My goal is to get away from split python/C development and just use one language most of the time. Today I ran across a situation where an immutable associative array would be handy. While perusing the

Re: can't link a code, is it a bug or my fault?

2021-03-11 Thread rikki cattermole via Digitalmars-d-learn
Try it with: -allinst It may just be deciding a template instance isn't required.

Re: can't link a code, is it a bug or my fault?

2021-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 3/11/21 8:41 AM, Iliya wrote: > I am using dmd 2.094.1 on linux Your program links fine for me with 2.094.2 on Linux. Ali

Re: can't link a code, is it a bug or my fault?

2021-03-11 Thread Iliya via Digitalmars-d-learn
On Thursday, 11 March 2021 at 17:25:35 UTC, Ali Çehreli wrote: On 3/11/21 8:41 AM, Iliya wrote: > I am using dmd 2.094.1 on linux Your program links fine for me with 2.094.2 on Linux. Ali Thank you, Ali! I also played with it on playground. Seems that it is a bug. The compilation results:

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
On Thursday, 11 March 2021 at 14:35:45 UTC, rikki cattermole wrote: Pipe it to grep should work | grep -v "__D2" Thanks - though I'm trying to suppress the symbols being generated in the library. A colleague says it can be done in ldc but not dmd. I'll think I'll try that out.

can't link a code, is it a bug or my fault?

2021-03-11 Thread Iliya via Digitalmars-d-learn
Hello. I am using dmd 2.094.1 on linux for compiling a piece code I found on the github. Unfortunately linker can't link it as it can't find opCall symbol instantiation demangled as: pure nothrow @nogc @safe bool app.IsEqual!(char).IsEqual.opCall(in char, in char) Do you have any ideas

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Виталий Фадеев via Digitalmars-d-learn
On Thursday, 11 March 2021 at 14:23:39 UTC, Adam D. Ruppe wrote: On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев wrote: _processMouseKey = // <-- not works _processMouseMove = // <-- not works This *should* actually work. What type are those variables? struct

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread rikki cattermole via Digitalmars-d-learn
Pipe it to grep should work | grep -v "__D2"

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев wrote: _processMouseKey = // <-- not works _processMouseMove = // <-- not works This *should* actually work. What type are those variables? struct MouseKeyEvent {} struct MouseMoveEvent{} void process( ref MouseKeyEvent

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Виталий Фадеев via Digitalmars-d-learn
On Thursday, 11 March 2021 at 13:14:56 UTC, Paul Backus wrote: On Thursday, 11 March 2021 at 12:56:34 UTC, Виталий Фадеев wrote: [...] Something like this: template Overloads(alias symbol) { static if (__traits(compiles, __traits(parent, symbol))) alias Overloads

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Dennis via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:56:34 UTC, Виталий Фадеев wrote: What right way to call function directly with selecting one of two ? If they are not nested functions, you can also do: ``` // Separate names void processKey (ref MouseKeyEvent event) {...} void processMove(ref MouseMoveEvent

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:56:34 UTC, Виталий Фадеев wrote: This will generate lambda: __processMouseKey = (ref MouseKeyEvent event) { process(event); }; two calls: call labnda; call process; What right way to call function directly with selecting one of two ? Something

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Виталий Фадеев via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:48:13 UTC, Paul Backus wrote: On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев wrote: Have: void process( ref MouseKeyEvent event ) { ... } void process( ref MouseMoveEvent event ) { ... } Want:

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев wrote: Have: void process( ref MouseKeyEvent event ) { ... } void process( ref MouseMoveEvent event ) { ... } Want: _processMouseKey = // <-- not works _processMouseMove = // <-- not

Two functions with different args. Taking address of the one

2021-03-11 Thread Виталий Фадеев via Digitalmars-d-learn
Have: void process( ref MouseKeyEvent event ) { ... } void process( ref MouseMoveEvent event ) { ... } Want: _processMouseKey = // <-- not works _processMouseMove = // <-- not works What is correct way to get address of function with specific

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning*

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d?

Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: module xlutils; import core.stdc.string : strlen, strcpy; //import std.conv : to; //import std.string : toStringz; import core.stdc.stdlib :