Re: Get return type statically

2016-06-27 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 28, 2016 at 01:41:03AM +, Smoke Adams via Digitalmars-d-learn wrote: > I have a type > > public class SuperFunction(T) > { > T t; > return(T) Do() { return t(); } > } > > where T is a delegate or function. First, I would like to be able to > specify that this must be the

Re: Registration-free COM client

2016-06-27 Thread thedeemon via Digitalmars-d-learn
On Monday, 27 June 2016 at 21:17:52 UTC, Thalamus wrote: Hi everyone, I've succeeded in using D as a client for regular (registered) COM servers in the past, but in this case, I'm building the server as well. I would like to avoid registering it if possible so XCOPY-like deployment remains

Re: Get return type statically

2016-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2016 06:41 PM, Smoke Adams wrote: I have a type public class SuperFunction(T) { T t; return(T) Do() { return t(); } } where T is a delegate or function. First, I would like to be able to specify that this must be the case for SuperFunction so we can't pass non-function/delegates

Re: Get return type statically

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
I should point out also that this should be inheritable. Eventually I would like to create an algebra of SuperFunctions. e.g., SF3 = SF1 + SF2 is a new super function that combines the parameter list of SF1 and SF2 and unionizes their return type. Both functions are called by Do(which will

Re: Local fixed sized arrays

2016-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2016 04:02 PM, Smoke Adams wrote: > On Monday, 27 June 2016 at 22:56:35 UTC, Ali Çehreli wrote: >> On 06/27/2016 02:58 PM, Smoke Adams wrote: >>> I'm in need of a way to create a local array that isn't GC'ed. It must >>> be dynamic in the sense of setting the size at compile time but it

Re: Get return type statically

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
On Tuesday, 28 June 2016 at 01:41:03 UTC, "Smoke" Adams wrote: I have a type public class SuperFunction(T) { T t; return(T) Do() { return t(); } } where T is a delegate or function. First, I would like to be able to specify that this must be the case for SuperFunction so we can't pass

Get return type statically

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
I have a type public class SuperFunction(T) { T t; return(T) Do() { return t(); } } where T is a delegate or function. First, I would like to be able to specify that this must be the case for SuperFunction so we can't pass non-function/delegates for T. Second, How to specify the return

Re: Local fixed sized arrays

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
On Monday, 27 June 2016 at 22:56:35 UTC, Ali Çehreli wrote: On 06/27/2016 02:58 PM, Smoke Adams wrote: I'm in need of a way to create a local array that isn't GC'ed. It must be dynamic in the sense of setting the size at compile time but it will be used only in scope and only on structs.

Re: Local fixed sized arrays

2016-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2016 02:58 PM, Smoke Adams wrote: I'm in need of a way to create a local array that isn't GC'ed. It must be dynamic in the sense of setting the size at compile time but it will be used only in scope and only on structs. function x(int y) { bool[y] arr; arr ~= 3; } I care

Re: Dynamic array of objects

2016-06-27 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 27 June 2016 at 22:00:15 UTC, gummybears wrote: Hi, Today thought lets learn D. I am writing a compiler for a language and read D compiles very fast. Switched my compiler from C++ to D and ran my test suite to use D. Doing somethin wrong as creating array of objects gives me a

Dynamic array of objects

2016-06-27 Thread gummybears via Digitalmars-d-learn
Hi, Today thought lets learn D. I am writing a compiler for a language and read D compiles very fast. Switched my compiler from C++ to D and ran my test suite to use D. Doing somethin wrong as creating array of objects gives me a segmentation fault Example import std.stdio; class Pair {

Local fixed sized arrays

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
I'm in need of a way to create a local array that isn't GC'ed. It must be dynamic in the sense of setting the size at compile time but it will be used only in scope and only on structs. function x(int y) { bool[y] arr; arr ~= 3; } I care about slicing or anything but appending,

Forward References

2016-06-27 Thread Jonathan Marler via Digitalmars-d-learn
Do the various D compilers use multiple passes to handle forward references or some other technique?

Registration-free COM client

2016-06-27 Thread Thalamus via Digitalmars-d-learn
Hi everyone, I've succeeded in using D as a client for regular (registered) COM servers in the past, but in this case, I'm building the server as well. I would like to avoid registering it if possible so XCOPY-like deployment remains an option. Can a registration-free COM client be built in

Re: Getting the template name of a template instantiation

2016-06-27 Thread Nordlöw via Digitalmars-d-learn
On Monday, 27 June 2016 at 17:17:19 UTC, John wrote: import std.traits; __traits(identifier, TemplateOf!(S!int)); Scratch that, this is what you want: import std.traits; static assert(__traits(isSame, TemplateOf!(S!int), S)); I believe this is what import std.traits : isInstanceOf; is

Re: Diff between function and delegate

2016-06-27 Thread Mathias Lang via Digitalmars-d-learn
On Monday, 27 June 2016 at 19:34:06 UTC, "Smoke" Adams wrote: I have alias fnc = void function(Object); alias del = void delegate(); Does func avoid the GC? I am passing in this to Object so I don't technically need a delegate or a "context". I want to be sure that I'm actually gaining

Diff between function and delegate

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
I have alias fnc = void function(Object); alias del = void delegate(); Does func avoid the GC? I am passing in this to Object so I don't technically need a delegate or a "context". I want to be sure that I'm actually gaining something here by doing this. I read somewhere that delegates only

Re: executeShell doesn't work but system does

2016-06-27 Thread Smoke Adams via Digitalmars-d-learn
On Sunday, 26 June 2016 at 16:02:18 UTC, ag0aep6g wrote: On 06/26/2016 05:37 PM, Smoke Adams wrote: [...] Unsolicited spelling correction: no 'i' in "deprecated". [...] `system` directly prints its output, `executeShell` returns it in a tuple with the status code. Maybe cls works by

Re: Getting the template name of a template instantiation

2016-06-27 Thread John via Digitalmars-d-learn
On Monday, 27 June 2016 at 17:14:23 UTC, John wrote: On Monday, 27 June 2016 at 16:40:09 UTC, Nordlöw wrote: If I have a template parameter E = S!int where struct S(T) { S x; } how can I extract the template name part `S` from E`? Something like: static

Re: Getting the template name of a template instantiation

2016-06-27 Thread Ali Çehreli via Digitalmars-d-learn
On 06/27/2016 09:54 AM, Lodovico Giaretta wrote: On Monday, 27 June 2016 at 16:40:09 UTC, Nordlöw wrote: If I have a template parameter E = S!int where struct S(T) { S x; } how can I extract the template name part `S` from E`? Something like: static

Re: Getting the template name of a template instantiation

2016-06-27 Thread John via Digitalmars-d-learn
On Monday, 27 June 2016 at 16:40:09 UTC, Nordlöw wrote: If I have a template parameter E = S!int where struct S(T) { S x; } how can I extract the template name part `S` from E`? Something like: static assert(is(templateName!(S!int) == S)); Is this already in Phobos somewhere?

Re: Getting the template name of a template instantiation

2016-06-27 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 27 June 2016 at 16:40:09 UTC, Nordlöw wrote: If I have a template parameter E = S!int where struct S(T) { S x; } how can I extract the template name part `S` from E`? Something like: static assert(is(templateName!(S!int) == S)); Is this already in Phobos somewhere?

Getting the template name of a template instantiation

2016-06-27 Thread Nordlöw via Digitalmars-d-learn
If I have a template parameter E = S!int where struct S(T) { S x; } how can I extract the template name part `S` from E`? Something like: static assert(is(templateName!(S!int) == S)); Is this already in Phobos somewhere?

Re: executeShell doesn't work but system does

2016-06-27 Thread Satoshi via Digitalmars-d-learn
On Sunday, 26 June 2016 at 19:01:07 UTC, cym13 wrote: On Sunday, 26 June 2016 at 17:56:08 UTC, Satoshi wrote: On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote: system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new

Re: executeShell doesn't work but system does

2016-06-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/26/16 12:02 PM, ag0aep6g wrote: On 06/26/2016 05:37 PM, Smoke Adams wrote: system("cls") works but executeShell doesn't. system is depreciated. Use spawn-related function, and avoid capturing output instead. Not sure if you need to call spawnShell (which creates a new system shell to