Skip to content

type alias, design flaw or design pattern? #18556

Discussion options

You must be logged in to vote

No, it's not a flaw. If you were allowed to define new methods on built-in types, it could lead to confusion in the code base, bug reports because someone saw your method without seeing your definition, and wondering why it didn't work in their code, etc., etc.

Creating an alias is essentially creating a new type, and new types can have whatever methods you wish to define on them, as well as the ones they inherit from their parent types.

This is less confusing in V due to the naming conventions. If someone sees a method on a name with a capital letter, they know it's something defined in your code (or something you imported), rather than a built-in type.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by felixf4xu
Comment options

You must be logged in to vote
1 reply
@JalonSolov
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants