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

Implicit Conversions to System.Drawing structs #801

Merged

Conversation

ds5678
Copy link

@ds5678 ds5678 commented Aug 25, 2023

This pull request adds implicit conversions from the following types:

  • Point
  • Rectangle
  • Size

@FlorianRappl
Copy link
Collaborator

Why implicit? Explicit I would like a bit more, but maybe there is a good use-case for implicit.

@ds5678
Copy link
Author

ds5678 commented Feb 15, 2024

It should be implicit because it's allocation free, computationally efficient, and conceptually the same. Making it explicit would just increase code verbosity.

@FlorianRappl
Copy link
Collaborator

allocation free, computationally efficient

Implicit and explicit are actually the same. It's just that one thing is done implicitly by the compiler and the other one must be done explicitly. There is no difference regarding required allocations or computational efficiency. So no - those are not good reasons.

Where I'm with you is that implicit is / should be used for casting to a type that is conceptually the same / does not lose information. So this indeed would be in favor of an implicit cast.

All in all I'm on the fence here - I'd like to hear more opinions on this before we settle for one way or the other.

@ds5678
Copy link
Author

ds5678 commented Feb 15, 2024

allocation free, computationally efficient

Implicit and explicit are actually the same. It's just that one thing is done implicitly by the compiler and the other one must be done explicitly. There is no difference regarding required allocations or computational efficiency. So no - those are not good reasons.

No, I meant that my implementations for the cast methods were allocation free and computationally efficient. Explicit casts are recommended when the conversions are more costly, as a warning to developers.

@FlorianRappl
Copy link
Collaborator

No, I meant that my implementations for the cast methods were allocation free and computationally efficient. Explicit casts are recommended when the conversions are more costly, as a warning to developers.

Yeah - sure. In general the recommendation is that explicit casts are either computationally expensive or present a loss of information, while implicit casts are fast and will preserve information. So yes - it definitely fits in there from that POV; still I'd like to hear some opinions about it as I'm on the fence.

Copy link
Collaborator

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not heard any (negative) feedback on this one. We should merge it.

@FlorianRappl FlorianRappl merged commit 5125ee0 into ElectronNET:develop Apr 29, 2024
1 check failed
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.

None yet

2 participants