Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is used
very often in the source code for Phobos.
Thanks,
dhs
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer to
elements, length, capacity).
I tried two implementations: D's dynamic array and
std.container.array.
When D creates a dynamic array, it returns a slice. Functi
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is used
very often in the source code for Phobos.
Thanks,
dhs
Quote https:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
[...]
https://dlang.org/spec/simd.html
https://dlang.org/phobos/core_simd.ht
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is used
very often in the source code for Phobos.
Thanks,
dhs
It is either
The package dependency `emsi_containers` that can be found in
https://code.dlang.org/packages/emsi_containers might be a
viable way to resolve the problem.
```
/+dub.sdl:
dependency "emsi_containers" version="~>0.7"
+/
import std;
void main(string[] args) @nogc
{
import containers;
D
On Sunday, 1 October 2023 at 09:21:37 UTC, Imperatorn wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
[...]
https://
On Sunday, 1 October 2023 at 09:20:32 UTC, Anonymouse wrote:
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is
used very oft
On Sunday, 1 October 2023 at 09:24:39 UTC, evilrat wrote:
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote:
Hi,
What's the meaning of the dot in the call to writeln() below?
```d
.writeln("Hello there!");
```
I haven't found this in the spec or anywhere else. This is
used very often
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
I tried two implementations: D's dynamic array and
std.container.array.
Whe
On Sunday, 1 October 2023 at 11:39:11 UTC, bachmeier wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
I tried two imple
On Sunday, 1 October 2023 at 09:41:39 UTC, BoQsc wrote:
The package dependency `emsi_containers` that can be found in
https://code.dlang.org/packages/emsi_containers might be a
viable way to resolve the problem.
```
/+dub.sdl:
dependency "emsi_containers" version="~>0.7"
+/
import std;
void
On Sunday, 1 October 2023 at 11:43:17 UTC, bachmeier wrote:
On Sunday, 1 October 2023 at 11:39:11 UTC, bachmeier wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
[...]
Std::vector uses value semantics. D does not have anything like
that.
On Sunday, 1 October 2023 at 13:05:12 UTC, Steven Schveighoffer
wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tuple: (pointer
to elements, length, capacity).
[...]
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
When D creates a dynamic array, it returns a slice. Functions
that add or remove elements begin by asking the memory manager
for the dynamic array that the slice belongs to. Only then can
they go on and add elements.
Why is this a problem?
On Sunday, 1 October 2023 at 13:24:27 UTC, dhs wrote:
On Sunday, 1 October 2023 at 13:05:12 UTC, Steven Schveighoffer
wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
Hi,
Is there a straight forward Array type in D similar to C++'s
vector class? Something along the lines of the tu
On Sunday, 1 October 2023 at 13:51:35 UTC, Imperatorn wrote:
D can be very readable and maintainable, but since all the
advanced features exist, we are tempted to use them, which can
cause otherwise normal code to become a bit obfuscated.
OK in any case the forum seems to be very helpful. Th
On Sunday, 1 October 2023 at 13:24:27 UTC, dhs wrote:
On Sunday, 1 October 2023 at 13:05:12 UTC, Steven Schveighoffer
wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
[...]
Std::vector uses value semantics. D does not have anything
like that. It could be done someone just has to
On Sunday, 1 October 2023 at 13:27:37 UTC, Adam D Ruppe wrote:
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
When D creates a dynamic array, it returns a slice. Functions
that add or remove elements begin by asking the memory manager
for the dynamic array that the slice belongs to. Only
On 10/1/23 10:34 AM, Steven Schveighoffer wrote:
The complexity is from the way d does operator overloading and indexing.
It should be pretty straightforward. I’ll see if I can post a simple
wrapper.
I didn't tackle any attribute or memory safety issues, or many operator
overloads, but thi
Hi,
What is the difference between T[] opIndex() and T[] opSlice(),
which haven't parameters?
```d
struct S(T)
{
T[] arr;
T[] opIndex() => arr[];/*
T[] opSlice() => arr;//*/
}
alias Type = int;
void main()
{
auto s = S!Type([1,2,3]);
auto arr = s[]; // calls s.opIndex
On Sunday, 1 October 2023 at 17:41:08 UTC, Salih Dincer wrote:
Also, is it correct to use [] when returning?
Thanks...
[Here](https://dlang.org/spec/operatoroverloading.html#slice),
the opIndex() is proposed and an example of parameterized the
opSlice() is given for multidimensional arrays
On Sunday, 1 October 2023 at 17:21:32 UTC, Steven Schveighoffer
wrote:
On 10/1/23 10:34 AM, Steven Schveighoffer wrote:
This should give you a reasonable head-start.
-Steve
It does. Many thanks!
On Sunday, October 1, 2023 11:13:43 AM MDT dhs via Digitalmars-d-learn wrote:
> On Sunday, 1 October 2023 at 13:27:37 UTC, Adam D Ruppe wrote:
> > On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
> >> When D creates a dynamic array, it returns a slice. Functions
> >> that add or remove element
On Sunday, October 1, 2023 11:51:17 AM MDT Salih Dincer via Digitalmars-d-
learn wrote:
> On Sunday, 1 October 2023 at 17:41:08 UTC, Salih Dincer wrote:
> > Also, is it correct to use [] when returning?
> >
> > Thanks...
>
> [Here](https://dlang.org/spec/operatoroverloading.html#slice),
> the opInd
```d
import std;
auto data=“I went for a walk, and fell down a hole.”;
void main(string[] args) {
int[string] dic;
struct WordCnt {
string word;
ulong count;
string toString() const {
return text("Word: ", word, " - number of instances:
", count);
On 10/1/23 1:13 PM, dhs wrote:
It may not be a problem in practice. My concern was performance, because
each time we add an element to the array, the garbage collector has to
map the slice to the allocation it belongs to.
FWIW, there is a cache that makes this decently fast, so it doesn't hav
On 10/1/23 1:41 PM, Salih Dincer wrote:
Hi,
What is the difference between T[] opIndex() and T[] opSlice(), which
haven't parameters?
None. It used to be that opSlice was the only way, and the mechanisms
opSlice uses are still valid.
-Steve
On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote:
```d
import std;
auto data=“I went for a walk, and fell down a hole.”;
void main(string[] args) {
int[string] dic;
struct WordCnt {
string word;
ulong count;
string toString() const {
return text(
On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote:
```d
import std;
auto data=“I went for a walk, and fell down a hole.”;
You can improve it further by inlining
```d
import std;
auto data = "I went for a walk, and fell down a hole.";
void main(string[] args)
{
int[string] dic;
On Monday, 2 October 2023 at 02:01:34 UTC, Jonathan M Davis wrote:
For most code, you'd just write an opIndex with a single
parameter for indexing an element, opSlice with two parameters
for slicing the range or container, and then either opIndex or
opSlice with no parameters to return a slic
32 matches
Mail list logo