separate-typechecking 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. When and how to create/read interface files
  2. -------------------------------------------
  3. We need information from imports twice: at scope checking, and at type checking.
  4. We can go about this in a few different ways:
  5. - read interface file twice, first at scope checking (possibly creating it) and second
  6. at type checking
  7. - read the interface once, and store the type information for use at type
  8. checking time
  9. Other concerns
  10. --------------
  11. - What happens when we do import from inside a parameterised module? Top-level
  12. modules can be parameterised.
  13. - The imported module exists outside the parameterised module, so it shouldn't
  14. be affected by the parameters.
  15. - Can we do imports anywhere? Does it make sense. Probably, but is it a good
  16. thing? Options:
  17. - imports anywhere
  18. - only in top-level module
  19. - only first in top-level module (Haskell-style)
  20. - before the top-level module (java-style)
  21. Let's stick with imports anywhere for the time being.
  22. Technical issues
  23. ----------------
  24. - How should it work?
  25. - The interface file simply stores a representation of the internal state
  26. (ScopeInfo and Signature). When importing a module we just read the
  27. interface file and merge the corresponding internal thing into the current
  28. state.
  29. - We need to keep track of what things come from the current module, and what
  30. things come from imported modules. In the final version we don't want to store
  31. things from an imported module in the interface for a module. But rather store
  32. a reference to the imported module. This of course means that reading an
  33. interface file might require the reading of other interface files. We need
  34. cycle detection.
  35. - First step should be to change the Signature and ScopeInfo to account for
  36. imported modules, making sure we recognise what's part of the current module
  37. and what is imported.
  38. - In scope checking we need to store the ModuleScope. This means that there
  39. should be a function to extract the ModuleScope of the current module from the
  40. ScopeInfo.
  41. - Now what?
  42. Making the type checking monad aware of imports:
  43. - separate signatures for imported modules and other modules
  44. - look up things in both signatures. exactly one lookup must succeed.
  45. - we play around with the signature in a lot of places? what needs to be
  46. changed to handle the imported signature? don't know, i guess we'll see...
  47. - What does the interface file need to contain?
  48. - ModuleScope
  49. - Signature
  50. - BuiltinThings
  51. - names of imported modules
  52. - Issues
  53. - primitive functions: we can't store type-checking computations in the
  54. interface file. So we need a different representation. What?
  55. - remember which module have been imported, so that we don't load the same
  56. interface several times. Or don't care? If we want to check for clashes we
  57. might want to do this.
  58. vim: tw=80 sts=2 sw=2 fo+=t com=f\:-