Basic Print Commands

Jun 10, 2007 13:42

Sorry for posting this here, but finding an active community regarding the programming side of S2 is proving to be a bit difficult ( Read more... )

Leave a comment

Comments 4

pinterface June 10 2007, 18:36:02 UTC

Don't worry about print "foo"; vs. "foo";. They're supposed to do the same thing; which you use is a matter of personal preference.

To quote mart, from many years ago "print safe is used to force an untrusted print from a trusted layer. This is no different to print in an untrusted layer (which is essentially anything non-system), but in core and the system layers, where everything is trusted by default, it is used to force a little bit through the HTML cleaner." User layers are untrusted, so all prints are "safe" (e.g., no JavaScript).

Reply

mighty_gratira June 10 2007, 21:01:25 UTC
I am assuming I won't have any use for print safe then, unless I find some sort of problem. Thank you for the clarification!

Reply


mart June 11 2007, 18:49:48 UTC

Leaving out the print keyword is just a shorthand. If the compiler encounters a statement that starts with a string literal (and maybe a few other cases too; I'm not sure) it just assumes you wanted to do a print.

It's up to you whether you want to use it. Most of the time you probably want println anyway, since otherwise you end up with unreadable, obnoxious HTML output that's all on one line and a real pain to debug.

Reply

mighty_gratira June 11 2007, 23:32:15 UTC
Okie dokie, thanks. I obsessed with readable HTML, so I end up using a ton of \n's. I should probably try to use println more often, rather than trying to shove everything between functions into one print command... *guilty look*

Reply


Leave a comment

Up