Re: Get compilation errors within opDispatch?

2020-02-17 Thread cc via Digitalmars-d-learn
On Monday, 17 February 2020 at 17:01:12 UTC, Adam D. Ruppe wrote: It sometimes helps to write it out log-form foo.opDispatch!"hello"(5); should give the full error. this btw is one of the most annoying missing errors in d... This worked, thank you! On Monday, 17 February 2020 at 16:45:53

Re: Get compilation errors within opDispatch?

2020-02-17 Thread Ali Çehreli via Digitalmars-d-learn
On 2/17/20 8:41 AM, cc wrote: Is there any way to see the compilation errors that occurred within an opDispatch template? struct Foo { void opDispatch(string s, SA...)(SA sargs) {     literally anything; } } Foo foo; foo.hello(5); Result:  Error: no property `hello` for type

Get compilation errors within opDispatch?

2020-02-17 Thread cc via Digitalmars-d-learn
Is there any way to see the compilation errors that occurred within an opDispatch template? struct Foo { void opDispatch(string s, SA...)(SA sargs) { literally anything; } } Foo foo; foo.hello(5); Result: Error: no property `hello` for type `Foo` Desired

Re: Difference between range `save` and copy constructor

2020-02-17 Thread uranuz via Digitalmars-d-learn
> Either way, generic code should never be using a range after > it's been copied, and copying is a key part of how > idiomatic, range-based code works in D. OK. Thanks for instructions. I shall give it a try.

Re: Get compilation errors within opDispatch?

2020-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 February 2020 at 16:41:54 UTC, cc wrote: Foo foo; foo.hello(5); Result: Error: no property `hello` for type `Foo` It sometimes helps to write it out log-form foo.opDispatch!"hello"(5); should give the full error. this btw is one of the most annoying missing errors in d...

Re: Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Adnan via Digitalmars-d-learn
On Monday, 17 February 2020 at 14:34:44 UTC, Simen Kjærås wrote: On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote: // All in all, I end up with this code: module strassens_matmul package { T[][] mulIterative(T)(const T[][] mat1, const T[][] mat2) { auto result =

Re: dub / use git branch

2020-02-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/16/20 9:01 AM, Robert M. Münch wrote: I want to use a specific branch version if a package. I specified the branch version in a dub.selections.json file. But it seems that dub requires a ZIP file that can be downloaded from code.dlang.org, which of course fails because the branch is only

Re: betterC CTFE nested switch

2020-02-17 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:51:03 UTC, Abby wrote: On Monday, 17 February 2020 at 11:05:46 UTC, Stefan Koch wrote: On Monday, 17 February 2020 at 10:18:32 UTC, Abby wrote: [...] I have a ctfe compatible string formatter, you should be to find it here

Re: Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Paul Backus via Digitalmars-d-learn
On Monday, 17 February 2020 at 20:08:24 UTC, Adnan wrote: On Monday, 17 February 2020 at 14:34:44 UTC, Simen Kjærås wrote: On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote: // All in all, I end up with this code: module strassens_matmul package { T[][] mulIterative(T)(const

Re: How to get the name of an object's class at compile time?

2020-02-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/17/20 2:28 AM, Nathan S. wrote: What I want is something like this: string className(in Object obj) {     return obj is null ? "null" : typeid(obj).name; } ...except I want it to work in CTFE. What is the way to do this in D? https://issues.dlang.org/show_bug.cgi?id=7147

Re: How to get the name of an object's class at compile time?

2020-02-17 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 17 February 2020 at 18:49:55 UTC, Steven Schveighoffer wrote: On 2/17/20 2:28 AM, Nathan S. wrote: What I want is something like this: string className(in Object obj) {     return obj is null ? "null" : typeid(obj).name; } ...except I want it to work in CTFE. What is the

Re: How to get the name of an object's class at compile time?

2020-02-17 Thread Basile B. via Digitalmars-d-learn
On Monday, 17 February 2020 at 22:34:31 UTC, Stefan Koch wrote: Upon seeing this I just implemented typeid(stuff).name; https://github.com/dlang/dmd/pull/10796 With any luck this will be possible in the next release ;) Can this work using `stuff.classinfo.name` too ? This is the same as

DPP: Linker issue with functions implemented in C header files

2020-02-17 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to get wrap the "Azure SDK for C" using DPP and have following issue. Functions, which are actually implemented in C header files will cause linker errors: https://github.com/Azure/azure-sdk-for-c/blob/master/sdk/core/core/inc/az_span.h#L91 Example: AZ_NODISCARD AZ_INLINE az_span

betterC CTFE nested switch

2020-02-17 Thread Abby via Digitalmars-d-learn
Hi there guys, I was trying to generated code during compile time. Bassicly I'm creating a tokenizer and I would like to generated nested switch using betterC. Basically convert something like this: enum tokens = [ ['!', '='], ['>', '='], ['>'], ]; to: switch(str[i]) { case

Re: betterC CTFE nested switch

2020-02-17 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 17 February 2020 at 10:18:32 UTC, Abby wrote: Hi there guys, I was trying to generated code during compile time. Bassicly I'm creating a tokenizer and I would like to generated nested switch using betterC. [...] I have a ctfe compatible string formatter, you should be to find

From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread foozzer via Digitalmars-d-learn
Hi all, There's something in Phobos for that? Thank you

Re: From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:51:52 UTC, FeepingCreature wrote: On Monday, 17 February 2020 at 11:07:33 UTC, foozzer wrote: Hi all, There's something in Phobos for that? Thank you Here you go: import std; // extract the types that make up the tuple auto transposeTuple(T :

Re: From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread FeepingCreature via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:07:33 UTC, foozzer wrote: Hi all, There's something in Phobos for that? Thank you Here you go: import std; // extract the types that make up the tuple auto transposeTuple(T : Tuple!Types[], Types...)(T tuples) { // templated function that extracts the

Re: betterC CTFE nested switch

2020-02-17 Thread Abby via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:05:46 UTC, Stefan Koch wrote: On Monday, 17 February 2020 at 10:18:32 UTC, Abby wrote: Hi there guys, I was trying to generated code during compile time. Bassicly I'm creating a tokenizer and I would like to generated nested switch using betterC. [...] I

Re: From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:51:52 UTC, FeepingCreature wrote: Here you go: import std; // extract the types that make up the tuple auto transposeTuple(T : Tuple!Types[], Types...)(T tuples) { // templated function that extracts the ith field of an array of tuples as an array

Re: From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 February 2020 at 11:07:33 UTC, foozzer wrote: Hi all, There's something in Phobos for that? Thank you import std.meta : staticMap; import std.typecons : Tuple; // Turn types into arrays alias ToArray(T) = T[]; // Leave everything else the same alias ToArray(T...) = T; // Now

Re: How to iterate over range two items at a time

2020-02-17 Thread Basile B. via Digitalmars-d-learn
On Monday, 17 February 2020 at 09:41:35 UTC, Adnan wrote: On Monday, 17 February 2020 at 07:50:02 UTC, Mitacha wrote: On Monday, 17 February 2020 at 05:04:02 UTC, Adnan wrote: What is the equivalent of Rust's chunks_exact()[1] method in D? I want to iterate over a spitted string two chunks at

best practices for a new project

2020-02-17 Thread Panke via Digitalmars-d-learn
When I start a new project is there anything that I should get right from the start? Like using a specific set of compiler flags (e.g. -dip1000)? Is there an overview over the status of upcoming language changes (-preview=?), e.g. what about -preview=rvaluerefparam? Should I use it?

Re: How to iterate over range two items at a time

2020-02-17 Thread Adnan via Digitalmars-d-learn
On Monday, 17 February 2020 at 07:50:02 UTC, Mitacha wrote: On Monday, 17 February 2020 at 05:04:02 UTC, Adnan wrote: What is the equivalent of Rust's chunks_exact()[1] method in D? I want to iterate over a spitted string two chunks at a time. [1]

Re: Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Adnan via Digitalmars-d-learn
On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote: On Monday, 17 February 2020 at 13:44:55 UTC, Adnan wrote: [...] Okay I changed to module strassens_matmul; [...] I changed getPointPtr to following and now it works /// row and column are 0 index-based void assign(T)(ref

Re: operator overload for sh-like scripting ?

2020-02-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 February 2020 at 13:03:38 UTC, Basile B. wrote: eg Sh(echo) < "meh"; struct Sh { // you see the idea we have op overload for < here } You can't overload < separately - all the comparison operators (<, <=, >, >=) are handled via opCmp. Even if you choose to go down

Re: From [Tuple!(A,B), ...] to Tuple!(A[], B[])

2020-02-17 Thread foozzer via Digitalmars-d-learn
On Monday, 17 February 2020 at 12:11:38 UTC, Simen Kjærås wrote: On Monday, 17 February 2020 at 11:51:52 UTC, FeepingCreature wrote: [...] One tiny thing: the above fails for tuples with named fields, like Tuple!(int, "a", string "b"). This code handles that case, and preserves field names:

Re: operator overload for sh-like scripting ?

2020-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 February 2020 at 13:03:38 UTC, Basile B. wrote: Sh(echo) < "meh"; Not allowed in D - it only does a comparison overload which covers < and > (and <= and >=). Though we could do strings and stuff. especially with my string interpolation dip

Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Adnan via Digitalmars-d-learn
https://ideone.com/lVi5Uy module strassens_matmul; debug { static import std; } package { ulong getRowSize(T)(T[][] mat) { return mat[0].length; } ulong getColumnSize(T)(T[][] mat) { return mat.length; } T[][] createMatrix(T)(const ulong rowSize, const

operator overload for sh-like scripting ?

2020-02-17 Thread Basile B. via Digitalmars-d-learn
eg Sh(echo) < "meh"; struct Sh { // you see the idea we have op overload for < here }

Re: Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Adnan via Digitalmars-d-learn
On Monday, 17 February 2020 at 13:44:55 UTC, Adnan wrote: https://ideone.com/lVi5Uy module strassens_matmul; debug { static import std; } ... Okay I changed to module strassens_matmul; debug { static import std; } package { ulong getRowSize(T)(scope const T[][] mat) {

Re: Why can't I pass a const array to a function that takes scope const arrays?

2020-02-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote: cdsa ~master: building configuration "cdsa-test-library"... source/strassens_matmul.d(22,16): Error: cannot implicitly convert expression [row][column] of type const(uint)* to uint* source/strassens_matmul.d(37,36): Error: template