Skip to content

make std/lists usable with ptr instead of ref#593

Draft
timotheecour wants to merge 2 commits intodevelfrom
pr_lists_nogc2
Draft

make std/lists usable with ptr instead of ref#593
timotheecour wants to merge 2 commits intodevelfrom
pr_lists_nogc2

Conversation

@timotheecour
Copy link
Owner

@timotheecour timotheecour commented Feb 17, 2021

just to illustrate that it's possible with a small diff, see tests

note

it'd be better if something like this worked, which depends on nim-lang/RFCs#85 (default generic params):

type
  SinglyLinkedList*[T; isPtr: static bool = false] = object
    when isPtr:
      head*: SinglyLinkedNode[T, true]
      tail*: SinglyLinkedNode[T, true]
    else:
      head*: <//>(SinglyLinkedNode[T])
      tail* {.cursor.}: SinglyLinkedNode[T]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant