microsoft / GSL

Guidelines Support Library
Other
6.23k stars 739 forks source link

`Expects` and `Ensures` should be `GSL_EXPECTS` and `GSL_ENSURES` #1032

Open sean-parent opened 2 years ago

sean-parent commented 2 years ago

GSL should obey the core guidelines. Expects and Ensures should be GSL_EXPECTS and GSL_ENSURES. As the person who has suffered for 30 years for defining widely used macros check and require I can attest to just how bad an idea those names are. (https://opensource.apple.com/source/xnu/xnu-7195.141.2/EXTERNAL_HEADERS/AssertMacros.h.auto.html)

dmitrykobets-msft commented 2 years ago

Hi @sean-parent,

I looked over the related discussions:

From what I've gathered, it seems like there was hope that contracts would be introduced soon enough, and that for the time being these checks were implemented as macros because of some technical caveats. And because the macros were considered an "implementation detail", their names were chosen purposefully to conform to I.6 and I.8.

However, these discussions are quite old and things have changed since then, so I'll re-surface this topic in the next GSL maintainers' sync.

Thanks, Dmitry

robert-andrzejuk commented 2 years ago

@dmitrykobets-msft Did you have "contracts" in mind instead of "concepts" in the sentence: "...like there was hope that concepts would be introduced soon enough..."?

dmitrykobets-msft commented 2 years ago

@robert-andrzejuk oops, yes I did thanks for the catch -- updated

dmitrykobets-msft commented 2 years ago

Hi @sean-parent, It looks like because the macro behavior is documented explicitly in https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#gslassert-assertions, the discussion will have to start with the Core Guidelines. But there's currently other work being done with regards to Expects/Ensures https://github.com/microsoft/GSL/pull/962 that will also need to touch base with the guidelines, so we'll try and include this discussion as part of that related work. Thanks, Dmitry