unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: [PATCH] Add `fixnum?' VM primitive
Date: Thu, 24 Mar 2011 23:01:21 +0100	[thread overview]
Message-ID: <87sjuc2n66.fsf@gnu.org> (raw)
In-Reply-To: 1300846773-19003-2-git-send-email-a.rottmann@gmx.at

Hi!

Andreas Rottmann <a.rottmann@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.)

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	other threads:[~2011-03-24 22:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23  2:19 fixnum? VM primitive, increasing fixnum operation speed Andreas Rottmann
2011-03-23  2:19 ` [PATCH] Add `fixnum?' VM primitive Andreas Rottmann
2011-03-24 22:01   ` Ludovic Courtès [this message]
2011-03-24 23:51     ` Andreas Rottmann
2011-03-25 10:40       ` Ludovic Courtès
2011-03-25 11:50         ` Andreas Rottmann
2011-03-25 13:21           ` Ludovic Courtès
2011-03-29 11:03             ` Andy Wingo
2011-03-28 18:48         ` Ken Raeburn
2011-03-29 10:55           ` Andy Wingo
2011-03-29 10:52       ` Andy Wingo
2011-03-29 10:48     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sjuc2n66.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).