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

not_null constructor is now explicit #659

Merged
merged 1 commit into from
Apr 25, 2018

Conversation

ericLemanissier
Copy link
Contributor

solves #395

@beinhaerter
Copy link
Contributor

Just curious: what's the reason to change the initialization in the tests and why have different initialization ("{}" vs. "()") in the same test?

@ericLemanissier
Copy link
Contributor Author

it was just a way to check they all work. I can harmonize them if it is a blocking point

@beinhaerter
Copy link
Contributor

OK, thanks, that was my guess.

@xaxxon
Copy link
Contributor

xaxxon commented Apr 15, 2018

I question the usefulness and desirability of this change as stated in the associated issue - especially as a breaking change.

@xaxxon
Copy link
Contributor

xaxxon commented Apr 15, 2018

an alternative would be to make a new type explicit_not_null or something if this behavior is desired.

@Amaroker
Copy link

I question the usefulness and desirability of this change as stated in the associated issue - especially as a breaking change.

Changing a parameter to not_null can be a breaking change, regardless if the constructor is explicit or not.

However, the explicit constructor is very useful because we don't want such changes to silently (until run-time) break something.

The sooner we have the explicit constructor, the better.

The core guidelines say:

  • Prefer compile-time checking to run-time checking.

  • Single-argument constructors should be declared explicit.

  • Do not introduce implicit conversions (through conversion operators or non-explicit constructors) just to gain a minor convenience.

@xaxxon
Copy link
Contributor

xaxxon commented Apr 17, 2018 via email

@ericLemanissier
Copy link
Contributor Author

@neilmacintosh What do you think about this pull request ?

@neilmacintosh
Copy link
Collaborator

@ericLemanissier I personally like this change, for the reasons observed on the issue threads: not_null will frequently be used to make a function have a strong contract about null values, and it seems sensible to ask callers to explicitly acknowledge that contract.

I'll leave final approval to @annagrin though.

@annagrin
Copy link

@neilmacintosh Agreed. We do want to follow the Guidelines in GSL:)

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.

6 participants