gravity icon indicating copy to clipboard operation
gravity copied to clipboard

[Feature] #include guards

Open mwasplund opened this issue 2 years ago • 1 comments

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
  }
}

mwasplund avatar Dec 28 '22 17:12 mwasplund

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

marcobambini avatar Dec 29 '22 08:12 marcobambini