Lisp HUG Maillist Archive

REPL output.

Hi,

Is there away to limit (customize) the output (printing) of large
objects (i.e: big strings, lists, sequences) during the Print part of
REPL in the Listener.

In other words, rather than printing the whole sequnce, just print a
*default-printing-length* and then print '....' indicating that there
are extra elements in the sequence, not displayed. (where I can use
the Inspector If needed)

Regards,

Ala'a


Re: REPL output.

Ala'a,

Please see the parameter values listed for PRINT in the CLHS.

http://www.lispworks.com/documentation/HyperSpec/Body/f_wr_pr.htm

Regards,

Tom
----------------------------------------------------------------
Thomas M. Hermann
Odonata Research LLC
http://www.odonata-research.com/
http://www.linkedin.com/in/thomasmhermann


On Thu, Jun 2, 2011 at 12:35 PM, Ala'a Mohammad <amalawi@gmail.com> wrote:

Hi,

Is there away to limit (customize) the output (printing) of large
objects (i.e: big strings, lists, sequences) during the Print part of
REPL in the Listener.

In other words, rather than printing the whole sequnce, just print a
*default-printing-length* and then print '....' indicating that there
are extra elements in the sequence, not displayed. (where I can use
the Inspector If needed)

Regards,

Ala'a


Re: REPL output.

Thanks.

With *print-string*, the following will do it in the moment (taking
care to evaluate them in order, since we are playing with a system
call):

(defparameter *abbreviate-long-strings* nil)

(defparameter *max-length-printed-for-strings* 100)

(defadvice
    ((method print-object (string t))
     before-print-object-for-string :before)
    (obj stream)
  (if (> (length obj) *max-length-printed-for-strings*)
    (setf *abbreviate-long-strings* *print-string*
           *print-string* *max-length-printed-for-strings*)))

(defadvice
    ((method print-object (string t))
     after-print-object-for-string :after)
    (obj stream)
  (if *abbreviate-long-strings*
    (setf *print-string* *abbreviate-long-strings*
           *abbreviate-long-strings* nil)))

Thanks again,

Regards,

Ala'a.

On Fri, Jun 3, 2011 at 3:18 PM, Martin Simmons <martin@lispworks.com> wrote:
>
>>>>>> On Fri, 3 Jun 2011 14:36:21 +0400, Ala'a Mohammad said:
>>
>> Thanks for the pointer.
>>
>> *print-length* does not limit the size of a printed string.
>> *print-array* applies to non-string array
>>
>> Currently I need something like *print-length but which applies to
>> strings (or sequences in general).
>
> There is a currently undocumented variable hcl:*print-string* that controls
> whether the printer uses an abbreviated form for strings when *print-escape*
> is true.
>
> If *print-string* is t (the default), then strings are printed in full as
> specified by ANSI Common Lisp.
>
> If *print-string* is nil, then strings are printed as an unreadable object
> with no specific information about the string.
>
> If *print-string* is an integer, then strings longer than *print-string* are
> printed as unreadable objects that include the type, length and first
> *print-string* characters.
>
> We will add this to the documentation.
>
> --
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
>
>


Re: REPL output.

Unable to parse email body. Email id is 11049

Updated at: 2020-12-10 08:37 UTC