Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

GCC has this also; this work is different because it removes the type errors. Instead of having an error like "%d expects a parameter of type int, not char ", it just lets %d print the string anyway. It's more like format* in Lisp, say:

  [1]> (format t "~05,'0d" 5)
  00005
  NIL
  [2]> (format t "~05,'0d" "abc")
  00abc
  NIL
Here ~d (decimal) doesn't care that it didn't get an integer.


For D's formatted write function, %s means "I don't care what type it is, just do the write thing with it" which works fine for nearly all uses.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: