dmd icon indicating copy to clipboard operation
dmd copied to clipboard

ImportC: add __check(assign-expression) extension

Open WalterBright opened this issue 2 years ago • 10 comments

Trying to use assert in ImportC without the preprocessor gets tiresome, so I added __assert as an extension.

WalterBright avatar Apr 26 '22 06:04 WalterBright

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14026"

dlang-bot avatar Apr 26 '22 06:04 dlang-bot

the name __assert is already used for the assert failure function on some platforms (see druntime core.stdc.assert for a list)

if it's made a keyword, the assert header and uses of the macro will fail to parse

$ cpp /usr/include/assert.h > assert.i
$ dmd -verrors=context assert.i
/usr/include/assert.h(81): Error: identifier or `(` expected
extern void __assert (const char *__assertion, const char *__file, int __line)
            ^

huglovefan avatar Apr 27 '22 06:04 huglovefan

Curses! Any ideas for a replacement keyword for __assert ?

WalterBright avatar Apr 28 '22 01:04 WalterBright

How about _Assert?

PetarKirov avatar Apr 28 '22 08:04 PetarKirov

Changed __assert to __check

WalterBright avatar May 12 '22 22:05 WalterBright

Changed __assert to __check

I already dumped my thoughts on using known keywords for reserved identifiers in C when __import got merged. __ is reserved and we better have a tiny prefix to avoid such conflicts, but well we got to deal with it someday.

ljmf00 avatar May 14 '22 13:05 ljmf00

ping @WalterBright

RazvanN7 avatar May 19 '22 08:05 RazvanN7

I want to make a new suggestion to you; if the English meaning is not contradictory!

"ascertain" that can't introduce new conflicts never?

  assert(true);
  ascertain(true);

Sounds good, huh? Okay, it's 3 letters more but it is better than underscore typed by double key press.:)

SDB@79

salihdb avatar Jul 09 '22 10:07 salihdb

@WalterBright what is the status of this PR?

RazvanN7 avatar Jul 20 '22 09:07 RazvanN7

@WalterBright is this good to go?

RazvanN7 avatar Sep 01 '22 13:09 RazvanN7

Ready to merge

WalterBright avatar Feb 07 '23 07:02 WalterBright

@WalterBright @RazvanN7 How do we know this works? The test is never ran by the testsuite!

ibuclaw avatar Feb 16 '23 18:02 ibuclaw