walt icon indicating copy to clipboard operation
walt copied to clipboard

Type inference

Open piranna opened this issue 5 years ago • 1 comments

Feature Request

Overview

Add support for type inference, so walt itself can discover the type of a variable from the values it's being assigned. For safety and simplicity this can be done in a strict way, don't allowing to change the type of a variable. This is something similar to how Rust types works. In a next iteration it would be changed to create new hidden variables transparently to the user if the type is different.

Impact

Medium. The most difficult part would be the type inference, but following the AST would not be too much difficult.

Details

This would allow to write more Javascript-like code, in most cases types would only be needed to be set in the function signature.

piranna avatar Sep 03 '18 17:09 piranna

This has already been done in AssemblyScript, which compiles a variant of TypeScript to WebAssembly. Walt's syntax is very similar (if not identical) to AssemblyScript, so type inference is probably feasible.

jarble avatar Nov 03 '19 16:11 jarble