This website requires JavaScript.
Cadquos
Explore
Marketplace
Help
Register
Sign In
Cadquos
Development
Main Navigation
🏠
Dashboard
🏢
Organizations
8
📁
Repositories
8
👥
Team
🗓️
Calendar
Workspace
📝
작업메모
🚀
시작하기
📝
빠른 메모
👻
나의 공간
3
📝
작업목록
Settings
Connections
Public Pages
Notifications
3
Help Center
John Smith
john@example.com
ByoungSooPark
/
modeling-app
Watch
1
Star
0
Fork
0
You've already forked modeling-app
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Files
5dc77ceed543ad8e631799076fb70a38dbe22f6b
modeling-app
/
rust
/
kcl-lib
/
e2e
/
executor
/
inputs
/
no_visuals
/
identity.kcl
4 lines
38 B
Plaintext
Raw
Normal View
History
Unescape
Escape
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.
2025-05-01 11:36:51 -05:00
export fn identity(@x) {
internal: KCL modules, part 1 (#4149) Addresses #4080. (Not ready to close it yet.) # Important Requires a fix for #4147 before it can work in ZMA. # Overview ```kcl // numbers.kcl export fn inc = (x) => { return x + 1 } ``` ```kcl import inc from "numbers.kcl" answer = inc(41) ``` This also implements multiple imports with optional renaming. ```kcl import inc, dec from "numbers.kcl" import identity as id, length as len from "utils.kcl" ``` Note: Imported files _must_ be in the same directory. Things for a follow-up PR: - #4147. Currently, we cannot read files in WebAssembly, i.e. ZMA. - Docs - Should be an error to `import` anywhere besides the top level. Needs parser restructuring to track the context of a "function body". - Should be an error to have `export` anywhere besides the top level. It has no effect, but we should tell people it's not valid instead of silently ignoring it. - Error message for cycle detection is funky because the Rust side doesn't actually know the name of the first file. Message will say "b -> a -> b" instead of "a -> b -> a" when "a" is the top-level file. - Cache imported files so that they don't need to be re-parsed and re-executed.
2024-10-17 00:48:33 -04:00
return x
}
Reference in New Issue
Copy Permalink