Is there an equivalent of Common Lisp's *features
* in Clojure, so you can detect the OS and other environment configuration? Or do I just go through the Java API for that?
Probably use the Java API. It's easy enough, no sense re-inventing the wheel.
user> (System/getProperty "os.name")
"Linux"
user> (System/getProperty "os.version")
"2.6.36-ARCH"
user> (System/getProperty "os.arch")
"amd64"
To add to Brian Carper's answer, you could easily create a map of system properties via the Java API and bind it to the symbol features:
(def *features* {
:name (System/getProperty "os.name"),
:version (System/getProperty "os.version"),
:arch (System/getProperty "os.arch")})
Which gives you this structure, for example:
{:name "Windows 7", :version "6.1", :arch "x86"}
Then access a property in any one of the following ways:
(:name *features*)
(*features* :name)
(get *features* :name)
Whichever floats your boat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With