guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add `fixnum?' VM primitive


From: Andreas Rottmann
Subject: Re: [PATCH] Add `fixnum?' VM primitive
Date: Fri, 25 Mar 2011 00:51:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

address@hidden (Ludovic Courtès) writes:

> Hi!
>
> Andreas Rottmann <address@hidden> 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?

> 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?

> 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 ;-)).

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]