chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] Export specializations with generated type


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Export specializations with generated type database information
Date: Sun, 19 Oct 2014 13:27:12 +0200
User-agent: Mutt/1.4.2.3i

On Sun, Sep 14, 2014 at 12:22:55PM -0700, Evan Hanson wrote:
> Hi all,
> 
> Her's a patch that allows specializations to be included in generated
> type files (previously, they couldn't be used outside the compilation
> unit in which they were defined, so users wouldn't benefit from
> specializations defined in eggs or across modules, etc.).
> 
> Applying this to chicken-5 wasn't too hard, but wasn't totally obvious
> either, so I've provided a patch for that, as well.
> 
> I think everything (NEWS, manifest, etc.) is in order. Let me know if
> I've missed anything.

Hi Evan,

This looks like a great improvement, congratulations on coming up with
this!  The patch itself is fine (and less complicated than I had imagined
for something like this).

I have one concern, though: This may possibly break existing eggs or use
code which generate type files (I'm not sure we have any).  I ran into
this problem myself with the numbers egg: you can't provide specialisations
that use ##core#inline and friends: the C code you link into a shared
object file is (AFAIK) inaccessible to code using that shared object.

For example, single-argument "-" can be specialized to "negate", like so:

((fixnum) ((or fixnum (struct bignum)))
 ((##core#inline_allocate ("C_a_u_i_fixnum_negate" 8) x) #(1)))

However, this will break when put in numbers.types, because numbers.h
isn't installed nor is there a way to have it included automatically
into any module that uses numbers.  That's why I had to add a workaround:

((fixnum) ((or fixnum (struct bignum)))
 (address@hidden #(1)))

And then export @fixnum-negate from the module, which is defined like so:
(define (@fixnum-negate x)
  (##core#inline_allocate ("C_a_u_i_fixnum_negate" 8) x))

This is hacky and inefficient, but better than not specializing at all.

We could decide to apply this anyway for CHICKEN 5, and add a caveat to
the manual (maybe with some sort of override to define "local"
specializations which _can_ use direct C calls).  But ideally, we'd
need some way to say "this module's specializations require including
header file FOO.h".

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

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