red / REP

Red Enhancement Process
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Node! datatype #57

Open hiiamboris opened 4 years ago

hiiamboris commented 4 years ago

Read here: https://github.com/red/red/wiki/[PROP]-Node!-datatype

Oldes commented 4 years ago

It would be good to see an example, how it should be used. Btw.. list! datatype was removed from Rebol3, because the internal structures were fragmenting memory. Wouldn't it be same with node!?

hiiamboris commented 4 years ago

One of the common usages would be simple tree traversal with foreach (towards the leaves) or foreach/reverse (towards the root). Here are some real code examples that become trivial one-liners: https://github.com/greggirwin/red-hof/blob/master/code-analysis/while/trees.md

because the internal structures were fragmenting memory

I wonder how is this different from just creating and collecting blocks. In any case if fragmentation is expected to be an issue, an implementation should chosen to prevent it.

greggirwin commented 4 years ago

IIRC, a bigger issue with list! was that the interface/behavior differed from blocks in ways that made it harder to use correctly.

JEROME-TICTEC commented 1 year ago

It's kind, could we imagine an auto ID for each node, edge (and new one in case of duplicate) Just to be able to associate any others "parameters" (tuples) onto each node edge by ref with this ID.

hiiamboris commented 1 week ago

@JEROME-TICTEC A node is itself a unique ID (same as objects and series), because it has a unique memory address, so no need. At least if we consider that I don't see how a node could fit into a single cell, this means that it has data on the heap, and that data address is going to be unique.

hiiamboris commented 1 week ago

Update: added implementation models descriptions