Book Image

D Cookbook

By : Adam Ruppe
Book Image

D Cookbook

By: Adam Ruppe

Overview of this book

Table of Contents (21 chapters)
D Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 8. Reflection

D supports limited runtime reflection out of the box as well as rich compile-time reflection that can be used in code generation efforts, custom semantic checks, building additional runtime reflection information, and more. In this chapter, we'll be covering the following recipes:

  • Getting dynamic runtime type information

  • Getting a list of child classes

  • Determining whether a module is available

  • Getting a list of all methods or fields in a module or an object

  • Inspecting function overloads

  • Determining names, types, and default values of function parameters

  • Getting components of complex types

  • Using user-defined attributes

  • Implementing a custom lint-style check for virtual functions

  • Extending the runtime type information

  • Creating a command-line function caller