In the case that a type is specified, it could be on the left (before) or the right (after) of the variable name.

For example, C, C# and Java have the type specified before the variable:

int num = 5;

TypeScript, Rust and Haxe (can) have the type specified after the variable:

let num: number = 5;
let num: u32 = 5;
var num: Int = 5;

Is there a term that denotes the way a language's syntax work with types? E.g. "The _____ language uses (left/back or right/front) typing type declaration".

  • 2
    Ask yourself whether this actually needs a term or whether it's sufficient to say "language L declares its types {before,after} its identifiers." – Blrfl Jan 13 at 11:50

There isn't a standard name for this as far as I'm aware. However, many features of programming languages are named after the language that introduced (or popularized) them, so one might refer to the former example as C-style declaration syntax (int x, y;) and the latter example as Pascal-style declaration syntax (VAR x, y : integer;).

n.b. It would be inappropriate to say that this is some sort of "typing" for the language. That term usually refers to static, dynamic, gradual, duck, etc. typing -- as in: the strength or classification of the language's type system, independent of the syntax.

  • 3
    Having the type on the left was already the case in ALGOL60, twelve years before C, and possibly also in ALGOL58. Having the type on the right was already the case in type theory before programming languages even existed. – Jörg W Mittag Jan 12 at 23:58
  • Well, sure, but does "type theoretic type specification syntax" communicate the idea more effectively than "[Pascal/other popular language]-style declaration syntax" to a broad audience of programmers and software engineers? We shouldn't expect everyone to be familiar with the simply-typed lambda calculus. – Alex Reinking Jan 13 at 0:13
  • Do you expect more programmers today would understand "My new language has C style declarations", or "ALGOL style declarations"? – Alex Reinking Jan 13 at 0:16
  • To say C-style declarations implies much more than merely the type preceding the variables name, though. Ritchie's idea was to declare identifiers in contexts resembling their use: "declaration reflects use". "C is sometimes castigated for the syntax of its declarations... The syntax is an attempt to make the declaration and the use agree; it works well for simple cases, but it can be confusing for the harder ones, because declarations cannot be read left to right, and because parentheses are over-used." C K&R 5.12 pg 122. – Erik Eidt Jan 13 at 0:45
  • If you have a clearer term, submit it as an answer. I'll even upvote it. – Alex Reinking Jan 13 at 0:46

I think you could say that C/C++/Java uses prefix type declarations whereas Rust/Typescript use postfix type declarations.

  • 1
    Actually in c c++, the type is not only on the left. Exemple: int * p [10]; for an array of 10 pointeurs to ints. – Michel Billaud Jan 13 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.