>>>> "ben" == Ben Wing <ben(a)666.com>
writes:
ben> Stefan is right, we need formats, not operations.
I think this is more confusion than clarification. In general, there
may be a number of different things to do with a format, or even a
pair of formats.
Eg, isn't what you really want to be able to write something like this:
(define-format jp-gz
;; The (detect ...) form is like a cond.
;; Each clause has a format to be checked; if the condition is OK,
;; execute the list of converters in the cdr of the clause in order.
'(decoder
(detect (gzip gunzip
(detect (utf-8 utf8-to-mule)
(shift-jis sjis-to-mule)
(euc-jp eucjp-to-mule)
(iso2022jp iso2022jp-to-mule)
;; yeah yeah this syntax is bogus
(other (error "This isn't Japanese.")))
;; no error if eol not detected, assume Unix
(detect (eol-crlf dos-to-unix)
(eol-cr mac-to-unix))
(other (error "This isn't gzip."))))))
But now it's not obvious what should be done with a gzip if we specify
(gzip internal). Should we apply gunzip to it, or should we apply the
jp-gz decoder? Both result in the `internal' format. How do we
disambiguate that?
Also, note that the jp-gz decoder does not have a well-defined inverse
operation. But wouldn't we like to be able to define such auto-
detecting converters, and pipeline them with other converters? Eg,
(define-format maybe-gz
'(decoder
(detect (gzip gunzip))))
You can put the maybe-gz converter in any input pipeline, and it will
detect gzipped files and gunzip them but not barf if they aren't (the
plain gzip converter should do so, I think). But it doesn't have an
inverse, either. This isn't quite it:
(define-format maybe-gz-too
'(decoder
(detect (gzip gunzip))
encoder
(detect (gzip identity)
(other gzip))))
but that looks kinda useful to me.
We do not have these problems if we treat the operations as operations,
rather than try to deduce them from pairs of formats. That's always
been one of the problems with Mule: it insists on doing conversions
that you don't want and don't know about until your data is corrupted.
I don't see how we can avoid that if we try to work in terms of
formats rather than operations.
--
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Institute of Policy and Planning Sciences Tel/fax: +81 (298) 53-5091
_________________ _________________ _________________ _________________
What are those straight lines for? "XEmacs rules."