Common-Lisp printing the tab character in function format
Asked Answered
M

1

13

I wish to print the tab character with the format function. I can achieve this with ~C and then placing #\tab as an argument to format, but this seems a bit verbose as for a newline one can simply place a ~% in the string.

  • What is the most commonly used practise for printing tabs with the format function?

Thanks for all the help!

Mcgrath answered 10/5, 2014 at 4:47 Comment(1)
I suppose, then, you don't want to just put a literal tab into the format string, itself?Toastmaster
Q
13

There is no notation for the tab character in FORMAT.

There are several choices, but none is really really good.

  • use #\tab (or a variable set to the character) as the argument, as you mention, is okay for me

  • embed a literal tab character in the string. This may break with some editor settings, where the editor replaces tabs with spaces. It's also not directly visible.

  • use a function in a format string, which writes a tab character

  • use a reader macro to introduce extended string syntax. Probably not bad. Maybe there exists even one. There was a post on comp.lang.lisp with an example.

Quincey answered 10/5, 2014 at 7:25 Comment(1)
For more info, these options are covered here groups.google.com/g/comp.lang.lisp/c/Ac_FqxHKdnAWalther

© 2022 - 2024 — McMap. All rights reserved.