chicken-users
[Top][All Lists]
Advanced

[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:12:06 -0800


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.

For now the recommended method is to pick some unused escape sequence and define your own formatter function. These are reserved: ?!{}^()%/ ~|_[;]*$&<>IASCRFEQGTYPXDOBK@:V#',+-0123456789
but `.HJLMNUWZ are available.

Unfortunately there wasn't an exported procedure to acquire an argument - this has been fixed with the '*formatter-next-argument' procedure in the 1.8 release/3.

(define (formatter-mine state start params colon atsign)
(let-optionals params ((foo 1) (bar #f)) ; these are the parsed parameter values, ex.
    (let ((obj (*formatter-next-argument state)))
      (*formatter-out-string state (with-foobar obj foo bar)) ) ) )

(define *my-formatter* `((#\Z ,(formatter-function formatter-mine))))

(define extd-format (make-format-function #f #\~ (cons *my-formatter* *formatter-cl*)))


Thanks.

-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






reply via email to

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