Implement Object in C++!
Static and Dynamic The terms static typing and dynamic typing are probably familiar to everyone. The key to distinguishing between them lies in the timing of type checking. What does that mean? ...
Static and Dynamic The terms static typing and dynamic typing are probably familiar to everyone. The key to distinguishing between them lies in the timing of type checking. What does that mean? ...
First, what is metadata? Consider the following python code. We want to automatically modify the corresponding field value based on the input string. class Person: def __init__(self, age, name): self.age = age self.name = name person = Person(10, "xiaohong") setattr(person, "age", 12) setattr(person, "name", "xiaoming") print(f"name: {person.name}, age: {person.age}") # => name: xiaoming, age: 12 setattr is a built-in python function that perfectly meets our needs. It modifies the corresponding value based on the input field name. ...
Clang is a C-language family compiler frontend provided by the LLVM project. It was originally developed to replace the C language frontend of the GNU Compiler Collection (GCC), with the goal of providing faster compilation speeds, better diagnostic information, and a more flexible architecture. Clang includes C, C++, and Objective-C compiler frontends, which are designed to be embedded in other projects. A key feature of Clang is its modular architecture, which makes it easier for developers to extend and customize compiler functionality. Clang is widely used in many projects, including LLVM itself, the development of some operating system kernels, and the implementation of compilers for some programming languages. ...
Introduction Let’s take a recent requirement as an introduction. We all know that Markdown can use lang to fill in code blocks and supports code highlighting. However, I wanted to support my own custom code highlighting rules and encountered the following problems: ...
What is Reflection? The term Reflection is probably not new to anyone; perhaps you haven’t used it, but you’ve certainly heard of it. However, like many other idiomatic terms in the CS field, there isn’t a clear and precise definition for reflection. This leads to a situation where, for languages like C#, Java, and Python that have reflection, discussing it naturally brings to mind related facilities, APIs, and code examples in those languages, making it very concrete. But for languages like C, C++, and Rust, which don’t have reflection, when reflection is discussed, people are often unsure what the other person is referring to, making it very abstract. For example, someone might tell me that Rust has reflection, and the example they provide is the introduction to std::Any module in Rust’s official documentation. It mentions: ...
Recently, I’ve been planning to write a series of articles discussing the concept of reflection in detail. Coincidentally, C++26 has a new reflection proposal, and I noticed there aren’t many related articles on Zhihu, despite this topic being frequently discussed. So, I’m taking this opportunity to talk about static reflection in C++, as a warm-up for the series. ...