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

Lack of indenting/braces on nested options in gridfinity-spiral-vase.scad #241

Open
reedy opened this issue Oct 21, 2024 · 1 comment
Open

Comments

@reedy
Copy link
Contributor

reedy commented Oct 21, 2024

There's quite a bit of code in gridfinity-spiral-vase.scad that becomes hard to follow because of conditionals and loops, with inexplicit following instructions due to lack of indenting, or braces etc

For example:

module block_x() {
    translate([-(gridx-1)*l_grid/2,-(gridy-1)*l_grid/2,0])
    for (i = [1:gridx])
    for (j = [1:gridy])
    if (xFunc[style_base](i,j))
    translate([(i-1)*l_grid,(j-1)*l_grid,0])
    block_x_sub();
}

I'm guessing is really something like

module block_x() {
    translate([-(gridx-1)*l_grid/2,-(gridy-1)*l_grid/2,0])
    for (i = [1:gridx]) {
        for (j = [1:gridy]) {
            if (xFunc[style_base](i,j)) {
                translate([(i-1)*l_grid,(j-1)*l_grid,0])
            }
        }
    }
    block_x_sub();
}

But maybe it's

module block_x() {
    translate([-(gridx-1)*l_grid/2,-(gridy-1)*l_grid/2,0])
    for (i = [1:gridx]) {
        for (j = [1:gridy]) {
            if (xFunc[style_base](i,j)) {
                translate([(i-1)*l_grid,(j-1)*l_grid,0])
                block_x_sub();
            }
        }
    }
}

due to the position of the ;. The inconsistency of usages of ; similar make it a little hard to follow, knowing which statements are related to each other...

@EmperorArthur
Copy link
Collaborator

The 2nd is correct, and the first should fail to compile. The rule is that there is an implicit scope (braces) around the next object.

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