Re: Range with an alias parameter

2019-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/19 3:56 PM, Alex wrote: Ok... strange... it doesn't in fact... as this works: ´´´ import std.experimental.all; void main() {     S!42 s;     auto res = s[];     static assert(isInputRange!(typeof(res)));     res.front.writeln; } //static

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: Range with an alias parameter

2019-01-30 Thread Alex via Digitalmars-d-learn
On Wednesday, 30 January 2019 at 20:13:56 UTC, Alex wrote: Given this: ´´´ import std.experimental.all; void main(){} static assert(isInputRange!(ReturnType!(produceS!(42))[])); auto produceS(size_t param)() { return S!param(); } struct S(size_t param) { //@disable this(this); auto

Range with an alias parameter

2019-01-30 Thread Alex via Digitalmars-d-learn
Given this: ´´´ import std.experimental.all; void main(){} static assert(isInputRange!(ReturnType!(produceS!(42))[])); auto produceS(size_t param)() { return S!param(); } struct S(size_t param) { //@disable this(this); auto opIndex() { return produceRange!(this); } } auto

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: Should I prefix package names with the name of my program?

2019-01-30 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jan 28, 2019 at 05:07:35PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 1/28/19 4:57 PM, Steven Schveighoffer wrote: > > On 1/28/19 3:16 PM, H. S. Teoh wrote: [...] > > > > I use a package nearly every time because if you don't, you run > > > > into weird quirks of the

Re: Is there something special required to use Appender.clear

2019-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/19 7:32 AM, FeepingCreature wrote: On Monday, 28 January 2019 at 15:16:54 UTC, Steven Schveighoffer wrote: It will inspect the allocated length from the GC if the array is appendable from the beginning. So it's not always going to reallocate. e.g.: string x = "abc".idup; auto app =

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: Status of BetterC

2019-01-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/01/2019 3:12 AM, Pavel Vozenilek wrote: I am interested in viability of using BetterC (and only BetterC) for a project. 1. Is BetterC supported by GDC and LDC compilers? LDC yes, dunno about GDC but it'll depend upon the version. 2. Is there debugger/editor/IDE support? Not

Status of BetterC

2019-01-30 Thread Pavel Vozenilek via Digitalmars-d-learn
I am interested in viability of using BetterC (and only BetterC) for a project. 1. Is BetterC supported by GDC and LDC compilers? 2. Is there debugger/editor/IDE support? 3. The only language specific documentation seems to be https://dlang.org/spec/betterc.html Is more documentation

Re: Is there something special required to use Appender.clear

2019-01-30 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 28 January 2019 at 15:16:54 UTC, Steven Schveighoffer wrote: It will inspect the allocated length from the GC if the array is appendable from the beginning. So it's not always going to reallocate. e.g.: string x = "abc".idup; auto app = x.appender; app ~= "xyz"; // does not

Re: Can't build vibed:tls project

2019-01-30 Thread WebFreak001 via Digitalmars-d-learn
On Monday, 28 January 2019 at 20:08:31 UTC, Suliman wrote: If I am specifying (sic! TLS): dependency "vibe-d:tls" version="0.8.4" in my dub.sdl I am getting error when building simple project: module `vibe` is in file 'vibe\vibe.d' which cannot be read But I need to get vibed build with

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