Common-Lisp printing the tab character in function format

此生再无相见时 提交于 2019-12-08 17:18:45

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/23577195/common-lisp-printing-the-tab-character-in-function-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!