Talk:LSL Style Guide

From Second Life Wiki
Revision as of 07:37, 15 April 2009 by Psistorm Ikura (talk | contribs)
Jump to navigation Jump to search

Script Formatting

Ive recently looked more at ways to keep SL scripts easily readable, and I found that good formatting can be a very positive influence on readability. Would it be worthwhile to advertise it? basic example: <lsl>integer number = 14; string something = "test";</lsl> and instead, with formatting: <lsl>integer number = 14; string something = "test";</lsl> I personally find this a lot faster to take in, and this might be good to pick up for the wiki, possibly making the code pieces here easier readable for the beginning scripter. especially the article on variables has a block of definitions right at the start, for example, which is a bit confusing to read, but significantly improved by formatting - compare to earlier versions, I went and formatted the text, which, imho, greatly helped readability in that particular case. feel free to revert if theres issues, I consider it a good improvement however, and wouldnt mind bringing more articles to that kind of formatting style if its approved on. its a thought i wanted to throw in here, and might improve the experience for the readers in general.

Psistorm Ikura 15:28, 15 April 2009 (UTC)


Script Structure

Mandating event order seems a little retentive to me. I don't think any scripter who is going to post code onto the wiki is going to be keen on rewriting their code to fit the pattern. Being flexible to other scripters styles is a key to success (especially with regards to collaborative projects). They should be grouped in a fashion that makes sense to the script and scripter. Seeing as this section is going to be a hot topic, maybe it shouldn't be included or make it very short? Strife Onizuka 22:29, 14 February 2007 (PST)

I agree that mandating event order would be a pain in the ass.
I personally put events in the order they're first used throughout the process of a script's life cycle.
If a Resident is learning to script from a mentor or teacher, they're likely to be using snippets of code they're sent in-world. For them to see a different structure in LSL Library code would be confusing
SignpostMarv Martin 05:44, 15 February 2007 (PST)

Re: General Guidelines

Would suggest that the virtues of the second style shown be amended. Saving space is a pointless exercise if LSL code is truly compiled rather than interpreted. The overhead needed to compile a few extra carriage returns has to be trivial in all but the most monumentally huge scripts.

Second virtue of the "parallel brackets" style (the second type shown) is that the nesting of logical modules is far more clear, and is effectively a form of self-documentation that is often more effective than text comments, especially when code is likely to be rewritten, revised or adapted to another purpose by individuals other than the original author. It can even help the original author understand her own code better, faster, if she is returning to a bit of code written in the relatively dim past.

Would take a shot at saying this more concisely, but first want to see if there are other views that should also be reflected in any revision to the text.

This is my first contribution here. Please forgive any unintentional breeches of protocol and etiquette. --Azadine Umarov 17:49, 7 May 2007 (PDT)

Good comment. Bracketing style is an old debate in programing (20 years at least). Both styles have their advantages as long as the scripter is consistent with the style they pick. The key in programing is consistency in style, not so much what the style is. -- Strife Onizuka 12:11, 8 May 2007 (PDT)
I wonder if we should just show the two ways of bracketing and let the readers decide which to use, with out giving any description of which one is "Better", even though everyone knows the brackets go on the same line as the code. ;P Xaviar Czervik