Skip to content

zend_compile: Bundle function type constants into an zend_function_type enum#21208

Open
TimWolla wants to merge 2 commits intophp:masterfrom
TimWolla:zend-function-type
Open

zend_compile: Bundle function type constants into an zend_function_type enum#21208
TimWolla wants to merge 2 commits intophp:masterfrom
TimWolla:zend-function-type

Conversation

@TimWolla
Copy link
Member

This clarifies the relationship between these constants and improves type safety a little.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Seems reasonable, thanks!

…ype` enum

This clarifies the relationship between these constants and improves type
safety a little.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Looking forward to being able to use C23_ENUM more often! :)

/* Define a fixed-size enum as enum C23_ENUM(name, size) { }. */
#if __STDC_VERSION__ >= 202311L || defined(__cplusplus)
# define C23_ENUM(name, size) \
name: size; \
Copy link
Member

Choose a reason for hiding this comment

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

I don't comprehend this. Shouldn't this line be this:

Suggested change
name: size; \
enum name: size; \

Copy link
Member

Choose a reason for hiding this comment

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

Ah no, I get it now. You put enum at the use-site of C23_ENUM... I think it would be more logical to embed enum in this macro

Copy link
Member Author

Choose a reason for hiding this comment

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

The intended usage is enum C23_ENUM(name, size), thus the leading enum keyword is provided “outside of the macro”. I wanted to keep it outside of the macro to make it easier to visually scan the file.

Copy link
Member

Choose a reason for hiding this comment

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

I think putting it outside adds redundancy and confusion.

Copy link
Member

Choose a reason for hiding this comment

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

I would have also preferred to have it in the macro, but don't care enough either way.

enum name: size
#else
# define C23_ENUM(name, size) \
name; \
Copy link
Member

Choose a reason for hiding this comment

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

Likewise, is enum prefix missing here or what am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants