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

[Feature] #include guards #402

Open
mwasplund opened this issue Dec 28, 2022 · 1 comment
Open

[Feature] #include guards #402

mwasplund opened this issue Dec 28, 2022 · 1 comment

Comments

@mwasplund
Copy link

mwasplund commented Dec 28, 2022

Including a file multiple times should automatically guard against re-loading the same file multiple times. This is especially important with diamond dependencies.

Main.gravity

#include "A.gravity"
#include "B.gravity"

func main() {
  return A.value() + B.value()
}

A.gravity

#include "C.gravity"

class A {
  static func value() {
    return C.value() + 1
  }
}

B.gravity

#include "C.gravity"

class B {
  static func value() {
    return C.value() + 2
  }
}

C.gravity

class C {
  static func value() {
    return 39
  }
}
@marcobambini
Copy link
Owner

@mwasplund you are right, it should not be too hard to implement, let me take a look at it.

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