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: Ludovic Courtès
Subject: Re: [PATCH] Add `fixnum?' VM primitive
Date: Thu, 24 Mar 2011 23:01:21 +0100
User-agent: Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux)

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

For ‘master’ your patch looks good to me modulo a few details.  Why did
you need to renumber VM opcodes?  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.

Thanks,
Ludo’.




reply via email to

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