> Are the authors opposed to pre-processing on principle, or is this just
> something nobody has gotten around to yet?
Go is not going to acquire a preprocessing phase like C. This is a
matter of principle.
> If the Go community rejects pre-processing, why and what does it offer to
> prevent the explosion of variant sources?
Note that this is only an issue when working with the syscall package or
cgo. For the syscall package, variant sources, controlled by build
tags, are the supported mechanism. For a case like your using cgo, I
would recommend handling the type in the C source code if possible, in
order to present a uniform interface to the Go code.
Ian
If the Go community rejects pre-processing, why and what does it offer to prevent the explosion of variant sources?
In particular, how could the following be offered as a patch to misc/cgo/gmp/gmp.go ?
// Lsh sets z = x << s and returns z.func (z *Int) Lsh(x *Int, s uint) *Int {x.doinit()z.doinit()// The version of gmp we have (4.3.2) doesn't have mp_bitcnt_t
// C.mpz_mul_2exp(&z.i[0], &x.i[0], C.mp_bitcnt_t(s))
C.mpz_mul_2exp(&z.i[0], &x.i[0], C.ulong(s))return z}// Rsh sets z = x >> s and returns z.func (z *Int) Rsh(x *Int, s uint) *Int {x.doinit()z.doinit()// The version of gmp we have (4.3.2) doesn't have mp_bitcnt_t// C.mpz_div_2exp(&z.i[0], &x.i[0], C.mp_bitcnt_t(s))
I originally asked for usage of the mp_bitcnt_t type
http://code.google.com/p/go/issues/detail?id=2007
because newer versions of GMP do use this type. Instead of reverting this
change I really would like to see an exemplary way to handle such problems.
Best,
Frithjof
I originally asked for usage of the mp_bitcnt_t type
http://code.google.com/p/go/issues/detail?id=2007
because newer versions of GMP do use this type. Instead of reverting this
change I really would like to see an exemplary way to handle such problems.
Here's how it's done in C: http://plan9.bell-labs.com/sources/plan9/sys/src/9/
The compiler just predefines these values.
What's special about this? Any reasonable optimizing compiler will do
the same. Or in the case of the Go toolchain, one of ?l can do it too
IIRC.
I tried but failed to find the article that we used to call 'if (0)'
back at LANL. The argument explained why
if (0)
made a lot more sense than
#if 0
(more or less)
ron
There is nothing special required of the compiler, that is why it is
such an elegant solution.