Path: utzoo!utgpu!water!watmath!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!fons From: fons@cs.vu.nl (Fons Botman) Newsgroups: gnu.emacs.bug Subject: Re: "format" function suggestion Message-ID: <1534@draak.cs.vu.nl> Date: 16 Oct 88 18:23:38 GMT References: <8810050713.AA02552@wheat-chex.ai.mit.edu> <2977@mipos3.intel.com> Reply-To: fons@cs.vu.nl (Fons Botman) Distribution: gnu Organization: VU Informatica, Amsterdam Lines: 42 In article <2977@mipos3.intel.com> merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes: >In article <8810050713.AA02552@wheat-chex.ai.mit.edu>, phr@WHEATIES (Paul Rubin) writes: >| I suggest a new conversion spec, "%g" perhaps (after >| G format in Fortran), to convert any object to its >| printed form like prin1-to-string. >| Also (nitpick) format's doc str does not describe %o or %x. > >And, as 18 people around the world are probably also typing in an >answer to say, > (format "%s" val) >is identical to > (format "%s" (prin1-to-string val)) >because of some very handy undocumented feature. I found this one the >hard way. >-- >Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 And, as 18 people around the world are probably also typing in an answer to say, (format "%s" (prin1-to-string 'a\ b)) "a\\ b" (format "%s" 'a\ b) "a b" (format "%s" (prin1-to-string '(a\ b))) "(a\\ b)" (format "%s" '(a\ b)) "(a\\ b)" So the identity mentioned is not always true. But because of the difference between "princ" and "print" i agree with the original poster that there should be an extra format to distinguish between princ and prin1 conversion. An extra format character is nicer than using prin1-to-string and princ-to-string (also because the latter does not exist :-). It would be nice to have the same specifiers as common lisp, i do not relate to fortran. CL uses ~s for prin1 and ~a for princ, but then the original definition should be switched: %s now behaves as ~a (considering the documentation and code, not the 'feature') which would involve a lot of replacing in old lisp code. So the choice is to the one who implements it (isn't it always? :-). The Fons