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: Fri, 25 Mar 2011 11:40:26 +0100
User-agent: Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux)

Hello!

Andreas Rottmann <address@hidden> writes:

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

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?

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

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

BTW why does the ZIP implementation in Industria keep calling ‘fixnum?’?

Thanks,
Ludo’.



reply via email to

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