guile-user
[Top][All Lists]
Advanced

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

Re: guile style


From: Zelphir Kaltstahl
Subject: Re: guile style
Date: Sat, 19 Jun 2021 17:02:39 +0000

On 6/19/21 2:16 PM, jerry wrote:
> On 6/19/21 7:20 AM, Christopher Lam wrote:
>> Agree set! is not a desirable form. It is not consistently optimisable. I
>> cannot find the reference in the manual.
>>
>> Also consider the first form: you're building a list in 3 passes -- call iota
>> to generate a list, call filter to navigate the list again, then fold to
>> accumulate your answer. Therefore it's O(3N).
>>
>> The preferred form is definitely from the little schemer.
>>
> Haskell has something called stream fusion which can optimize the extra
> passes out in many cases. I wonder if Guile or any of the other scheme
> compilers can do that? As someone who has spent the majority of my life
> writing high performance C and Fortran code, the inefficiencies in a lot
> of functional programming is something I don't care for. On the other
> hand, writing functional code is fun.

I'd be surprised, if Guile did such an optimization. I think you are supposed to
write the optimized version of the algorithm. In my opinion, when you know a
better version, you should not rely on an optimization by one particular
compiler or language.

I think it is fine to have small (really small, hopefully not changing time or
space complexity class) performance trade-offs in order to achieve better
readability. Usually however, I well readable version of the better algorithm is
possible.

-- 
repositories: https://notabug.org/ZelphirKaltstahl




reply via email to

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