Re: __traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 26 November 2018 at 10:53:25 UTC, Eduard Staniloiu wrote: I would like to see this in the compiler traits :D https://github.com/dlang/dmd/pull/9014

Re: dip1000 rule 5

2018-11-26 Thread sclytrack via Digitalmars-d-learn
On Sunday, 25 November 2018 at 19:22:36 UTC, sclytrack wrote: There are 4 rules listed. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md What is rule 5? int* global_ptr; void abc() { scope int* a; int* b; scope int* c = a; // Error, rule 5 scope int* d = b;

Re: __traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Eduard Staniloiu via Digitalmars-d-learn
On Monday, 26 November 2018 at 09:28:37 UTC, Basile B. wrote: On Monday, 26 November 2018 at 09:04:25 UTC, Per Nordlöw wrote: Why is there no - __traits(isArray, T) alongside - __traits(isStaticArray, T) and - __traits(isAssociativeArray, T) when dmd already has `ENUMTY.Tarray` alongside -

Re: __traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Basile B. via Digitalmars-d-learn
On Monday, 26 November 2018 at 09:04:25 UTC, Per Nordlöw wrote: Why is there no - __traits(isArray, T) alongside - __traits(isStaticArray, T) and - __traits(isAssociativeArray, T) when dmd already has `ENUMTY.Tarray` alongside - ENUMTY.Tsarray and - ENUMTY.Taarray and std.traits already

__traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Per Nordlöw via Digitalmars-d-learn
Why is there no - __traits(isArray, T) alongside - __traits(isStaticArray, T) and - __traits(isAssociativeArray, T) when dmd already has `ENUMTY.Tarray` alongside - ENUMTY.Tsarray and - ENUMTY.Taarray and std.traits already has a wrapper for this at

Re: How do I the temlate parameter name as string?

2018-11-26 Thread Soulsbane via Digitalmars-d-learn
On Tuesday, 27 November 2018 at 02:00:44 UTC, PacMan wrote: ParameterIdentifierTuple from std.traits did work fine for regular functions but not for template functions: Error: template instance `std.traits.ParameterIdentifierTuple!(f)` does not match template declaration

How do I the temlate parameter name as string?

2018-11-26 Thread PacMan via Digitalmars-d-learn
ParameterIdentifierTuple from std.traits did work fine for regular functions but not for template functions: Error: template instance `std.traits.ParameterIdentifierTuple!(f)` does not match template declaration `ParameterIdentifierTuple(func...) if (func.length == 1 && isCallable!func)`

Re: How do I the temlate parameter name as string?

2018-11-26 Thread Neia Neutuladh via Digitalmars-d-learn
On Tue, 27 Nov 2018 02:00:44 +, PacMan wrote: > f is defined as: > >> void f(T)(T t, string p) >> if(is(T == A) || is(T == B)) >>{ >> // ... >>} > > my goal is get "p" as string. `f` is a template that generates functions. Before you instantiate that template, the function doesn't

Re: handling shared objects

2018-11-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/26/18 9:00 AM, Alex wrote: Hi all! Can somebody explain to me, why the example below is not working in a way I'm expecting it to work? My example is a little bit longer this time, however the half of it is taken from https://dlang.org/library/std/concurrency/receive_only.html ´´´

handling shared objects

2018-11-26 Thread Alex via Digitalmars-d-learn
Hi all! Can somebody explain to me, why the example below is not working in a way I'm expecting it to work? My example is a little bit longer this time, however the half of it is taken from https://dlang.org/library/std/concurrency/receive_only.html ´´´ import std.experimental.all; struct

Re: __traits for checking if a type is dynamic array (slice)

2018-11-26 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 11/26/18 4:04 AM, Per Nordlöw wrote: Why is there no - __traits(isArray, T) alongside - __traits(isStaticArray, T) and - __traits(isAssociativeArray, T) Thanks for bringing this to my attention, Per. The core idea is to have __traits "primitive and ugly" and std.traits "convenient and

Re: Cannot build project due to Derelict package

2018-11-26 Thread Alex via Digitalmars-d-learn
On Monday, 26 November 2018 at 11:57:40 UTC, Andrey wrote: Hello, I try to build my project using command "dub build" but I can\t because there is an error: Fetching derelict-util 3.0.0-beta.2 (getting selected version)... SSL connect error on handle 1F19AC0 And this happens every time... As

derelict-sdl2 automatically stripping the SDL_ prefix from names

2018-11-26 Thread ProgramGamer via Digitalmars-d-learn
Hi, I attempted to use a combination of traits and mixins to automatically create aliases of names in SDL2 without the SDL_ prefix for convenience. However, I was only able to achieve this for functions in the module, and not for types nor enum values. How could I go about achieving the

Re: handling shared objects

2018-11-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/26/18 10:16 AM, Alex wrote: On Monday, 26 November 2018 at 14:28:33 UTC, Steven Schveighoffer wrote: A static member is stored per thread. If you want a global that's shared between all threads, you need to make it shared. But the result may not be what you are looking for, shared can

Re: How to iterate getSymbolsByUDA

2018-11-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/26/18 8:59 AM, Adam D. Ruppe wrote: On Monday, 26 November 2018 at 13:50:13 UTC, Eko Wahyudin wrote: seems my problem is i use GDC, i got this error error: basic type expected, not foreach. The common versions of gdc don't support static foreach, but plain foreach should work there

Re: handling shared objects

2018-11-26 Thread Alex via Digitalmars-d-learn
On Monday, 26 November 2018 at 15:26:43 UTC, Steven Schveighoffer wrote: Well, if you want to run calculations in another thread, then send the result back to the original, you may be better off sending the state needed for the calculation to the worker thread, and receiving the result back

Re: handling shared objects

2018-11-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/26/18 10:37 AM, Alex wrote: On Monday, 26 November 2018 at 15:26:43 UTC, Steven Schveighoffer wrote: Well, if you want to run calculations in another thread, then send the result back to the original, you may be better off sending the state needed for the calculation to the worker

Re: D is supposed to compile fast.

2018-11-26 Thread welkam via Digitalmars-d-learn
On Sunday, 25 November 2018 at 22:00:21 UTC, Chris Katko wrote:. So 1) I have to compile manually, then link. Except that also runs the files every time even if they're up-to-date. Is that normal behavior for C/C++? Well you dont have to use separate commands but yes compiling and linking

Re: handling shared objects

2018-11-26 Thread Alex via Digitalmars-d-learn
On Monday, 26 November 2018 at 14:28:33 UTC, Steven Schveighoffer wrote: Some problems arose: 1. Obviously, this is not the case, as the output is different, depending on the thread I start the model function. Yes, unless you declare the model to be shared, there is a copy made for each

Re: handling shared objects

2018-11-26 Thread Alex via Digitalmars-d-learn
On Monday, 26 November 2018 at 16:27:23 UTC, Steven Schveighoffer wrote: On 11/26/18 10:37 AM, Alex wrote: On Monday, 26 November 2018 at 15:26:43 UTC, Steven Schveighoffer wrote: Well, if you want to run calculations in another thread, then send the result back to the original, you may be

Re: D is supposed to compile fast.

2018-11-26 Thread aliak via Digitalmars-d-learn
On Monday, 26 November 2018 at 03:09:03 UTC, Mike Parker wrote: I mean, can you think of any module in the Python/Javascript/C# standard library that simply including it will swell your program to the point it can't compile? I'm not an omnipotent master programmer, but as a professional, I

Re: Cannot build project due to Derelict package

2018-11-26 Thread Andrey via Digitalmars-d-learn
On Monday, 26 November 2018 at 12:11:03 UTC, Alex wrote: On Monday, 26 November 2018 at 11:57:40 UTC, Andrey wrote: Hello, I try to build my project using command "dub build" but I can\t because there is an error: Fetching derelict-util 3.0.0-beta.2 (getting selected version)... SSL connect

Re: How to iterate getSymbolsByUDA

2018-11-26 Thread Eko Wahyudin via Digitalmars-d-learn
On Sunday, 25 November 2018 at 01:01:30 UTC, bauss wrote: On Saturday, 24 November 2018 at 08:50:59 UTC, Eko Wahyudin wrote: On Saturday, 24 November 2018 at 08:09:38 UTC, Stanislav Blinov wrote: [...] aah ya,, this statement is work static foreach (i; 0 .. symbols.length) thank you. It

Re: interrupting a function

2018-11-26 Thread Alex via Digitalmars-d-learn
On Saturday, 17 November 2018 at 08:17:36 UTC, Paul Backus wrote: You could run the calculation in another thread and use std.concurrency.receiveTimeout [1] to stop waiting for the result after a certain amount of time. Ok... would you say the following is a feasible alternative? ´´´ import

Cannot build project due to Derelict package

2018-11-26 Thread Andrey via Digitalmars-d-learn
Hello, I try to build my project using command "dub build" but I can\t because there is an error: Fetching derelict-util 3.0.0-beta.2 (getting selected version)... SSL connect error on handle 1F19AC0 And this happens every time... As I understand dub can't find package. In dub.json I have

Re: How to iterate getSymbolsByUDA

2018-11-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 November 2018 at 13:50:13 UTC, Eko Wahyudin wrote: seems my problem is i use GDC, i got this error error: basic type expected, not foreach. The common versions of gdc don't support static foreach, but plain foreach should work there the same way in this context. So just

Re: version(StdDoc)

2018-11-26 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Nov 25, 2018 at 09:53:50PM +, Stanislav Blinov via Digitalmars-d-learn wrote: > On Sunday, 25 November 2018 at 21:38:43 UTC, H. S. Teoh wrote: > > > Actually, I just thought of a way to do this with the existing language: > > use a struct to simulate an enum: > > > > struct E {

Re: D is supposed to compile fast.

2018-11-26 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote: Any time I see people mention the benefits of D, I see "compile times" "compile times" "compile times" over and over. I'm using very modest amounts of templates, for a fairly small sized program (very early work toward a game),