4

That must be something like that :

(if (= system-type 'gnu/linux)
    (system "make"))

To be honest I think my scheme implementation even can't do it in anyways but I'm free to add realization for it. What is usual scheme syntax for Platform detection?

thank you

cnd
  • 32,616
  • 62
  • 183
  • 313
  • 3
    I suspect there is no standard syntax for this. But as with so many things Scheme, it's easy enough to add to other variants if you implement it in one of them. My guess is, you should write a function looking for the existence (and possibly contents) of specific files that would indicate the system you're running on. Look for "/bin/uname" to find Linux-like systems for instance, then run it to find out the details. – Janne Jan 20 '12 at 13:05
  • 1
    Questions like this one are good ones, and point to why it is more accurate to call Scheme a family of languages rather than a single one; most of the time, writing a program requires writing to a particular one, rather than all of them. Ryan's answer is the right one for Racket, and I think that the responsiveness of the Racket community generally is one good reason to make it your choice. Sorry for the biased advocacy :). – John Clements Jan 20 '12 at 20:00

2 Answers2

7

I can't speak for any other Schemes, but Racket has a procedure called system-type:

> (system-type)
'unix
> (system-type 'machine)
"Linux ... x86_64 GNU/Linux"  ;; ellipses mine, output is same as `uname -a`
Ryan Culpepper
  • 10,495
  • 4
  • 31
  • 30
1

And guile has a uname function, which returns a description as a scheme vector object:

scheme@(guile-user)> (uname)
$2 = #("Linux" "gblaptop" "2.6.39-gentoo-r3" "#4 SMP Fri Oct 21 08:12:17 PDT 2011" "i686")
gcbenison
  • 11,723
  • 4
  • 44
  • 82