Freitag, September 17, 2004

hey .. 1 more ..

I do not intend this to become a Scheme hater page, still it might be helpful to show you some more or less suprising things(depending on where you come from), so that your are not too surprized when they fall onto your feet.

At first sight following seemed to be ok:
(define thread-safe-format
  (let ((our-thread-lock (make-mutex)))
    (lambda (stream format . rest)
      (with-mutex our-thread-lock
        (apply format stream format rest)))))


But no, it's wrong! .. as you would probably find out very fast.

Scheme has only one namespace for functions and variables(which in fact is nice in theory, but still ..). So the function that apply actually tries to apply is the format that was supplied to the lambda form.

Changing the name helps a lot .. now think in the lines of writing programatic macros and you might realize why using something like #' in combination with funcall(in CL) might indeed make some sense..

Ohh i forgot to mention: guiles (ice-9 format) isn't threadsafe which exactly is one of the reasons why this posts exists.

4 Comments:

Anonymous Anonym

So, you're pissed off because Scheme isn't CL? That makes just as much sense as the Schemers who're pissed off because CL isn't Scheme. Empty your cup.-- Larry Clapp

4:36 PM  
Blogger Christian B.

Der Kommentar wurde von einem Blog-Administrator entfernt.

2:50 AM  
Blogger Christian B.

I am a bit pissed but rather because being offered to empty a cup somebody else just passed around. (pun intended)

As i mentioned in the first line of the post this comment belongs to. this remarks are there for me to remember and for others to make them aware.

This certainly is no Lisp pissing contest, just a summary of some pitfalls that one can fall into when using scheme.

I am very well aware that certain things might come handy in certain situations and can be a source of major headaches in others.

If i might paraphrase mutt: all programming languages suck, lisps just sucks less.

3:14 AM  
Blogger Christian B.

Please don't be surprised, i changed the post a bit.
I hope my intentions are more easily understood now.

5:49 PM  

Kommentar veröffentlichen

<< Home