Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use parse(T, str) over constructors #79

Closed
rofinn opened this issue Apr 11, 2020 · 0 comments · Fixed by #82
Closed

Use parse(T, str) over constructors #79

rofinn opened this issue Apr 11, 2020 · 0 comments · Fixed by #82
Milestone

Comments

@rofinn
Copy link
Owner

rofinn commented Apr 11, 2020

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).

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 a pull request may close this issue.

1 participant