[Top][All Lists]

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

Re: Use core or SRFIs?

From: Taylan Kammer
Subject: Re: Use core or SRFIs?
Date: Thu, 24 Oct 2019 19:01:58 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 24.10.2019 17:55, Zelphir Kaltstahl wrote:
> Hello Guile Users!
> I have a question regarding usage of SRFIs in Guile code.
> Sometimes there are core functions, which are also available from an
> SRFI implementation. One example I am currently dealing with are bitwise
> operations for integer numbers. There is SRFI 60 and there are the core
> functions like logand, logior and so on.
> Usually I tend to think, that using the SRFI implementation in such
> situation is better, as it is an implementation of a common interface,
> which other Schemes might also have implemented. Using that makes code
> more portable to other Schemes. However, I want to be sure, that this is
> a good way of thinking about it. Are there ever arguments against using
> an SRFI implementation, when an SRFI implementation provides what I need?
> Another example are structs. I usually use SRFI 9 to make some structs,
> instead of the core record or struct type.
> What do you think?

My decision-tree on this question would go like this:

Do I *really* care about my code being portable?
-> Yes -> Use the SRFI
-> No
   Is the Guile API an old and crusty one that may be deprecated?
   -> Yes -> Use the SRFI
   -> No
      Is the Guile API noticeably better than the SRFI?
      -> Yes -> Use the Guile API
      -> No -> Use the SRFI

The criteria for the API/implementation being "better" might include,
depending on the situation and your subjective tastes:

- simplicity
- feature-richness
- performance

I would default to using the SRFI if the Guile-specific API isn't
noticeably better, because maybe one day you or someone else will try to
make your code portable.  I don't know of an argument for using a
Guile-specific API when there's an SRFI that does the same, is as good,
and is supported by Guile.

> Best regards,
> Zelphir

Kind regards,

- Taylan

P.S. for SRFI enthusiasts: I've written a ton of them in R7RS Scheme,
many of which Guile might support:

reply via email to

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