Alternative declaration syntax

This is about tokens order. I guess the reason why modern programming languages tend to use fn/func/proc for subroutines and let/var whatever for variables is quite “simple” - these “prefixing” keywords just make life more easy for compilers. If you see an int (I mean C), you do not know what will follow. If you see var, you definitely know what should follow next.

Tokens order, tokens order… a variable data entity/data unit declaration include (generally) these components:

  • keyword (var or let or…)
  • name
  • type
  • properties/attributes
    • mutability
    • volatileness
    • kind of memory (CPU registers, progmem)
    • something else?..
  • initializer
  • separators (like : in Pascal, Zig and many other)

It seems very logical to have a keyword to be first elevent and an initializer to be the last one.
Position of others may vary…

What is “better”,

data mut,reg ptr: * imm,progmem u8;
// mutable pointer in CPU register(s),
// pointing to immutable u8 in progmem

or

data ptr mut,reg : *u8 imm,progmem;

? I do not know :slight_smile:

1 Like