Compile-time reflection

Having built-in JSON support is nice, but V also allows you to create efficient serializers for any data format. V has compile-time if and for constructs:

  1. struct User {
  2. name string
  3. age int
  4. }
  5. fn main() {
  6. $for field in User.fields {
  7. $if field.typ is string {
  8. println('$field.name is of type string')
  9. }
  10. }
  11. }
  12. // Output:
  13. // name is of type string

See examples/compiletime/reflection.v for a more complete example.