On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote:
What happens here is, the compiler first tries the D2-style
rewrite:
```d
s.opIndexAssign(arr[1..4], s.opSlice!0(0, 3))
```
However, that rewrite fails to compile, because your `opSlice`
does not take a template argument
On Sunday, 10 October 2021 at 17:14:30 UTC, Adam Ruppe wrote:
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
The language subset "BetterC" is required for calling D
functions from C though.
This is false.
You can use any D features when calling it from C, you just
need to provide
Btw, I should have written:
`s.opIndexAssign(arr[1..4], s.opSlice(0,3));`
But it compiles the same way.
Hello Dear community.
I'd like to overload `opIndexAssign` for a struct which wraps
around a generic array (so that it can't support `opIndex` due to
unknown return type).
Broken down as much as possible this is the code:
```
import std.stdio : writeln;
import std.range : ElementType;
On Sunday, 10 October 2021 at 15:15:51 UTC, drug wrote:
It would be nice if one could use pattern-matching for it in
D. Is this possible?
As I know it's impossible, but you can use a regular template:
...
If anyone is interested in pattern matching, someone provides a
package "dpmatch"
On Sunday, 10 October 2021 at 15:15:51 UTC, drug wrote:
As I know it's impossible, but you can use a regular template:
```d
template isPointedStaticArray(T)
{
static if (isPointer!T)
enum isPointedStaticArray =
isStaticArray!(PointerTarget!T);
else
enum
On Sunday, 10 October 2021 at 15:01:17 UTC, Elmar wrote:
```d
enum isPointedStaticArray(T) = is(PointerTarget!T : P[N], P,
size_t N);
```
```d
enum isPointedStaticArray(X : P*, P) =
.isStaticArray!(PointerTarget!X);
```
`isStaticArray` is a good example that makes me ask how to
On Sunday, 10 October 2021 at 14:36:50 UTC, Elmar wrote:
On Sunday, 10 October 2021 at 14:08:13 UTC, drug wrote:
You just need to check if T is a pointer:
```D
import std;
alias DA = int[];
alias SA = int[3];
alias PSA = SA*;
alias PDA = DA*;
version(all)
enum isPointedStaticArray(T) =
On Sunday, 10 October 2021 at 14:08:13 UTC, drug wrote:
You just need to check if T is a pointer:
```D
import std;
alias DA = int[];
alias SA = int[3];
alias PSA = SA*;
alias PDA = DA*;
version(all)
enum isPointedStaticArray(T) = isPointer!T &&
isStaticArray!(PointerTarget!T);
else
enum
On Sunday, 10 October 2021 at 13:56:06 UTC, rempas wrote:
Actually I know about BetterC and how to call C functions from
D and visa versa. I would also disagree that "BetterC" is
almost no improvement over C as about 90% of the language is
there!! C++ classes are also supported
Nice :-) ,
On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
The language subset "BetterC" is required for calling D
functions from C though. Unfortunately, the runtime features of
BetterC are limited and some of C's language features aren't
availabe like C99 variable-length-arrays. "BetterC" is
On Sunday, 10 October 2021 at 13:10:27 UTC, rempas wrote:
Thanks, I'm converting a library from C to D so I have to fix
all the other bugs first to see If it's working but probably it
will. Have an amazing day my friend!
Hopefully it will :-) .
D has some good C support. You can call any C
PS: the title is a misnomer. `is(T : P*, P) && isStaticArray!P`
doesn't either compile when inlined because `P` is not defined
when not matched.
Hey D people.
Currently in my project I have worked on a unified type interface
for all arrays which requires fixed-size arrays to be stored as
pointer (in correspondence to dynamic and associative arrays) and
allow them being allocated with any selected allocator.
There can be code like
On Sunday, 10 October 2021 at 12:01:33 UTC, rempas wrote:
This is the first time I'm finding something like that. I'm
having the following code in C:
```
if (0 == (i >> 7)) {
if (len < 1) return -1;
v = i;
return *ret = v, 1;
}
```
This is part of a function that returns an
On Sunday, 10 October 2021 at 10:44:15 UTC, rempas wrote:
I'm having the following C code:
```
static void* (*ppmalloc)(size_t) = malloc;
static void (*ppfree)(void*) = free;
```
I want to covert this code in D so I try to do the following:
```
static void* function(size_t)*ppmalloc = malloc;
Hello D community.
I was browsing the `__traits` keywords and I found `isFuture`
whose descriptions says something about `@future`-annotated
variables.
[link](https://dlang.org/spec/traits.html#isFuture)
I didn't find anything about `@future` for the D programming
language. I only found
I also should discourage its current form with large
`tupleSize`s. The computation is in O(exp(values.length)).
Instead of `~=` I would suggest an `std.array.appender` of arrays
instead of an 2D-array for the `choices`, if the `choices` become
large. Most efficient is a preallocated array
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote:
Hi All,
Request your help on the below to print the below array as
"Required output", Was able to get these values
"[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your
help to get values
Hello there,
I got a weird compilation error which was hard to debug (even for
just a little program) and I thought, this is quite related to
this thread. This is my error message:
```
***search.d(42,1): Error: class ***.XXX has forward references
***box.d(21,32): Error: template instance
On Saturday, 29 May 2021 at 19:55:30 UTC, Elmar wrote:
In many or most of the cases the use case doesn't actually
require GC-allocation.
Btw, I'm talking about core-level and systems software which
concentrates on data transformations.
When I only want to access a data structure but not
On Wednesday, 26 May 2021 at 15:07:12 UTC, Jack wrote:
On Wednesday, 26 May 2021 at 13:58:56 UTC, Elmar wrote:
On Saturday, 8 December 2018 at 03:51:02 UTC, Adam D. Ruppe
wrote:
[...]
That's amazing, this should be one thing that should appear in
every tutorial just right at the start! I
On Saturday, 8 December 2018 at 03:51:02 UTC, Adam D. Ruppe wrote:
On Saturday, 8 December 2018 at 03:48:10 UTC, Murilo wrote:
Try passing `ps[]` to the function instead of plain `ps` and
see what happens.
How do I transform an array into a range?
With the slicing operator, [].
That's
23 matches
Mail list logo