This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bracket heresies. What about subscripting?


Lars Arvestad <arve@nada.kth.se> writes:

> CB = Chris Bitmead <chris@tech.com.au>
> CB> Lars Arvestad wrote:
> >> While the smiley might cover the first sentence as well as the 
> >> second, I would like to point out that there are certainly 
> >> situation when you need a vector, even if you want to write 
> >> your programs functionally.
> 
> CB> Well I did say "much". It is rather difficult I think to write
> CB> functional code with vectors. Vectors usually imply the notion of
> CB> changing slots. Don't you think?
> 
> Sure, but my point is that you might have a fully functional mindset,
> but still be better of using vectors. I have written simple code for
> computing (basically) string edit distance using vectors, but
> otherwise use a functional approach (with looping by recursion
> et.c.). It is only the vector manipulation in that program that is
> non-functional, so I'd like to say that I used a functional programming
> style. I have seen a full research article for solving the same
> problem in a purely functional programming style, so even if I did not 
> read that article I'd say that you are better of compromising.

Paul Graham in his book "On Lisp" which is a must read for those
interested in macros and the full power of lisps, talks about this
mixture of functional programming style with imperative, or
side-effecting datatypes and functions.

Some things to consider when writing side-effecting code, or calling
it:

1. Does it modify any of it's args?
2. Does it modify anything shared with other code?
3. Does it modify objects that are returned to it?
4. Does it share code with functions that violate another rule?
5. Is it safe to modify objects which it returns?

Code which follows these rules are nearly as good as pure
functional code.  When we have functions that do not follow one of
these rules, we need to be careful about how we let them infect the
rest of our program.


-- 
Craig Brozefsky                         <craig@red-bean.com>
Free Scheme/Lisp Software     http://www.red-bean.com/~craig
I say woe unto those who are wise in their own eyes, and yet
imprudent in 'dem outside                            -Sizzla

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]