Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider exposing parameters, variables and fields as property accessors #56

Open
vlsi opened this issue Feb 2, 2020 · 1 comment
Open

Comments

@vlsi
Copy link

vlsi commented Feb 2, 2020

For instance:

func("func", "bool" of Boolean::class) {
If("bool") {
statement("println(true)")
}.end()
}

The sad thing is "bool" is duplicated. For instance, when If("bool") is created in another method, it won't even fail if the parameter with that name does not exist.

What if func scope provided property that could be used to declare, and retrieve parameters and locals?

For instance:

createFun{
    func("func") {
        // Below adds a parameter to the function. It knows data type, it knows the name
        val flag by parameters.creating<Boolean>()
        If(flag) {
...
createFun{
    func("func") {
        // Below adds a parameter to the function. It knows data type, it knows the name
        val flag by parameters.creating<Boolean> {
            // configure initializers, varargs or whatever (it will go to the function parameter declaration)
        }
        If(flag) {
...
createFun{
    func("func", "flag" of Boolean::class) {
        val flag by parameters.existing // throw if parameter named "flag" does not exist
        If(flag) {
...
@tieskedh
Copy link
Owner

tieskedh commented Feb 4, 2020

Great idea!
I will look into it on sunday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants