chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Even more format weirdness


From: Alejandro Forero Cuervo
Subject: Re: [Chicken-users] Even more format weirdness
Date: Sun, 4 Sep 2005 10:35:43 -0500
User-agent: Mutt/1.5.9i

> I have just kicked out the old format from the base system. It will
> be available as an egg in the future (so user-code will not notice).
> [...] Perhaps if you release the new format code as an egg
> (`better-format` ? ;-), users will find it easier to test it?

Great thinking!  That will greatly simplify testing.

I'll lay, erm, release the egg soon (I want to clean it up a little).

I was thinking about an optimization where one can call
"make-format-function" with the format string and it will return a
function receiving the port and optional arguments.  With that one
could define format as follows:

  (define (format port str . rest)
    (apply (make-format-function str) port rest))

(Actually, one uses another function to build "make-format-function"
from some parameters specifing its behaviour.)

This would have the advantage, though, that when the same format
string is used multiple times, one can make things run faster, as in:

  (let ((func (make-format-function "Times: ~A: ~:{ ~A=~A~^,~}~%")))
    (for-each (cut apply func #t <>) *all-objects*))

Since most of the time this string will be known in advance, I'd like
this expansion to be performed at compile time (or at least once at
startup).  Basically, I want to do something like this:

  (define-macro (format p fmt . args)
    (if (string? fmt)
      (compile-time-expand p fmt args)
      `((make-format-function fmt) p ,@args)))

However, I would save a lot of time if I could define
compile-time-expand as a call to make-format-function so I wouldn't
have to duplicate functionality.  Any thoughts on how I should do
this?

Thanks.

Alejo.
http://azul.freaks-unidos.net/

---=(  Comunidad de Usuarios de Software Libre en Colombia  )=---
---=(  http://bachue.com/colibri )=--=( address@hidden  )=---

Attachment: signature.asc
Description: Digital signature


reply via email to

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