Search code examples
schememit-scheme

How to detect version of MIT Scheme?


Is there a method that can be used to detect the version of MIT Scheme used from within a piece of Scheme code?

For example, I may need a piece of code to determine whether it is being interpreted by MIT Scheme 9.1, or by MIT Scheme 9.2, and act accordingly.

Maybe there exists a procedure (e.g. (interpreter-version)) that returns the release number of MIT Scheme?


Solution

  • Here are methods used by some open source projects to detect the version of MIT Scheme:

    • Method used by the SLIB project (file: mitscheme.init):

      (get-subsystem-version-string "Release")
      

      Example return value: "9.2"

    • Method used by the SLIME project (file: contrib/swank-mit-scheme.scm):

      (get-subsystem-version "Release")
      

      This returns the version numbers in a list. For example, if you are using MIT Scheme version 10.1.10, the return value will be '(10 1 10). Example usage:

      (if (>= (car (get-subsystem-version "Release"))
              9)
        'do-something-if-version-9-and-above
        'otherwise-do-this-if-below-version-9)
      

    Caution: The procedures used in this answer are undocumented. get-subsystem-version and get-subsystem-version-string are both defined in MIT Scheme's src/runtime/system.scm file.