Skip to content

More usability woes #7

@p0nce

Description

@p0nce

I tried to modify njson to use more numem:

  • .length for vector (also: slength for signed length?)
  • .ptr for string
  • for shared_ptr and unique_ptr, .ptr gets repeated a lot, at any point of use. Not sure how alias this can settle that.
  • ref inout(T) for vector index and slices, currently only mutable supported. Tricky with atomics.
  • ref inout(T) for string index and slices

Note during yxml development:

  • unique_ptr!A not naturally covariant with a B class that would descend from A. This is quite complicated, when involving vector!unique_ptr after... ouch
  • nogc_delete crashes if the class instance access its surrounding frame (not a static class). So this shall be documented, I don't see a way out. (EDIT: this is related to std.conv.emplace segfaults for nested types dlang/phobos#10125)
  • unique_ptr can't be copied:
    unique_ptr!A a = unique_new!A();
    vector!(unique_ptr!A) v;
    v ~= a; // fail
    v ~= unique_new!A(); // but this works
    perhaps an explicit ".appendMove" operation?
  • vector!(unique_new!Class) owns every element. But vector!(Struct*) and vector!Class also own every element. It just bypass the whole move constraint and is more usable for now than vector!(unique_ptr!Class)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions