Skip to content

Use parse(T, str) over constructors #79

@rofinn

Description

@rofinn

Currently, parse(T, str) basically defaults to T(str) which doesn't seem ideal. Especially with #72, we may want to use parse more extensively and reserve constructors for explicit type construction.

Base on the julia docs this seems like what we want:

  • Constructors are explicit, but may manipulate values as necessary.
  • convert should be lossless (e.g., convert(String, convert(::PathType, str))) == str)
  • parse/tryparse can be lossy, but are explicitly for parsing string representations of paths)

In theory, if you don't expect anyone to explicitly construct your type and folks are just relying on internal default behaviour of join, Path, p"" then a new type could probably just use the default constructor and only implement parse(T, str).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions