Re: How can I express the type of a function in D?

2019-02-04 Thread dnsmt via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. Did you consider

Re: How can I express the type of a function in D?

2019-02-01 Thread Atila Neves via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. There's a way: int add(int i,

Re: How can I express the type of a function in D?

2019-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/19 1:39 PM, Ali Çehreli wrote: On 01/30/2019 07:47 AM, Steven Schveighoffer wrote: > On 1/30/19 12:14 AM, Sobaya wrote: >> I want to get a mangled name of a D function by >> `core.demangle.mangle`, but I'm in trouble because there are no ways >> to express a type of a function, which

Re: How can I express the type of a function in D?

2019-01-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Wed, 30 Jan 2019 12:56:06 -0800, Ali Çehreli wrote: > I remember names like _add. Is that a Windows thing? A number of functions are implemented as manually-mangled names with preprocessor macros that forward to them. It's weird, but it happens.

Re: How can I express the type of a function in D?

2019-01-30 Thread Ali Çehreli via Digitalmars-d-learn
On 01/30/2019 11:42 AM, H. S. Teoh wrote: On Wed, Jan 30, 2019 at 10:39:21AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: [...] I wonder why the inconsistency. On the other hand, .mangleof produces just "add" when the function is extern(C). (?) [...] For extern(C), this is correct

Re: How can I express the type of a function in D?

2019-01-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 30, 2019 at 07:51:17PM +, Neia Neutuladh via Digitalmars-d-learn wrote: > On Wed, 30 Jan 2019 10:39:21 -0800, Ali Çehreli wrote: > > import core.demangle; > > > > extern(C) int add(int, int); > > > > void main() { > >alias F = typeof(add); > >pragma(msg,

Re: How can I express the type of a function in D?

2019-01-30 Thread Neia Neutuladh via Digitalmars-d-learn
On Wed, 30 Jan 2019 10:39:21 -0800, Ali Çehreli wrote: > import core.demangle; > > extern(C) int add(int, int); > > void main() { >alias F = typeof(add); >pragma(msg, mangle!F("add")); >pragma(msg, add.mangleof); > } > > Output: > > _D3addUiiZi > add <-- Is that

Re: How can I express the type of a function in D?

2019-01-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 30, 2019 at 10:39:21AM -0800, Ali Çehreli via Digitalmars-d-learn wrote: [...] > I wonder why the inconsistency. On the other hand, .mangleof produces > just "add" when the function is extern(C). (?) [...] For extern(C), this is correct behaviour, because that's how a C function

Re: How can I express the type of a function in D?

2019-01-30 Thread Ali Çehreli via Digitalmars-d-learn
On 01/30/2019 07:47 AM, Steven Schveighoffer wrote: > On 1/30/19 12:14 AM, Sobaya wrote: >> I want to get a mangled name of a D function by >> `core.demangle.mangle`, but I'm in trouble because there are no ways >> to express a type of a function, which is used for a template argument >> of

Re: How can I express the type of a function in D?

2019-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/19 12:14 AM, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. For example, it is wrong to use the type `int

Re: How can I express the type of a function in D?

2019-01-30 Thread Ali Çehreli via Digitalmars-d-learn
On 01/29/2019 09:14 PM, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. For example, it is wrong to use the type `int

Re: How can I express the type of a function in D?

2019-01-29 Thread Sobaya via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 06:02:02 UTC, FrankLike wrote: On Wednesday, 30 January 2019 at 05:40:50 UTC, FrankLike wrote: On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote: [...] import std.stdio; import std.process:executeShell; import core.demangle; void main() {

Re: How can I express the type of a function in D?

2019-01-29 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 05:40:50 UTC, FrankLike wrote: On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a

Re: How can I express the type of a function in D?

2019-01-29 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 05:14:20 UTC, Sobaya wrote: I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. For example, it is wrong to

How can I express the type of a function in D?

2019-01-29 Thread Sobaya via Digitalmars-d-learn
I want to get a mangled name of a D function by `core.demangle.mangle`, but I'm in trouble because there are no ways to express a type of a function, which is used for a template argument of `mangle`. For example, it is wrong to use the type `int function(int,int)` to express the type of