Open charlesstaats opened 9 months ago
Correction: The word using
was already present in C++ (as in using namespace std;
); it was not introduced in C++11, only given an additional use. I think it's unlikely that existing users have variables, functions, or types called using
, but I'd be open to repurposing an existing keyword instead if there is one that would work.
Additional note: The way I've implemented using
is a bit hacky. In some sense, I think this is unavoidable: the tradeoff for a very elegant implementation was the weird syntax that typedef uses to define function types. I welcome suggestions on how to make the implementation more elegant and/or more thorough (e.g., supporting comma-separated aliases rather than only the single alias, or refactoring the typedef
definition rather than clunkily rewriting a using
statement into a typedef). But I also urge the reviewers not to make the perfect the enemy of the good.
Upon further consideration, I actually think the current approach may be the best "reasonable" option available. I have added comments to camp.y to explain how the syntax of using
is designed to imitate the type alias syntax in the C++ standard.
C++11 introduced the keyword
using
, which can be used for a more intuitive but equivalent version of typedef. For instance,are now equivalent. This PR introduces a similar feature into Asymptote. There's no new functionality, but many programmers find the
using
-style alias easier to read since it is much more similar to variable assignment.