From: DaveNlp
Subject: [newbie] nice function like princ
Date: 
Message-ID: <%FZbb.340454$Ny5.10846598@twister2.libero.it>
I have made this function:

(DEFUN PRINCC (&rest params)
    (DOLIST (sym params)
        (IF (EQ sym T) (TERPRI) (PRINC sym))))

It's small and easy to use. :)
It permits multiple arguments.
You can use (format..) within its arguments.
Some examples of the current syntax:

(princc "The sum of 2*8 is " (* 2 8) "." T)
(princc "The sum of 2*8 is: " T (format nil "~A~A~%" (* 2 8) "."))
(princc T "This function permits to use more arguments." T T)
(princc T "This function permits to " (prin1-to-string "use") " more arguments." T T)

Comments welcomed. :)

greetings
DaveNlp

From: Robert P. Goldman
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <3f706f21$0$1103$5cbedd26@news.real-time.com>
DaveNlp wrote:
> I have made this function:
> 
> (DEFUN PRINCC (&rest params)
>     (DOLIST (sym params)
>         (IF (EQ sym T) (TERPRI) (PRINC sym))))
> 
> It's small and easy to use. :)
> It permits multiple arguments.
> You can use (format..) within its arguments.
> Some examples of the current syntax:
> 
> (princc "The sum of 2*8 is " (* 2 8) "." T)
> (princc "The sum of 2*8 is: " T (format nil "~A~A~%" (* 2 8) "."))
> (princc T "This function permits to use more arguments." T T)
> (princc T "This function permits to " (prin1-to-string "use") " more arguments." T T)
> 
> Comments welcomed. :)
> 
> greetings
> DaveNlp
> 
> 
> 
I don't mean to just criticize, but why do you want to do this instead 
of just using format?
From: DaveNlp
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <Bq%bb.340791$Ny5.10855470@twister2.libero.it>
"Robert P. Goldman" <···@nospam.real-time.com> ha scritto nel messaggio ·····························@news.real-time.com...
> DaveNlp wrote:
> > I have made this function:
> > 
> > (DEFUN PRINCC (&rest params)
> >     (DOLIST (sym params)
> >         (IF (EQ sym T) (TERPRI) (PRINC sym))))
> > 
> > It's small and easy to use. :)
> > It permits multiple arguments.
> > You can use (format..) within its arguments.
> > Some examples of the current syntax:
> > 
> > (princc "The sum of 2+8 is " (+ 2 8) "." T)
> > (princc "The sum of 2+8 is: " T (format nil "~A~A~%" (+ 2 8) "."))
> > (princc T "This function permits to use more arguments." T T)
> > (princc T "This function permits to " (prin1-to-string "use") " more arguments." T T)
> > 
> > Comments welcomed. :)
> > 
> > greetings
> > DaveNlp
> > 
> > 
> > 
> I don't mean to just criticize, but why do you want to do this instead 
> of just using format?

To simplify the building of a program that writes the programs alone. ;)
To avoid the writing and rewriting of "format-string" when I must change it.
With "princc" I must change only the arguments 
while with (format) I must change the arguments and the "format-string".
However I use (princc) only with few lines of text.

Greetings.
DaveNlp
From: Jock Cooper
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <m33cenxei1.fsf@jcooper02.sagepub.com>
"DaveNlp" <(NOSPAM)·········@iol.it> writes:

> "Robert P. Goldman" <···@nospam.real-time.com> ha scritto nel messaggio ·····························@news.real-time.com...
> > DaveNlp wrote:
> > > I have made this function:
> > > 
> > > (DEFUN PRINCC (&rest params)
> > >     (DOLIST (sym params)
> > >         (IF (EQ sym T) (TERPRI) (PRINC sym))))
> > > 
> > > It's small and easy to use. :)
> > > It permits multiple arguments.
> > > You can use (format..) within its arguments.
> > > Some examples of the current syntax:
> > > 
> > > (princc "The sum of 2+8 is " (+ 2 8) "." T)
> > > (princc "The sum of 2+8 is: " T (format nil "~A~A~%" (+ 2 8) "."))
> > > (princc T "This function permits to use more arguments." T T)
> > > (princc T "This function permits to " (prin1-to-string "use") " more arguments." T T)
> > > 
> > > Comments welcomed. :)
> > > 
> > > greetings
> > > DaveNlp
> > > 
> > > 
> > > 
> > I don't mean to just criticize, but why do you want to do this instead 
> > of just using format?
> 
> To simplify the building of a program that writes the programs alone. ;)
> To avoid the writing and rewriting of "format-string" when I must change it.
> With "princc" I must change only the arguments 
> while with (format) I must change the arguments and the "format-string".
> However I use (princc) only with few lines of text.
> 

If you don't mind using nil instead of t to cause a newline, you could do:

(format t ··@{~:[~%~;~:*~a~]~}" "This function permits to " (prin1-to-string "use") 
        " more arguments." nil nil)
From: DaveNlp
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <NDmcb.344901$lK4.11023676@twister1.libero.it>
"Jock Cooper" <·····@mail.com> ha scritto nel messaggio
···················@jcooper02.sagepub.com...
>
> If you don't mind using nil instead of t to cause a newline, you could
do:
>
> (format t ··@{~:[~%~;~:*~a~]~}" "This function permits to "
(prin1-to-string "use")
>         " more arguments." nil nil)

I didn't think that "format" was so powerful.. o_O

Thank you.
DaveNlp.
From: Avi Blackmore
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <7c1401ca.0309252228.1862fe1d@posting.google.com>
"DaveNlp" <(NOSPAM)·········@iol.it> wrote in message news:<·························@twister1.libero.it>...
>
> I didn't think that "format" was so powerful.. o_O

   Boy, are you in for a surprise. :-)  FORMAT directives can, among
other things, loop, conditionally dispatch on other format directives,
do recursive FORMAT calls, etc.  It's almost a language in its own
right.  One I have very little ability with, myself; kinda inscrutable
for me.  But I know there are some "FORMAT wizards" who can embed an
entire program in a single FORMAT string, provided that the program is
designed to do output of some kind, or return a string.

   Me, I just use FORMAT for relatively simple output.  I've never had
cause to try and wrap my brain around the looping or conditional
directives, much less recursive calls to FORMAT.

   It does figure, though, that CL would provide a Turing-complete
language for something that most other languages would only use simple
pattern-matching for.  :-)  Errr...is FORMAT Turing-complete?  I mean,
it kinda looks like it would be, but I haven't done a formal proof or
anything....

 
> Thank you.
> DaveNlp.

Hope this helps, or at least amuses.
Avi Blackmore

(defconstant +eternal-newbie+ "Avi Blackmore")
From: Tage Stabell-Kulo
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <bl0n2g$26es$1@news.uit.no>
········@cableone.net (Avi Blackmore) writes:

>"DaveNlp" <(NOSPAM)·········@iol.it> wrote in message news:<·························@twister1.libero.it>...

>> I didn't think that "format" was so powerful.. o_O

>   Boy, are you in for a surprise. :-)  FORMAT directives can, among
>other things, loop, conditionally dispatch on other format directives,
>do recursive FORMAT calls, etc.  It's almost a language in its own
>right.


Why do you use the term "almost"?  This is not meant as a retoric
question.

 [····@/\\]


-- 
////       Tage Stabell-Kuloe        |e-mail: Tage at ACM.org (···@)////
///Department of Computer Science/IMR|Phone : +47-776-44032         ///
//9037  University of Tromsoe, Norway|Fax   : +47-776-44580         //
/      "'oe' is '\o' in TeX"         |URL:http://www.cs.uit.no/~tage/
From: Joe Marshall
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <oex7puoj.fsf@ccs.neu.edu>
········@cableone.net (Avi Blackmore) writes:

> Errr...is FORMAT Turing-complete?  I mean,
> it kinda looks like it would be, but I haven't done a formal proof or
> anything....

I remember that FORMAT in CLtL 1 was just shy of being turing
complete, but I haven't bothered to try to prove it for CLtL 2.

The FORMAT string itself allows for a very complicated state machine,
but unless you have something isomorphic to a writable `tape', you
won't be turing complete.  (Another approach would be to use ~? to
reflect your state.  This might allow you to use the `stack' of pending
formats as a tape, but I'm not sure.)
  
From: Thomas F. Burdick
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <xcv7k3vs3vy.fsf@famine.OCF.Berkeley.EDU>
Joe Marshall <···@ccs.neu.edu> writes:

> ········@cableone.net (Avi Blackmore) writes:
> 
> > Errr...is FORMAT Turing-complete?  I mean,
> > it kinda looks like it would be, but I haven't done a formal proof or
> > anything....
> 
> I remember that FORMAT in CLtL 1 was just shy of being turing
> complete, but I haven't bothered to try to prove it for CLtL 2.

Lots of only-kind-of mathy-minded people prove or don't prove things
to be equivalent to a Turing machine ... when something's not
Turing-equivalent, true CS-freaks determine the exact type of
automoton it's equivalent to :)

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: ·············@comcast.net
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <oex460go.fsf@comcast.net>
···@famine.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> Joe Marshall <···@ccs.neu.edu> writes:
>
>> ········@cableone.net (Avi Blackmore) writes:
>> 
>> > Errr...is FORMAT Turing-complete?  I mean,
>> > it kinda looks like it would be, but I haven't done a formal proof or
>> > anything....
>> 
>> I remember that FORMAT in CLtL 1 was just shy of being turing
>> complete, but I haven't bothered to try to prove it for CLtL 2.
>
> Lots of only-kind-of mathy-minded people prove or don't prove things
> to be equivalent to a Turing machine ... when something's not
> Turing-equivalent, true CS-freaks determine the exact type of
> automoton it's equivalent to :)

Since you don't supply a solution either, I guess that rules out
both of us.
From: Thomas F. Burdick
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <xcvad8oyxw3.fsf@famine.OCF.Berkeley.EDU>
·············@comcast.net writes:

> ···@famine.OCF.Berkeley.EDU (Thomas F. Burdick) writes:
> 
> > Joe Marshall <···@ccs.neu.edu> writes:
> >
> >> ········@cableone.net (Avi Blackmore) writes:
> >> 
> >> > Errr...is FORMAT Turing-complete?  I mean,
> >> > it kinda looks like it would be, but I haven't done a formal proof or
> >> > anything....
> >> 
> >> I remember that FORMAT in CLtL 1 was just shy of being turing
> >> complete, but I haven't bothered to try to prove it for CLtL 2.
> >
> > Lots of only-kind-of mathy-minded people prove or don't prove things
> > to be equivalent to a Turing machine ... when something's not
> > Turing-equivalent, true CS-freaks determine the exact type of
> > automoton it's equivalent to :)
> 
> Since you don't supply a solution either, I guess that rules out
> both of us.

Pretty much :-).  I'm capable of being a freak, but not without the
aid of a book or two.  Wow, don't quote me out of context on that one!

For something like FORMAT, it might be more fun to see if it's
lambda-calculus-equivalent.

(Anyone at ILC, feel free to ask me if I figured this out on the trip
from Cali)

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Adam Warner
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <pan.2003.09.26.06.54.10.866838@consulting.net.nz>
Hi Avi Blackmore,

>> I didn't think that "format" was so powerful.. o_O
> 
>    Boy, are you in for a surprise. :-)  FORMAT directives can, among
> other things, loop, conditionally dispatch on other format directives,
> do recursive FORMAT calls, etc.  It's almost a language in its own
> right.  One I have very little ability with, myself; kinda inscrutable
> for me.  But I know there are some "FORMAT wizards" who can embed an
> entire program in a single FORMAT string, provided that the program is
> designed to do output of some kind, or return a string.

This creative use of format is a delight:
<http://99-bottles-of-beer.ls-la.net/c.html#Common-Lisp-(format-string)>

Regards,
Adam
From: Drew McDermott
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <bktsj8$c76$1@news.wss.yale.edu>
Robert P. Goldman wrote:

>>
> I don't mean to just criticize, but why do you want to do this instead 
> of just using format?
> 

Possibly because 'format' is so ugly.  (A polemic about this may be 
found at http://cs-www.cs.yale.edu/homes/dvm/format-stinks.html .)

The MSG macro invented at UCI many years ago is along the lines that Mr. 
  DaveNip proposed (right down to the use of T to mean "newline").  A 
descendant of MSG (called 'OUT'), with many bells and whistles, may be 
found in the YTools package (written by me), which is available at CLOCC 
(http://clocc.sourceforge.net/).  'OUT' is documented in the YTools 
manual, which is included in the download, or can be viewed separately 
at http://cs-www.cs.yale.edu/homes/dvm/papers/ytdoc.pdf .

    -- Drew McDermott
From: DaveNlp
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <X7Acb.345859$Ny5.11011980@twister2.libero.it>
"Drew McDermott" <··················@at.yale.dot.edu> ha scritto nel

>   DaveNip proposed (right down to the use of T to mean "newline").  A
> descendant of MSG (called 'OUT'), with many bells and whistles, may be
> found in the YTools package (written by me), which is available at
CLOCC
> (http://clocc.sourceforge.net/).  'OUT' is documented in the YTools
> manual, which is included in the download, or can be viewed separately
> at http://cs-www.cs.yale.edu/homes/dvm/papers/ytdoc.pdf .
>
>     -- Drew McDermott

I've read the YTools document quickly because I'm newbie in Lisp.
My impression is that YTools is a wonderful work :)
but is not much alike to Lisp according to my concept of Lisp.
My concept of Lisp is that one to write less possible.

Best regards.
DavdeNlp.
From: Drew McDermott
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <bkupki$mrj$1@news.wss.yale.edu>
DaveNlp wrote:

> My impression is that YTools is a wonderful work :)
> but is not much alike to Lisp according to my concept of Lisp.

That's the beauty of Lisp; it's not much alike even to itself.

> My concept of Lisp is that one to write less possible.

All the Zen masters agree.

     -- Drew McDermott
From: DaveNlp
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <qH_bb.340674$Ny5.10850964@twister2.libero.it>
----- Original Message ----- 
From: "DaveNlp" <(NOSPAM)·········@iol.it>

ERRATA CORRIGE of my post, sorry!!!

>(princc "The sum of 2*8 is " (* 2 8) "." T)

I have made a serious error of mathematics, 
you pardon to me!   ;))

(princc "The sum of 2+8 is " (+ 2 8) "." T)

Today they are a little careless one.. :P

bye
DaveNlp
From: Alan S. Crowe
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <868yobg9gp.fsf@cawtech.freeserve.co.uk>
I like it. I write a lot of format strings that only use ~A,
so the process of matching the A's to arguments is a wasted
effort.

My brain was destroyed by writing PASCAL in the early
80's. I'm stuck with the mentality of suffering what the
program language designer imposed. Your little function is a
valuable reminder that if I don't like something in Lisp it
is easy to write my own version

I was baffled that 

(princc "The sum of 2*8 is: " T (format nil "~A~A~%" (* 2 8) "."))

works. Surely format gets run when the arguments are
evaluated, so 16 gets printed out first. 
Then I spotted what I was missing. It is 

(princc "The sum of 2*8 is: " T (format t "~A~A~%" (* 2 8) "."))

that doesn't work :-)

Alan Crowe
Edinburgh
Scotland
From: DaveNlp
Subject: Re: [newbie] nice function like princ
Date: 
Message-ID: <IIXcb.349780$lK4.11176564@twister1.libero.it>
"Alan S. Crowe" <····@cawtech.freeserve.co.uk> ha scritto nel messaggio

> (princc "The sum of 2+8 is: " T (format t "~A~A~%" (+ 2 8) "."))
>
> that doesn't work :-)
>

Probably in Lisp this problem can be solved
however I never do not use (princc) with to (format). ;-)

Greetings.
DaveNlp