079_quoted_identifiers.zig 874 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // Sometimes you need to create an identifier that will not, for
  3. // whatever reason, play by the naming rules:
  4. //
  5. // const 55_cows: i32 = 55; // ILLEGAL: starts with a number
  6. // const isn't true: bool = false; // ILLEGAL: what even?!
  7. //
  8. // If you try to create either of these under normal
  9. // circumstances, a special Program Identifier Syntax Security
  10. // Team (PISST) will come to your house and take you away.
  11. //
  12. // Thankfully, Zig has a way to sneak these wacky identifiers
  13. // past the authorities: the @"" identifier quoting syntax.
  14. //
  15. // @"foo"
  16. //
  17. // Please help us safely smuggle these fugitive identifiers into
  18. // our program:
  19. //
  20. const print = @import("std").debug.print;
  21. pub fn main() void {
  22. const 55_cows: i32 = 55;
  23. const isn't true: bool = false;
  24. print("Sweet freedom: {}, {}.\n", .{
  25. 55_cows,
  26. isn't true,
  27. });
  28. }