Closed Retropikzel closed 2 weeks ago
One challenge here is the question of whether the result should be based on the result of system-type
or cross-system-type
, the latter of which is used for cross-compilation. If the use of cond-expand
switches between runtime code, then cross-system-type
is the right choice, but if it switches between compile-time code, then system-type
is the right choice.
I think system-type
is probably the right choice, since cross-compilation is rare, and providing the cross system information could be confusing. On the other hand, I suspect that most instances of code-expand
that switch based on OS are guarding runtime code, not compile-time code, in which case cross-system-type
would be more likely to do the right thing. Which approach do you think makes more sense?
My usage of cond-expand with OS values has been on the run time side only. Loading different shared objects, reading different environment variables and using different paths.
I do not have any experience cross-compiling with Racket but the documentation says (Installation tools should use cross-system-type, instead, to support cross-installation.)
and I think if one is making installation tools for Racket they dont mind cond-expanding on racket
and then inside there on needed system type.
So I think the system-type
is safer choice and should cover most cases.
Well, normally one would call system-type
at runtime, which is why usage of cross-system-type
is not ordinarily necessary. But cond-expand
is fundamentally a compile-time operation, which complicates matters somewhat. Still, I think you are probably correct that it’s acceptable to just use system-type
for now, and if someone wishes to support cross-compilation, they can do so explicitly.
The result of (system-type 'os)
is either 'windows
, 'macosx
, or 'unix
, so one of those symbols will be included in (features)
and will be recognized by cond-expand
. Do with that as you will!
Thank you very much!
Some Scheme implementations that run on multiple operating systems expose the operating system trough (features). This is very handy when writing portable code. Two implementations that do this are Sagittarius and Gauche. Here are the outputs, run on wine.
Sagittarius:
(sagittarius.termios termios sagittarius.odbc odbc sagittarius.crypto crypto sagittarius.process process sagittarius.ffi-vargs ffi-vargs sagittarius.ffi ffi sagittarius.socket socket sagittarius.time time sagittarius.threads threads sagitt arius.zlib zlib regexp-unicode regexp-backrefs regexp-look-around regexp-non-greedy x86_64-pc-win64 sagittarius-0.9.11 little-endian |64bit| x86_64 windows full-unicode ieee-float exact-complex exact-closed ratios r7rs sagittarius.os.windo ws sagittarius)
Gauche:
(gauche.net.ipv6 gauche.sys.select gauche.sys.nanosleep gauche.sys.setenv regexp-unicode regexp-backrefs regexp-look-around regexp-non-greedy gauche.sys.zlib gauche.net.tls.mbedtls gauche.net.tls gauche.sys.wthreads gauche.sys.threads srfi -22 little-endian windows ratios full-unicode ieee-float exact-closed r7rs gauche-windows gauche.os.windows gauche-0.9.15 gauche srfi-247 srfi-244 srfi-239 srfi-238 srfi-236 srfi-235 srfi-232 srfi-229 srfi-228 srfi-227 srfi-226 srfi-222 sr fi-221 srfi-219 srfi-217 srfi-216 srfi-215 srfi-210 srfi-209 srfi-207 srfi-197 srfi-196 srfi-195 srfi-194 srfi-193 srfi-192 srfi-189 srfi-185 srfi-181 srfi-180 srfi-178 srfi-176 srfi-175 srfi-174 srfi-173 srfi-172 srfi-170 srfi-169 srfi-16 2 srfi-160 srfi-159 srfi-158 srfi-154 srfi-152 srfi-151 srfi-149 srfi-146 srfi-145 srfi-144 srfi-143 srfi-141 srfi-135 srfi-134 srfi-133 srfi-132 srfi-131 srfi-130 srfi-129 srfi-128 srfi-127 srfi-125 srfi-124 srfi-121 srfi-120 srfi-118 srf i-117 srfi-116 srfi-115 srfi-114 srfi-113 srfi-112 srfi-111 srfi-106 srfi-101 srfi-99 srfi-98 srfi-96 srfi-95 srfi-87 srfi-78 srfi-74 srfi-69 srfi-66 srfi-64 srfi-62 srfi-61 srfi-60 srfi-55 srfi-46 srfi-45 srfi-43 srfi-42 srfi-41 srfi-40 s rfi-39 srfi-38 srfi-37 srfi-36 srfi-35 srfi-34 srfi-31 srfi-30 srfi-29 srfi-28 srfi-27 srfi-26 srfi-25 srfi-23 srfi-22 srfi-19 srfi-18 srfi-17 srfi-16 srfi-14 srfi-13 srfi-11 srfi-10 srfi-9 srfi-8 srfi-7 srfi-6 srfi-5 srfi-4 srfi-2 srfi-1 srfi-0 gauche.ces.utf8)
Would it be possible to expose the operating system trough features on racket-r7rs?
I've been cond-expanding like this when writing portable code:
(cond-expand (windows ...) (else ..)
Because often something is needed for windows, and other operating systems are just different unixes. So even just having the "windows" flag in the features would be very helpfull.