cqcallaw / newt

The newt programming language
GNU General Public License v3.0
12 stars 2 forks source link

Inferred return types #26

Open cqcallaw opened 8 years ago

cqcallaw commented 8 years ago

For one-liner anonymous functions, inferring the return type is handy.

Care should be taken to engineer this so it's not encouraged for larger functions where the return type is important for verifying the semantic correctness of the function.

cqcallaw commented 8 years ago

Idea: permit the return type to be inferred if the function "body" is an expression instead of a statement block. That is, (a:int, b:int) -> a * b would be valid, but (a:int, b:int) -> { return a * b } would be invalid.