Lisp HUG Maillist Archive

Delivering with FORMAT and Pretty Printing

Hi!

I am trying to deliver a program that uses the pretty printer and the
FORMAT directive ~_.

So, this is how I call DELIVER:

; Hack to get xp-fancyformat loaded

(format t "bla~_foo")

(deliver 'main "foo" 5 :keep-conditions :all
         :keep-clos-object-printing t
         :format t
         :keep-pretty-printer t)

However, when I run the delivered program, I get an error when the
delivered program is run:

Unrecognized format directive ~_

no matter what I try.  How can I use ~_ in delivered applications?

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Re: Delivering with FORMAT and Pretty Printing

Nils Goesche <cartan@cartan.de> writes:

> Hi!
> 
> I am trying to deliver a program that uses the pretty printer and the
> FORMAT directive ~_.
> 
> So, this is how I call DELIVER:
> 
> ; Hack to get xp-fancyformat loaded
> 
> (format t "bla~_foo")
> 
> (deliver 'main "foo" 5 :keep-conditions :all
>          :keep-clos-object-printing t
>          :format t
>          :keep-pretty-printer t)
> 
> However, when I run the delivered program, I get an error when the
> delivered program is run:
> 
> Unrecognized format directive ~_
> 
> no matter what I try.  How can I use ~_ in delivered applications?

Does using

  :keep-eval t

help?

Edi.


Re: Delivering with FORMAT and Pretty Printing

Unable to parse email body. Email id is 934

Re: Delivering with FORMAT and Pretty Printing

David Fox <davef@xanalys.com> writes:

>    I am trying to deliver a program that uses the pretty printer and the
>    FORMAT directive ~_.
> 
> You can use FORMATTER to compile the format function before delivery:
> 
> ----------------------------------------------------------------------
> (load-all-patches)
> 
> (require "formatter")
> 
> (compile 
>  (defun main () 
>   (funcall (formatter "bla~_foo") *standard-output*)
>   (force-output)))
> 
> (deliver 'main "foo" 5 :keep-conditions :all
>           :keep-clos-object-printing t
>           :format t
>           :keep-pretty-printer t)
> 
> (quit)
> ----------------------------------------------------------------------
> 
> 
> An alternative workaround is to pass these delivery keywords, which
> allow the format ~_ function to be compiled at runtime:
> 
> :redefine-compiler-p nil
> :keep-macros t

Thanks for your reply.  Now I use

(define-compiler-macro format (&whole form stream fmt &rest args)
  (if (stringp fmt)
      `(funcall (formatter ,fmt) ,(if (eq stream t)
                                      '*standard-output*
                                    stream)
                ,@args)
    form))

and this seems to work fine so far.

Regards,
-- 
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x0655CFA0


Re: Delivering with FORMAT and Pretty Printing

* David Fox wrote:
> You can use FORMATTER to compile the format function before delivery:

I didn't realize that FORMATTER did anything non-trivial in LW, but it
does - cool! I'd only tried it on things like "~A" where it really
only does the minimal thing.  Does using it cause all the XP-derived
things to be compiled into function calls (and thus remove the nasty
unfindable calls to functions that format strings have)?

--tim




Re: Delivering with FORMAT and Pretty Printing

Tim Bradshaw <tfb@cley.com> writes:

> * David Fox wrote:
> > You can use FORMATTER to compile the format function before delivery:
> 
> I didn't realize that FORMATTER did anything non-trivial in LW, but it
> does - cool! I'd only tried it on things like "~A" where it really
> only does the minimal thing.  Does using it cause all the XP-derived
> things to be compiled into function calls (and thus remove the nasty
> unfindable calls to functions that format strings have)?

Er, cough, cough - what does XP mean here?

Thanks,
Edi.


Re: Delivering with FORMAT and Pretty Printing

* Edi Weitz wrote:

> Er, cough, cough - what does XP mean here?

Well, I think the LW pretty printer is derived from XP (which was the
implementation which gave rise to the pretty printer stuff in the
standard, see issue 270).

At least, if you evaluate (FORMATTER "~_") it looks that way.

(I assume most other implementations' pretty printers are XP-derived).

--tim




Updated at: 2020-12-10 09:00 UTC