From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Add `fixnum?' VM primitive Date: Fri, 25 Mar 2011 12:50:47 +0100 Message-ID: <877hbn1krs.fsf@gmx.at> References: <1300846773-19003-1-git-send-email-a.rottmann@gmx.at> <1300846773-19003-2-git-send-email-a.rottmann@gmx.at> <87sjuc2n66.fsf@gnu.org> <87vcz8rsap.fsf@vir.lan> <878vw3xz39.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1301053873 17517 80.91.229.12 (25 Mar 2011 11:51:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2011 11:51:13 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Mar 25 12:51:09 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q35Xn-0003Tx-P4 for guile-devel@m.gmane.org; Fri, 25 Mar 2011 12:51:08 +0100 Original-Received: from localhost ([127.0.0.1]:33092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q35Xm-0003vG-Oq for guile-devel@m.gmane.org; Fri, 25 Mar 2011 07:51:06 -0400 Original-Received: from [140.186.70.92] (port=41397 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q35Xh-0003tX-7v for guile-devel@gnu.org; Fri, 25 Mar 2011 07:51:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q35Xe-0001R6-OH for guile-devel@gnu.org; Fri, 25 Mar 2011 07:51:00 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:34033) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Q35Xe-0001Pk-AJ for guile-devel@gnu.org; Fri, 25 Mar 2011 07:50:58 -0400 Original-Received: (qmail invoked by alias); 25 Mar 2011 11:50:55 -0000 Original-Received: from 83-215-154-5.hage.dyn.salzburg-online.at (EHLO nathot.lan) [83.215.154.5] by mail.gmx.net (mp048) with SMTP; 25 Mar 2011 12:50:55 +0100 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX18vUbRESpEvdSz/G2gbYPkeyKGnmFn0qVLN02+F07 RsImxZcWKZBcSJ Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id 7BF8B3A68F; Fri, 25 Mar 2011 12:50:53 +0100 (CET) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4UHr99GAL9HI; Fri, 25 Mar 2011 12:50:48 +0100 (CET) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id 6F3543A685; Fri, 25 Mar 2011 12:50:48 +0100 (CET) Original-Received: by delenn.lan (Postfix, from userid 1000) id 154982C00C1; Fri, 25 Mar 2011 12:50:48 +0100 (CET) In-Reply-To: <878vw3xz39.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Fri, 25 Mar 2011 11:40:26 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 213.165.64.22 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11978 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hello! > > Andreas Rottmann writes: > >> ludo@gnu.org (Ludovic Court=C3=A8s) writes: >> >>> Hi! >>> >>> Andreas Rottmann writes: >>> >>>> +SCM_DEFINE (scm_fixnum_p, "fixnum?", 1, 0, 0, >>>> + (SCM x), >>>> + "Return @code{#t} if @var{x} is a fixnum, @code{#f} other= wise.") >>>> +#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 (=3D 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=E2=80=99s not broken any = more. ;-) > ISTR that Chez=E2=80=99 =E2=80=98define-integrable=E2=80=99 macro is hair= ier 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 =E2=80=98master=E2=80=99 your patch looks good to me modulo a few d= etails. Why did >>> you need to renumber VM opcodes?=20 >>> >> 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=E2=80=94i.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=E2=80=99d prefer not to have =E2=80=98fixnum?=E2=80=99 in the d= efault name space >>> because: >>> >>> 1. In Guile parlance, it=E2=80=99d rather be =E2=80=98immediate-numbe= r?=E2=80=99 (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=E2=80=99s =E2=80=98add-interestin= g-primitive!=E2=80=99, > 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 =E2=80=98fi= xnum?=E2=80=99? > 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 --=20 Andreas Rottmann --