5 ms·
You can just hover over the keyword with an IDE and instantly see that it's just a typedef for static. There's nothing wrong with doing something like this, esp
by _gabe_ 4y ago
You can just hover over the keyword with an IDE and instantly see that it's just a typedef for static. There's nothing wrong with doing something like this, especially since it wasn't meant to be OSS and more of a personal project until now. In addition, i32 is not an ambiguous typedef. It's way clearer that this is a 32 bit integer than `int` is.
Finally, big libraries do this as well. Freetype is notorious for typedefing weird stuff like FTPos and all that. It's just one way to model the domain language in the code, and that's fine by me. If the big open source libraries can do it, what's wrong with a small one doing it too?
- maccard 4y ago> You can just hover over the keyword with an IDE and instantly see that it's just a typedef for static Assuming you're browsing in an IDE, and that the IDE understands your build system. Github for example doesn't detect that it's a typedef for static. There's also the fact that the keyword `internal` is overloaded, and not in a standard way. For example, does it mean that it's not exported (a la dllexport in msvc). > In addition, i32 is not an ambiguous typedef. It's way clearer that this is a 32 bit integer than `int` is. but that's not what the typedef is to, the typedef is to int32_t which is a standard type that is guaranteed to be 32 bits. > If the big open source libraries can do it, what's wrong with a small one doing it too? typedef'ing FT_POS is totally different - FT_POS is not redefining a basic type to be used all over the project, it's defining the types used to refer to coordinates. Freetype is also written in C, and is almost 30. You also better hope that when you're using these typedefs that any third party libraries (e.g. free type) also use the same aliases.
- sevnin 4y agoInternal define for static is actually really good, maybe different keyword like 'fn' would be better cause it doesn't clash with windows.h but, redefining static to a different keyword allows you to search for it in a codebase while static can be a local variable, global variable, function.
- maccard 4y agoI fundamentally disagree. The reason programming languages work are because things are consistent, if everyone defined their own flavor of keywords then you're not using the same language anymore. On any project I've worked on I would fail a code review for attempting to introduce something like this.
- sevnin 4y agoHe is consistent, all functions have that keyword, it's his codebase. He has also has the api(custom) define so his metaprogram knows which functions to publish into the plugin system. C++ syntax is not very regular so if you want to consistently catch all functions with a homemade parser or grep or whatever it would need to be complex, it needs to do backtracking, account for stuff like operator+ etc. If you do what he is doing it's trivial to make a metaprogram for C++ that would consistently catch all functions. It's great that you would fail a code review in your company for that but it's not relevent.
- maccard 4y agoThe API custom define is perfectly fine. (Well it sucks but that's not his fault, that's a c++ language deficiency). But making custom defines for fundamental types and for language keywords because you'd rather type internal than static is just messy.
- sevnin 4y agoWell, I guess at this point the only thing I can say is: I disagree.