chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATCH][5] Move foldable binding annotations into type


From: Evan Hanson
Subject: [Chicken-hackers] [PATCH][5] Move foldable binding annotations into types.db
Date: Tue, 30 Sep 2014 00:33:21 -0700
User-agent: OpenSMTPD enqueuer (Demoosh)

Hi all,

The attached patch moves foldable binding annotations out of
c-platform.scm and into types.db.

While looking into #986[1], I realized there are currently several
library procedures that are marked foldable when they really shouldn't
be (such as the example in the ticket itself!).

So, I audited the whole lot of `foldable-bindings`, and in doing so
moved them into types.db as #:foldable properties for clarity. I have a
hunch that many of the incorrect markings were there in part due to the
indirect way the set of foldable bindings was defined, and in any case
now that we have types.db I think it makes sense to keep as many of
these properties as possible in a single, declarative place.

It's also safe to fold predicates, so rather than redundantly mark all
of those procedures redundantly, I've made #:predicate imply #:foldable
in the optimizer.

A summary of the changed annotations follows. Note that you'll have to
build this revision with itself via boot-chicken, as the new types.db
property is unrecognized on older versions and they'll take this as a
reason to bomb.

If I've missed anything, let me know.

Cheers,

Evan

[1]: http://bugs.call-cc.org/ticket/986

No longer foldable, because they no longer exist:

    hash-table-ref
    thread-specific
    thread-specific-set!

No longer foldable, either because (a) that can't ever actually happen,
(b) doing so seems wrong to me, or (c) they mustn't be folded according
to the spec (or some similar line of thought):

    alist-cons
    append
    block-ref
    block-set!
    call-with-input-file
    call-with-output-file
    call/cc
    f32vector-ref
    f64vector-ref
    foldl
    foldr
    list->string
    list->vector
    locative->object
    locative-ref
    locative-set!
    pointer+
    pointer->object
    pointer=?
    reverse
    string->list
    string-append
    substring
    vector->list
    xcons

Now foldable, though they weren't previously:

    alist-ref
    blob=?
    eighth
    equal=?
    fifth
    imag-part
    last
    last-pair
    length+
    ninth
    rassoc
    real-part
    seventh
    sixth
    string->symbol
    symbol-append
    tenth
    ##sys#gcd
    ##sys#lcm
    ##sys#substring-index
    ##sys#substring-index-ci

For reference, the remaining procedures were previously foldable, and
still are: 
http://paste.call-cc.org/paste?id=41f31ee251427d3d42efdb55f98d21bfeb0cfb3f

Attachment: 0001-Move-foldable-binding-annotations-into-types.db.patch
Description: Text document


reply via email to

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