[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wikid 0.6
From: |
Miroslav Silovic |
Subject: |
Re: wikid 0.6 |
Date: |
17 Sep 2001 16:38:44 +0200 |
Thien-Thi Nguyen <address@hidden> writes:
> wiki w/ guile anyone? all hail the goddess procrastes!
>
> WIKID is free software, provided under GNU GPL, with ABSOLUTELY NO
> WARRANTY. see file COPYING for more details.
>
> thi
A style comment: I noticed you use a lot of string-appends. There's a
trick that both simplifies your code and increases performance (and it
was discussed on this list some time ago).
First, define this function:
(define (flatten-write v)
(if (not (null? v))
(if (pair? v)
(begin
(flatten-write (car v))
(flatten-write (cdr v)))
(display v))))
(replacing 'display' with whatever is needed to output to HTML port).
Now you can use lists instead of strings:
(flatten-write '(("foo" "bar" "baz") "mumble" (("quux"))))
results in
foobarbazmumblequux
The point of this trick: First, string-append allocates a new string
very often, so you really want to pregenerate all your strings and
append them only once. That way you gain on the performance.
Secondly, and much more importantly, you don't need to add extra glue
(such as (apply string-append ...) around list processing functions:
(define (generate-something l)
(list (make-html-header)
(map (lambda (x) (list "<p>" x "</p>\n")) l)
(make-html-footer)))
vs.
(define (generate-something l)
(string-append (make-html-header)
(apply string-append (map (lambda (x) (string-append "<p>" x
"</p>\n")) l))
(make-html-footer)))
I find this style much more LISPish in general. :)
--
How to eff the ineffable?
- wikid 0.6, Thien-Thi Nguyen, 2001/09/17
- Re: wikid 0.6,
Miroslav Silovic <=