[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] format-modular feature request: defining one's own m
From: |
Kon Lovett |
Subject: |
Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats |
Date: |
Fri, 7 Mar 2008 13:39:02 -0800 |
On Mar 7, 2008, at 1:16 PM, Robin Lee Powell wrote:
On Fri, Mar 07, 2008 at 01:12:06PM -0800, Kon Lovett wrote:
On Mar 7, 2008, at 9:08 AM, Robin Lee Powell wrote:
I'd like to define my own %[...%] sort of formatter using
format-modular, but it seems to be impossible without copying most
of the egg into my own code! Could this be added as a general
feature?
No quite sure what you mean. Is '%' to be the escape character,
instead of '~'? This is possible but you would need to override
the "*formatter-cond*" to provide new semantics. And all format
codes would need to use '%' as the escape.
Or are you asking for a user defined multi-character escape+code
sequence that would coexist with the default escape+code
sequences? I suppose this could be done but would require some
surgery.
I don't think I'm asking for either of those, but I'm not sure.
I'm asking how to do before-and-after escape sequences, like
~[...~] or ~(...~), but with my own code behind them.
You can override the existing semantics by supplying your own
procedures. However access to the state object is very restricted to
the public. So not all functionality that the *formatter-foo* provide
can be reproduced by an external formatter. And the public cannot
extend the state object, which might be necessary to implement own
"before-and-after escape sequences".
But that doesn't mean you cannot override the existing semantics. You
just cannot do everything.
(define (formatter-open state start params colon atsign)
... )
(define (formatter-close state start params colon atsign)
... )
(define *my-caseconv*
`((#\( ,(formatter-function formatter-open))
(#\) ,(formatter-function formatter-close))))
(define *formatter-mine*
`(,*formatter-flush*
,*formatter-plural*
,*formatter-tabulate*
,*formatter-params*
,*formatter-iteration*
,*my-caseconv*
,*formatter-chars*
,*formatter-numbers*
,*formatter-cond*
,*formatter-indirection*
,*formatter-jump*
,*formatter-objs*
,*formatter-version*))
(define extd-format (make-format-function #f #\~ *formatter-mine*))
-Robin
--
Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo
Proud Supporter of the Singularity Institute - http://singinst.org/
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users
Best Wishes,
Kon
- [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/07
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Kon Lovett, 2008/03/07
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/07
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats,
Kon Lovett <=
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/07
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/07
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Kon Lovett, 2008/03/08
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/08
- Re: [Chicken-users] format-modular feature request: defining one's own multi-part formats, Robin Lee Powell, 2008/03/08