Skip to content

Support for func/function keyword syntax #368

@dennybaa

Description

@dennybaa

Hello,

I'm totally able to use functions in KCL and this is awesome. But it would be nice to have syntax support for this:

schema Config:
    mixin [
        AppIdMixin
    ]
    [...str]: any
    team: str
    teamName?: str
    cluster?: str
    project?: str
    env?: str
    baseId?: str
    appId?: any

protocol AppIdProtocol:
    team: str
    project?: str
    env?: str

mixin AppIdMixin for AppIdProtocol:
    baseId = "-".join([e for e in [team, project, env] if e])
    appId = lambda name: str -> str {
        "${baseId}-${name}"
    }

Functions are operational, though I'm not sure with how many positional arguments, one argument works at least...
To achieve this scenario a workaround setting type to any appId?: any is required, it would great to have ability to support this with some native syntax... WDYT @Peefy ?

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions