KCL: User-defined KCL functions in examples etc now use keywords (#6603)
Preparing for the removal of positional functions from the language. The first big step is to change all our KCL code examples, test code, public samples etc to all use keyword functions. Apologies for how large this PR is. Most of it is: - Changing example KCL that defined its own functions, so the functions now use keyword arguments rather than positional arguments. E.g. change `cube([20, 20])` to be `cube(center = [20, 20])`. - Some parts of the code assumed positional code and didn't handle keyword calls, e.g. the linter would only check for positional calls to startSketchOn. Now they should work with either positional or keyword. - Update all the artifacts This does _not_ remove support for positional calls. That will be in a follow-up PR.
This commit is contained in:
		@ -1105,49 +1105,69 @@ description: Result of parsing cube_with_error.kcl
 | 
			
		||||
          "init": {
 | 
			
		||||
            "arguments": [
 | 
			
		||||
              {
 | 
			
		||||
                "commentStart": 0,
 | 
			
		||||
                "end": 0,
 | 
			
		||||
                "raw": "40",
 | 
			
		||||
                "start": 0,
 | 
			
		||||
                "type": "Literal",
 | 
			
		||||
                "type": "Literal",
 | 
			
		||||
                "value": {
 | 
			
		||||
                  "value": 40.0,
 | 
			
		||||
                  "suffix": "None"
 | 
			
		||||
                "type": "LabeledArg",
 | 
			
		||||
                "label": {
 | 
			
		||||
                  "commentStart": 0,
 | 
			
		||||
                  "end": 0,
 | 
			
		||||
                  "name": "length",
 | 
			
		||||
                  "start": 0,
 | 
			
		||||
                  "type": "Identifier"
 | 
			
		||||
                },
 | 
			
		||||
                "arg": {
 | 
			
		||||
                  "commentStart": 0,
 | 
			
		||||
                  "end": 0,
 | 
			
		||||
                  "raw": "40",
 | 
			
		||||
                  "start": 0,
 | 
			
		||||
                  "type": "Literal",
 | 
			
		||||
                  "type": "Literal",
 | 
			
		||||
                  "value": {
 | 
			
		||||
                    "value": 40.0,
 | 
			
		||||
                    "suffix": "None"
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "commentStart": 0,
 | 
			
		||||
                "elements": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "commentStart": 0,
 | 
			
		||||
                    "end": 0,
 | 
			
		||||
                    "raw": "0",
 | 
			
		||||
                    "start": 0,
 | 
			
		||||
                    "type": "Literal",
 | 
			
		||||
                    "type": "Literal",
 | 
			
		||||
                    "value": {
 | 
			
		||||
                      "value": 0.0,
 | 
			
		||||
                      "suffix": "None"
 | 
			
		||||
                "type": "LabeledArg",
 | 
			
		||||
                "label": {
 | 
			
		||||
                  "commentStart": 0,
 | 
			
		||||
                  "end": 0,
 | 
			
		||||
                  "name": "center",
 | 
			
		||||
                  "start": 0,
 | 
			
		||||
                  "type": "Identifier"
 | 
			
		||||
                },
 | 
			
		||||
                "arg": {
 | 
			
		||||
                  "commentStart": 0,
 | 
			
		||||
                  "elements": [
 | 
			
		||||
                    {
 | 
			
		||||
                      "commentStart": 0,
 | 
			
		||||
                      "end": 0,
 | 
			
		||||
                      "raw": "0",
 | 
			
		||||
                      "start": 0,
 | 
			
		||||
                      "type": "Literal",
 | 
			
		||||
                      "type": "Literal",
 | 
			
		||||
                      "value": {
 | 
			
		||||
                        "value": 0.0,
 | 
			
		||||
                        "suffix": "None"
 | 
			
		||||
                      }
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                      "commentStart": 0,
 | 
			
		||||
                      "end": 0,
 | 
			
		||||
                      "raw": "0",
 | 
			
		||||
                      "start": 0,
 | 
			
		||||
                      "type": "Literal",
 | 
			
		||||
                      "type": "Literal",
 | 
			
		||||
                      "value": {
 | 
			
		||||
                        "value": 0.0,
 | 
			
		||||
                        "suffix": "None"
 | 
			
		||||
                      }
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "commentStart": 0,
 | 
			
		||||
                    "end": 0,
 | 
			
		||||
                    "raw": "0",
 | 
			
		||||
                    "start": 0,
 | 
			
		||||
                    "type": "Literal",
 | 
			
		||||
                    "type": "Literal",
 | 
			
		||||
                    "value": {
 | 
			
		||||
                      "value": 0.0,
 | 
			
		||||
                      "suffix": "None"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ],
 | 
			
		||||
                "end": 0,
 | 
			
		||||
                "start": 0,
 | 
			
		||||
                "type": "ArrayExpression",
 | 
			
		||||
                "type": "ArrayExpression"
 | 
			
		||||
                  ],
 | 
			
		||||
                  "end": 0,
 | 
			
		||||
                  "start": 0,
 | 
			
		||||
                  "type": "ArrayExpression",
 | 
			
		||||
                  "type": "ArrayExpression"
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "callee": {
 | 
			
		||||
@ -1168,8 +1188,9 @@ description: Result of parsing cube_with_error.kcl
 | 
			
		||||
            "commentStart": 0,
 | 
			
		||||
            "end": 0,
 | 
			
		||||
            "start": 0,
 | 
			
		||||
            "type": "CallExpression",
 | 
			
		||||
            "type": "CallExpression"
 | 
			
		||||
            "type": "CallExpressionKw",
 | 
			
		||||
            "type": "CallExpressionKw",
 | 
			
		||||
            "unlabeled": null
 | 
			
		||||
          },
 | 
			
		||||
          "start": 0,
 | 
			
		||||
          "type": "VariableDeclarator"
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ fn cube(length, center) {
 | 
			
		||||
    |> extrude(length = length)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
myCube = cube(40, [0, 0])
 | 
			
		||||
myCube = cube(length = 40, center = [0, 0])
 | 
			
		||||
 | 
			
		||||
// Error, after creating meaningful output.
 | 
			
		||||
foo
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,58 @@ description: Operations executed cube_with_error.kcl
 | 
			
		||||
      "name": "cube",
 | 
			
		||||
      "functionSourceRange": [],
 | 
			
		||||
      "unlabeledArg": null,
 | 
			
		||||
      "labeledArgs": {}
 | 
			
		||||
      "labeledArgs": {
 | 
			
		||||
        "center": {
 | 
			
		||||
          "value": {
 | 
			
		||||
            "type": "Array",
 | 
			
		||||
            "value": [
 | 
			
		||||
              {
 | 
			
		||||
                "type": "Number",
 | 
			
		||||
                "value": 0.0,
 | 
			
		||||
                "ty": {
 | 
			
		||||
                  "type": "Default",
 | 
			
		||||
                  "len": {
 | 
			
		||||
                    "type": "Mm"
 | 
			
		||||
                  },
 | 
			
		||||
                  "angle": {
 | 
			
		||||
                    "type": "Degrees"
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "type": "Number",
 | 
			
		||||
                "value": 0.0,
 | 
			
		||||
                "ty": {
 | 
			
		||||
                  "type": "Default",
 | 
			
		||||
                  "len": {
 | 
			
		||||
                    "type": "Mm"
 | 
			
		||||
                  },
 | 
			
		||||
                  "angle": {
 | 
			
		||||
                    "type": "Degrees"
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            ]
 | 
			
		||||
          },
 | 
			
		||||
          "sourceRange": []
 | 
			
		||||
        },
 | 
			
		||||
        "length": {
 | 
			
		||||
          "value": {
 | 
			
		||||
            "type": "Number",
 | 
			
		||||
            "value": 40.0,
 | 
			
		||||
            "ty": {
 | 
			
		||||
              "type": "Default",
 | 
			
		||||
              "len": {
 | 
			
		||||
                "type": "Mm"
 | 
			
		||||
              },
 | 
			
		||||
              "angle": {
 | 
			
		||||
                "type": "Degrees"
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          "sourceRange": []
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "sourceRange": []
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ fn cube(length, center) {
 | 
			
		||||
    |> extrude(length = length)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
myCube = cube(40, [0, 0])
 | 
			
		||||
myCube = cube(length = 40, center = [0, 0])
 | 
			
		||||
 | 
			
		||||
// Error, after creating meaningful output.
 | 
			
		||||
foo
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user