KittyCAD / modeling-app

The KittyCAD modeling app.
https://kittycad.io/modeling-app/download
MIT License
367 stars 30 forks source link

KCL type signatures #1079

Open adamchalmers opened 10 months ago

adamchalmers commented 10 months ago

In #993 we are going to add a "compiler" to KCL, which takes the AST and outputs an execution plan (a series of API calls, assignments, and arithmetic ops).

This is the perfect time to introduce a typechecker to KCL. During the compilation, we should check if the execution plan contains any impossible steps (like dividing a string by a number) and fail out.

This would be easier to do if KCL functions had type signatures. We've already planned out a syntax for this:

(dir: Direction, distance: float) => { /* function body goes here*/ }

This opens up the way forward for users to add their own struct types (enums are already planned in #1006). Currently KCL supports objects, but we should let users declare structs, which are just types for their objects.

adamchalmers commented 10 months ago

@jessfraz @Irev-Dev fyi