From: Eduardo O. <edu...@gm...> - 2025-05-18 07:42:07
|
How do I use "~m"? Here's what I tried (on a very recent SBCL Maxima): format([args]) := apply(?format, append([false], args)); o : a^"b"; format("~a", o); /* ((MEXPT SIMP) $A b) */ format("~s", o); /* ((MEXPT SIMP) $A "b") */ format("~m", o); /* Unknown format directive */ Thanks in advance! Eduardo On Sat, 17 May 2025 at 16:32, Robert Dodier <rob...@gm...> wrote: > Maxima's printf has a lot of great things going for it, mostly > inherited from Common Lisp FORMAT. > > As wonderful as it is, FORMAT doesn't provide a way to define new > format directives or redefine existing ones. At present the > Maxima-specific directives (~h for bigfloat, ~m for 2-d pretty printer > output) and redefined directives (~a and ~s for 1-d output) are > implemented by effectively reimplementing some large part of FORMAT, > in particular the stuff for looping. > > I have wondered about how to handle printf in a neater way, mostly > with the goal of fixing bugs, although it's not out of the question to > make it simpler to define or redefine additional directives. > > I wonder if it's thinkable to start with an existing FORMAT > implementation and then bolt on the Maxima-specific bits. I haven't > investigated. Or we could take a second look at the existing printf > code and see if the looping stuff could be revised. > > At this point I'm interested to hear comments about this stuff at a > high level -- we can work out details if we can arrive at a workable > plan. > > FWIW & all the best. > > Robert > > |