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

Do we allow cycles in modules? #69

Open
k2d222 opened this issue Jan 24, 2025 · 1 comment
Open

Do we allow cycles in modules? #69

k2d222 opened this issue Jan 24, 2025 · 1 comment
Milestone

Comments

@k2d222
Copy link
Contributor

k2d222 commented Jan 24, 2025

// module matrix.wesl

fn rotation(angle: f32) -> mat2x2f {
    return mat2x2f(
        cos(angle, -sin(angle),
        sin(angle), cos(angle)
    );
}

fn sum_components(m: mat2x2f) -> f32 {
    return vector::sum_components(m[0]) + vector::sum_components(m[1]);
}

// module vector.wesl

fn rotate(v: vec2f, angle: f32) -> vec2f {
    return matrix::rotation(angle) * v;
}

fn sum_components(v: vec2f) -> f32 {
    return v[0] + v[1];
}

vector::rotate depends on matrix::rotation and matrix::sum_components depends on vector::sum_components. Some languages allow that (rust, javascript) while others don't (c++, python in some cases, java IIRC). What should we do in WESL?

@k2d222 k2d222 added this to the M1 milestone Jan 24, 2025
@stefnotch
Copy link
Collaborator

stefnotch commented Jan 24, 2025

My vote is to allow cycles.

However, there is at least one case that is still illegal.

// foo.wesl
import bar::b;
const a = b + 1;
// bar.wesl
import foo::a;
const b = a + 1;

(a depends on b which depends on a)
Basic linker implementations don't need to check for this though. Generating broken code and letting naga/tint complain is fine.

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

No branches or pull requests

2 participants