l...@gnu.org (Ludovic Courtès) writes: > Hello! > > Andreas Rottmann <a.rottm...@gmx.at> writes: > >> l...@gnu.org (Ludovic Courtès) writes: >> >>> Hi! >>> >>> Andreas Rottmann <a.rottm...@gmx.at> writes: >>> >>>> +SCM_DEFINE (scm_fixnum_p, "fixnum?", 1, 0, 0, >>>> + (SCM x), >>>> + "Return @code{#t} if @var{x} is a fixnum, @code{#f} >>>> otherwise.") >>>> +#define FUNC_NAME s_scm_fixnum_p >>>> +{ >>>> + return scm_from_bool (SCM_I_INUMP (x)); >>>> +} >>>> +#undef FUNC_NAME >>> >>> For 2.0 I think you could go with this wonderful hack: >>> >>> (define (fixnum? x) >>> (not (= 0 (logand 2 (object-address x))))) >>> >>> (An inlinable variant thereof, as done in srfi-9.scm.) >>> >> Excellent. Should we put `define-inlinable' in some common place to >> avoid code duplication? If so, where? > > That would be nice, if we are confident that it’s not broken any more. ;-) > ISTR that Chez’ ‘define-integrable’ macro is hairier than that, so I > wonder if our implementation is too naive. Thoughts? > I'll have another look at that; if it turns out it's good, would `(ice-9 inline)' be a proper place for it?
>>> For ‘master’ your patch looks good to me modulo a few details. Why did >>> you need to renumber VM opcodes? >>> >> I didn't need to do so, but the neat order elicited my instinct to keep >> it ;-). I'll revert that part; should I then put `fixnum?' at the end? > > Yes please. > > I guess we could even add the new opcode in stable-2.0 because Andy > tweaked objcode version check to be smarter—i.e., 2.0.1 would be able to > read objcodes produced by either 2.0.1 or 2.0.0. > > WDYT? > That would be nice indeed. >>> Also, I’d prefer not to have ‘fixnum?’ in the default name space >>> because: >>> >>> 1. In Guile parlance, it’d rather be ‘immediate-number?’ (info >>> "(guile) Immediate objects"). >>> >>> 2. I think this fixnum thing is a breach in the numerical tower. >>> >> I'm fine with moving it out of the default namespace (I was actually >> worried about that, too). However, I vaguely remember the compiler not >> outputting the opcode when I did not define `fixnum?' as a C-based >> procedure in the default namespace, but I might be mistaken. I would >> appreciate pointer(s) of where to look to learn about how the compiler >> decides if some procedure can be emitted as an opcode (but I think I >> would be able to figure that out myself, but pointers would be nice >> nevertheless ;-)). > > In (language tree-il primitives), there’s ‘add-interesting-primitive!’, > which checks whether the primitive name is bound in the current module. > OK, I'll experiment with that. > BTW why does the ZIP implementation in Industria keep calling ‘fixnum?’? > It's actually the implementation of `(rnrs arithmetic fixnums)' that calls fixnum for almost every operation; also see my other mail [0], where I talk about lifting that at least for some operations. [0] http://lists.gnu.org/archive/html/guile-devel/2011-03/msg00235.html Regards, Rotty -- Andreas Rottmann -- <http://rotty.yi.org/>