On Monday, 25 April 2022 at 02:19:46 UTC, Ali Çehreli wrote:
This type violates a fundamental rule: Containers and ranges
are separate concepts. Your List is a container, not a range. I
changed your code by moving the range functions to a Range [...]
Dear Ali,
I implemented a linkedlist
On 4/24/22 17:18, Vinod K Chandran wrote:
> private this(int a, string b, bool c) {
Looks good to me.
There are other ways as well:
class Foo {
private:
// ...
public:
// ...
}
Or:
class Foo {
private {
// ...
}
// ...
}
Ali
On 4/24/22 18:40, Alain De Vod wrote:
> I think this has something to do with popFront
This type violates a fundamental rule: Containers and ranges are
separate concepts. Your List is a container, not a range. I changed your
code by moving the range functions to a Range struct that is created
On 4/24/22 17:26, Salih Dincer wrote:
> first destroy() then free()...
Makes sense only if we allocated the memory.
> import object: doDestroy = destroy;
I like adding 'do' to verbs that can be confused with nouns. For
example, because 'copy' is both a noun and a verb, I think it helps when
On 4/24/22 14:00, Alain De Vod wrote:
> Is this a correct program to explicit call destroy & free ?
destroy() is called with the object that you want its destructor to be
executed on. This is very rare in D because when the destructor has to
be called, one relies on the lifetime of a struct
Following program is a single linked list.
We expect as output 1 2 3 1 2 3
But the output is only 1 2 3
I think this has something to do with popFront
How to fix it using "class List" ?
```
import std.stdio: write,writeln;
import std.range: empty,popFront,front;
struct Node {
int
On Sunday, 24 April 2022 at 21:00:50 UTC, Alain De Vod wrote:
Is this a correct program to explicit call destroy & free ?
```
void main(){
int[] i=new int[1];
import object: destroy;
destroy(i);
import core.memory: GC;
GC.free(GC.addrOf(cast(void *)(i.ptr)));
}
```
Hi all,
Please take a look at this code. Is this the right way to use
private constructors ?
```d
class Foo {
int p1 ;
string p2 ;
bool p3 ;
private this(int a, string b, bool c) {
this.p1 = a
this.p2 = b
this.p3 = c
}
this(int a) {
Is this a correct program to explicit call destroy & free ?
```
void main(){
int[] i=new int[1];
import object: destroy;
destroy(i);
import core.memory: GC;
GC.free(GC.addrOf(cast(void *)(i.ptr)));
}
```
On Sunday, 24 April 2022 at 15:13:15 UTC, Alain De Vos wrote:
I'm currenlty experimenting about binding to C.
I have :
C-library:
mylib.h:
```
void libprintme(char *s);
```
mylib.c:
```
#include
#include "mylib.h"
void libprintme(char *s){printf("%s",s);}
```
[...]
Can this procedure be
```
void main(){dprintme("Hello\n");}
}
```
I'm currenlty experimenting about binding to C.
I have :
C-library:
mylib.h:
```
void libprintme(char *s);
```
mylib.c:
```
#include
#include "mylib.h"
void libprintme(char *s){printf("%s",s);}
```
main.d:
```
extern(C) @nogc nothrow {
void libprintme(char *s);
alias pprintme=void
On Sunday, 24 April 2022 at 12:21:29 UTC, elfstone wrote:
On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi
wrote:
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
[...]
You need to use the flag `-preview=dip1021`
test.d(8,30): Error: variable `test.test.p` assigning
On Sunday, 24 April 2022 at 11:36:29 UTC, Paolo Invernizzi wrote:
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
[...]
You need to use the flag `-preview=dip1021`
test.d(8,30): Error: variable `test.test.p` assigning to
Owner without disposing of owned value
Weird, it's
On Sunday, 24 April 2022 at 11:07:43 UTC, Tejas wrote:
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p =
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
On Sunday, 24 April 2022 at 09:31:40 UTC, elfstone wrote:
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
Dub(DMD 2.099.1) builds and runs the following code without a
warning.
import std.stdio;
import core.stdc.stdlib;
@live
void test()
{
int* p = cast(int*) malloc(32);
p = cast(int*) malloc(32);
free(p);
}
void main()
{
test();
18 matches
Mail list logo