Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 27, 2021 at 01:03:56AM +, Jack via Digitalmars-d-learn wrote: > On Friday, 26 February 2021 at 23:37:18 UTC, Murilo wrote: > > On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: > > > I started with: > > > > > > enum isAssignableNull(T) = is(T : Object) || isPointer(T); > >

Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 23:37:18 UTC, Murilo wrote: On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases? You can check if it's null with this `variable is null` and you can

Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread Murilo via Digitalmars-d-learn
On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases? You can check if it's null with this `variable is null` and you can test it with assert as in `assert(variable is null);`

Re: Can Metaprogramming Help Here?

2021-02-26 Thread Mike Brown via Digitalmars-d-learn
On Friday, 26 February 2021 at 20:42:50 UTC, H. S. Teoh wrote: On Fri, Feb 26, 2021 at 11:37:18AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > [...] [...] Alright, here's an actual working example. Instead of using classes, I decided to use templates instead, but the underlying

Re: Can Metaprogramming Help Here?

2021-02-26 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 26, 2021 at 11:37:18AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Feb 24, 2021 at 08:10:30PM +, Mike Brown via Digitalmars-d-learn > wrote: > [...] > > Thank you for the reply. Im struggling extending this to get the > > nesting working. [...] Alright, here's an

Re: How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:37:34 UTC, Adam D. Ruppe wrote: On Friday, 26 February 2021 at 19:32:52 UTC, Jack wrote: I managed to do this with alias parameter in a template: this is the only way, it needs to be an alias template Also, can I short this template function somehow to

Re: How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:32:52 UTC, Jack wrote: I managed to do this with alias parameter in a template: this is the only way, it needs to be an alias template Also, can I short this template function somehow to syntax f!(a) omitting the g? rename g to f. If the function inside

Re: Can Metaprogramming Help Here?

2021-02-26 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 24, 2021 at 08:10:30PM +, Mike Brown via Digitalmars-d-learn wrote: [...] > Thank you for the reply. Im struggling extending this to get the > nesting working. > > I'm trying something like: > > string entry(string i, string[] inherit = []) { > return i; > } > > alias

Re: ldc on a raspberry pi 3 running freebsd

2021-02-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-02-23 16:34, Decabytes wrote: ldc2 is the winner thank you! I'd like to get gdc and dmd up and running to at some point Unfortunately, DMD doesn't support ARM. -- /Jacob Carlborg

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:00:57 UTC, H. S. Teoh wrote: On Fri, Feb 26, 2021 at 06:53:32PM +, evilrat via Digitalmars-d-learn wrote: On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: > On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: > > "targetType":

How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Jack via Digitalmars-d-learn
int a = 10; f(a); // print "a" int b = 10; f(b); // print "b" I managed to do this with alias parameter in a template: template f(alias s, string file = __FILE__, size_t line = __LINE__) { import std.exception : enforce; import std.string : format; void g() {

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 18:53:32 UTC, evilrat wrote: On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: "targetType": "executable", and it should just run using "dub run" Unfortunately, the problem remains :/

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:00:57 UTC, H. S. Teoh wrote: On Fri, Feb 26, 2021 at 06:53:32PM +, evilrat via Digitalmars-d-learn wrote: On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: > On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: > > "targetType":

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 18:53:32 UTC, evilrat wrote: On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: "targetType": "executable", and it should just run using "dub run" Unfortunately, the problem remains :/

Re: How do I check if a type is assignable to null at compile time?

2021-02-26 Thread Jack via Digitalmars-d-learn
On Friday, 26 February 2021 at 05:45:39 UTC, Nathan S. wrote: On Friday, 26 February 2021 at 05:34:26 UTC, Paul Backus wrote: On Friday, 26 February 2021 at 05:25:14 UTC, Jack wrote: I started with: enum isAssignableNull(T) = is(T : Object) || isPointer(T); but how do I cover all cases?

Re: DUB is not working correctly

2021-02-26 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 26, 2021 at 06:53:32PM +, evilrat via Digitalmars-d-learn wrote: > On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: > > On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: > > > "targetType": "executable", > > > > > > and it should just run using "dub run" > >

Re: DUB is not working correctly

2021-02-26 Thread evilrat via Digitalmars-d-learn
On Friday, 26 February 2021 at 18:20:38 UTC, Maxim wrote: On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: "targetType": "executable", and it should just run using "dub run" Unfortunately, the problem remains :/ Looks like something specific to your machine. The last thing

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 17:57:12 UTC, ryuukk_ wrote: "targetType": "executable", and it should just run using "dub run" Unfortunately, the problem remains :/

Re: DUB is not working correctly

2021-02-26 Thread ryuukk_ via Digitalmars-d-learn
"targetType": "executable", and it should just run using "dub run"

Re: Optimizing for SIMD: best practices?(i.e. what features are allowed?)

2021-02-26 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 25 February 2021 at 14:28:40 UTC, Guillaume Piolat wrote: On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote: How does one optimize code to make full use of the CPU's SIMD capabilities? Is there any way to guarantee that "packed" versions of SIMD instructions will be

Re: DUB is not working correctly

2021-02-26 Thread Maxim via Digitalmars-d-learn
On Friday, 26 February 2021 at 09:15:02 UTC, Siemargl wrote: On Thursday, 25 February 2021 at 17:38:11 UTC, Maxim wrote: On Thursday, 25 February 2021 at 17:34:29 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: [...] I think, I need to rephrase the question

Re: DUB is not working correctly

2021-02-26 Thread Siemargl via Digitalmars-d-learn
On Thursday, 25 February 2021 at 17:38:11 UTC, Maxim wrote: On Thursday, 25 February 2021 at 17:34:29 UTC, Maxim wrote: On Wednesday, 24 February 2021 at 16:13:48 UTC, Maxim wrote: [...] I think, I need to rephrase the question for the present situtation: how can I force DUB to change