| www.delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to geda-user-bounces using -f |
| X-Recipient: | geda-user AT delorie DOT com |
| Date: | Sat, 12 Sep 2015 17:37:46 +0200 (CEST) |
| From: | Roland Lutz <rlutz AT hedmen DOT org> |
| To: | "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com> |
| Subject: | Re: [geda-user] About reinventing the wheel, and how to avoid it |
| In-Reply-To: | <20150911214120.GB7946@localhost.localdomain> |
| Message-ID: | <alpine.DEB.2.00.1509121720120.2554@lichen> |
| References: | <alpine DOT DEB DOT 2 DOT 00 DOT 1509111150410 DOT 2482 AT lichen> <20150911214120 DOT GB7946 AT localhost DOT localdomain> |
| User-Agent: | Alpine 2.00 (DEB 1167 2008-08-23) |
| MIME-Version: | 1.0 |
| Reply-To: | geda-user AT delorie DOT com |
| Errors-To: | nobody AT delorie DOT com |
| X-Mailing-List: | geda-user AT delorie DOT com |
| X-Unsubscribes-To: | listserv AT delorie DOT com |
On Sat, 12 Sep 2015, Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com] wrote:
> On Fri, Sep 11, 2015 at 04:06:36PM +0200, Roland Lutz wrote:
>> [C code]
>
> And that's an impenetrable code for the same in Guile:
>
> (use-modules (geda page))
>
> ; Checks if the OBJECT is a circle or an arc with zero radius
> (define (zero-radius-object? object)
> (or
> (and (circle? object) (= (circle-radius object) 0))
> (and (arc? object) (= (arc-radius object) 0))))
>
> (apply page-remove! (active-page)
> (filter
> zero-radius-object?
> (page-contents (active-page))))
Or, assuming a similar syntax that preserves the information needed to
optimize the request:
(delete-selected-objects! (active-page)
(select-by-radius (active-page) 0))
> Just about reinvention of the wheel. :-/
The point here isn't C vs. Scheme. The point is iterating over all
objects vs. passing a structured request to the library. My example is in
C because the libxornstorage interface is in C, and that's because it's
generally a good idea to have a library interface in C unless there is
good reason to do otherwise.
I don't seriously expect anyone (except maybe hardcore C fans) to use the
C interface directly (though I tried hard to make it as well-usable as
possible). I'm not even using it directly myself except for the test
cases. The intended use case is to write language bindings for some
high-level language--in my case, it was Python, it may be Scheme for
you--and use that language from then on.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |