Thread overview | |||||
---|---|---|---|---|---|
|
December 23, 2010 Re: is this the expected output | ||||
---|---|---|---|---|
| ||||
Thanks for the answers what I did is this ( i feel that it is quite clumsy): Node* x = cast(Node*) (GC.malloc(Node.sizeof)); *x = xa; x.up = curnode; ... |
December 23, 2010 Re: is this the expected output | ||||
---|---|---|---|---|
| ||||
Posted in reply to g g | On Wed, 22 Dec 2010 19:40:16 -0500
g g <htpp@www.com> wrote:
> Thanks for the answers
> what I did is this ( i feel that it is quite clumsy):
>
> Node* x = cast(Node*) (GC.malloc(Node.sizeof));
> *x = xa;
> x.up = curnode;
> ...
This is not that clumsy (except for you naming!). You have to allocate distinct memory cells for distinct programming elements that represent distinct entities in your (mental) modell, haven't you? D provides adequate features that allow you thinking thinking at a higher-level. But if you want to play at a lower-level, you'll need to juggle with pointer detail issues ;-)
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
|
December 23, 2010 Re: is this the expected output | ||||
---|---|---|---|---|
| ||||
Posted in reply to g g | On 23.12.2010 3:40, g g wrote: > Thanks for the answers > what I did is this ( i feel that it is quite clumsy): > > Node* x = cast(Node*) (GC.malloc(Node.sizeof)); > *x = xa; > x.up = curnode; > ... which could be improved: Node* x = new Node(...);//paste your constructor args in place of ... if Node has a constructor, or just Node* x = new Node;// if no constructors -- Dmitry Olshansky |
Copyright © 1999-2021 by the D Language Foundation