Pascal notation vs Manifest typying

Kotlin documentation reffers in few places to Pascal notation e.g. here
http://kotlinlang.org/docs/reference/functions.html

Function parameters are defined using Pascal notation, i.e. name: type. Parameters are separated using commas. Each parameter must be explicitly typed.

For mee Pascal notation is incorrect term (or at least it’s not used any more). It seems that we should use Manifest typying term instead

Let me know what you think

Well, it seems to me that all that is meant by ‘Pascal notation’ in that context is that, in a parameter declaration, the parameter precedes its type as it does in Pascal-family languages. In contrast, in the older C-family languages (C, C++, Java, C#, D etc), the type precedes the parameter.

Although it’s never wrong to explicitly specify a variable’s type in Kotlin, I suspect that most of us prefer to omit the type when the language allows us to do so (e.g. in local variable or property declarations) and it can be easily inferred from the initialization expression (if any) on the R.H.S of the equals sign.

So I don’t think it would be strictly correct to say that Kotlin is a ‘manifest typed’ language given that the use of type inference is so common.

From a language syntax perspective the use of post variable types has the advantage of being able to make omission of type information much easier to omit. For example in Kotlin lambda’s this is apparent. Even though functions don’t allow the omission (at this point) it would not introduce syntactical problems to do so.

So it’s all about of order - it’s quite interesting exmpanation and makes sense.
What wonders me s the fact that googling Pascal notation phrase return no results. Is it something from very old languages or someone just invented this phrase?

If you have a look at this link about procedures in Pascal, you will notice that the arguments are followed by a colon and then by their type as they are in Kotlin.

The authors of the Kotlin documentation have probably just invented the term ‘Pascal notation’ to indicate that Kotlin follows Pascal in this respect rather than Java.

Incidentally, Kotlin isn’t the only modern ‘curly brace’ language to do this. Go, Swift and Rust all do the same probably because it makes it easier to omit the type as @pdvrieze suggested.

I suppose Kotlin could do the same for function parameters where they have a default value but, for some reason, they chose not to do this and to always specify the type.

1 Like

Take a look at C#, where you can omit the type information of local variables and lambda parameters not harder than in Kotlin. And in C# the type precedes the parameter.