Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

2019-04-14

Nested functions

Some languages allow nested functions (or procedures, or subroutines, or whatever you prefer to call them), others don't.

I think those can be useful and I wonder why they aren't embraced by all living programming languages.

2017-11-03

Check at compile time if a going-to-be-stringified symbol is a member of a struct

I wanted a string which must “contain” the name of a member of a struct. The compiler should check the right spelling (at compile time).

At last I have found a possible reason to use the comma operator…

2015-06-20

Type-generic functions (overloading) in C11

As per Michael Stoffregen suggestion in the comment, I've tried to move arguments outside and it worked (even with gcc 4.9.2)! So I can finally say C(11) has Fortran-like function “overloading” — type generic functions.

I have often wondered why C hasn't any kind of function overloading. The typical answer is that we don't want to live with name mangling in C — the hell of the C++ — that would break a lot of things which must stay as they are. I agree… except that you don't need to implement it the C++ way when you have a bright example like Fortran.