Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

While Loop bug?

Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-21-2008 20:21
in my little lua circle we have the following all the fime

while true do
blhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
if blhablahblahblahblahblahblahblahvblhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblah
blhablahblahblahblahblahblahblahblhablahblahblahblahblahblahblah end

"wheres my error?"

finding your style and sticking with it helps out a freakin ton

me i dont like the
if(stuff){
}

makes it hard for me to see where blocks actually start and end

i do the

if(stuff)
{
}

routine

but it doesnt matter, as long as its consistent 100%

and eventho im often cussed for my particular brand of screwed up coding, ive never had someone (who knows the system) say they didnt understand what was going on, or they couldnt follow it

it just might take them a couple of min to comprehend whats going on heh
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-21-2008 20:40
From: Osgeld Barmy
me i dont like the
if(stuff){
}

makes it hard for me to see where blocks actually start and end

i do the

if(stuff)
{
}

routine

You don't like K&R? Well hell! I want my cookie back now! :p

This is why I have mine set up to take any junk including the noobie stuff here, paste it into Scite, hit F8, which runs it through the C compiler/indent/white space stripper and see it how God (who I should point out is female) intended code to be written within about 2 seconds :D

But then again, I have been wrong before(not about God being female though)!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-21-2008 20:55
its just me

the if(stuff){

to me is like a run on sentence

or playing wheres waldo

i want a block title

if (stuff)

and the contents of it below

not

if(){ljhrljhfjlhfdjashksdhskdalskjdlskadjskdjsalkdjlsdjlasdjlasdjsladjlsakdj
sdlfkdlfjhdjfhdkfshdfklfheuwyquidkjdsahdkjasdhuadhkaudkejdahkjdhuaed
asldkhaljdhuaedhaedhaudkaeduhkealjdhaekldhuahddnqwpeuwqeidsljdhalsjh
aldkhelrirelriyeryfkdfnrjeryry
}

for pages on end, and then play "wheres the missing bracket"

this mainly stems from the oldschool lsl script writers, where they proclaim their uberbness by writing that crap, right after declaring variables like "sixteen = 16" then using 8 math functions in a row that always report the same result every time they are called (take a look at xy chess)

besides
its just easier for ME,
god has to be female, that would explain alot (/me makes sure the wife isnt looking)
and i ate your cookie, it was yummy

so MEH
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-22-2008 01:06
lol thanks for the giggle you two, and I'd like to add my agreement about God... although I'm not sure I can.... on one hand we have pure spite, on the other we have what looks like someone that can't be bothered to check on distant relatives... ok maybe that's mean I suppose I could look at it positively and call it lessons by smacking or non-interference...

speaking of God and programming, both of you would probably appreciate a song called "the eternal flame (AKA God Wrote in LISP code)"... because god likes a language with it's own four letter name
http://www.gnu.org/fun/jokes/eternal-flame.html
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-22-2008 01:24
From: Jesse Barnett
and see it how God (who I should point out is female) intended code to be written within about 2 seconds :D
You have a Lisp <-> LSL compiler?
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
11-22-2008 01:45
From: Jesse Barnett
But then again, I have been wrong before(not about God being female though)!

How do you know this?

BTW there really is only one true way... and this is the lambda calculus (functional rather than imperative programming).

/esc
_____________________
http://slurl.com/secondlife/Together
Tabliopa Underwood
Registered User
Join date: 6 Aug 2007
Posts: 719
11-22-2008 02:07
From: Sindy Tsure
wrote in part ...
True - picking a style and sticking with it is half+ the battle..


True True

Im learning how to script LSL mostly from playing with the examples in the wiki and just about all of it follows the same style. I not have any real-world experience with C-like languages before so it makes it lots easier for me to work stuff out.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-22-2008 02:49
From: Tabliopa Underwood
True True

Im learning how to script LSL mostly from playing with the examples in the wiki and just about all of it follows the same style. I not have any real-world experience with C-like languages before so it makes it lots easier for me to work stuff out.


lsl only really shares formatting with c style languages

playing is the only way to learn a language

and thats a funny song ... i hate lisp
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
11-22-2008 04:38
The second place I worked had very specific coding standards, and since most of their programmers were green they took to them without complaint. Having the whole place agree was really cool, and their standard was very close to my own, so I adopted it easily and still use it twenty years later.

BTW, How do the K&R people handle long lines of code; say, a while statement with three complex conditions on three lines? Where do the second and third lines line up, and where does the while block line up?

CODE

while ( this &&
this_too &&
also_this)
{
// do stuff
}


I indent the 2nd and 3rd condition and the block code to the same level. How do you separate the block from the while conditions if the brace is in the wrong place? :D

You'll have to describe it since I don't have greasemonkey.
_____________________
The Vengeance Studio Gadget Store is closed!

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-22-2008 06:54
From: Anya Ristow
The second place I worked had very specific coding standards, and since most of their programmers were green they took to them without complaint. Having the whole place agree was really cool, and their standard was very close to my own, so I adopted it easily and still use it twenty years later.

BTW, How do the K&R people handle long lines of code; say, a while statement with three complex conditions on three lines? Where do the second and third lines line up, and where does the while block line up?

CODE

while ( this &&
this_too &&
also_this)
{
// do stuff
}


I indent the 2nd and 3rd condition and the block code to the same level. How do you separate the block from the while conditions if the brace is in the wrong place? :D

You'll have to describe it since I don't have greasemonkey.

I was digging around for a site that was very long indeed but showed the different indent schemes and all of thier permutations for C type code. Creator must have changed services though :(
On this one I get lazy sometimes. You can preset it in Indent but setting all of the variables such as break at ,/||/&& is a pain. But in general I TRY to remember to treat the parenthesis the same as brackets in a case like that:
CODE

void foo(
int arg1,
char arg2,
int *arg3,
long arg4,
char arg5
) {


PS just hit the QUOTE key on my post and you will see it formatted correctly for when you don't use GreaseMonkey.

And for people who are interested in trying/comparing different types of indent or just want to clean up code that was posted here, there is a freeware gui for Indent/Beautify:

http://www.milannemec.com/winindent.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-22-2008 07:06
From: Escort DeFarge
How do you know this?

All mammals, both male and female have nipples :rolleyes:
From: Osgeld Barmy
so MEH
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-22-2008 08:07
From: Jesse Barnett
All mammals, both male and female have nipples :rolleyes:

And platypus hatch from eggs. And dinosaurs ruled the earth for millions of years. Bacteria and insects both out number humans. The question of the sex of god is pretty moot when you cannot even determine God's species. Frankly if God were a giant chicken or maybe a spaghetti monster that would be more important to people initially then it's gender. People might reconsider eating meatballs or chicken sandwiches.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
4318723350112047 String
Registered User
Join date: 5 Sep 2008
Posts: 147
11-22-2008 09:22
From: Argent Stonecutter
You have a Lisp <-> LSL compiler?


Yesp
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
11-22-2008 10:35
From: Jesse Barnett
All mammals, both male and female have nipples :rolleyes:

Ahhh - I see you've played this game before ;)
_____________________
http://slurl.com/secondlife/Together
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-22-2008 11:15
From: Anya Ristow
The second place I worked had very specific coding standards, and since most of their programmers were green they took to them without complaint. Having the whole place agree was really cool, and their standard was very close to my own, so I adopted it easily and still use it twenty years later.

BTW, How do the K&R people handle long lines of code; say, a while statement with three complex conditions on three lines? Where do the second and third lines line up, and where does the while block line up?

CODE

while ( this &&
this_too &&
also_this)
{
// do stuff
}
I use modified lisp style, same as I do with functions:

CODE

while (
____this &&
____that &&
____something(else)
) {
____function (
________with,
________a,
________lotOf,
________parameters
____);
}
(underscores are spaces)

In fact I use this style even if I don't need to wrap the lines, where it makes the control flow easier to understand.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-22-2008 11:16
From: Jesse Barnett
All mammals, both male and female have nipples :rolleyes:
Monotremes do not have nipples. The young lick the milk from pores on the inside of the pouch.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-22-2008 11:41
From: Argent Stonecutter
Monotremes do not have nipples. The young lick the milk from pores on the inside of the pouch.

OK I concede cause I don't know what they are and can't even spell monotremes.

Always kind of took fancy to the notion of the stars as having intelligence and the Gods as portrayed by one scif fi writer. Course then you get back to the loop of who created the stars but it still sounds cool.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-22-2008 11:53
did you know platypii (sp?) also have a pair of poisonous spines? or divinty comes with a sense of humor, or somebody said "hey what do we do with these spare parts..."

as for handling long lines, I tend to break then to the same level on the conditionals/concatenators if I need to like so, including for functions
CODE

if (very_long_variable_name
& other_other_long_name_etc){
some_Function( variable_a,
variable_b,
function( something_ to_get_a_result),
worthless_constant );
}


works for me because I read function properties like a list, and operators tell me it's a continuation of the previous line... oddly I don't usually split equivalencies.

but something has to get pretty long before I do that.... oddly I picked that up from writing html where properties could indeed make a line VERY long (before CSS solidified enough to make it much more readable)... that and line continuation characters in VB and a few other languages

From: Argent Stonecutter
You have a Lisp <-> LSL compiler?

want to write one? it'd be seriously crippled, but what the heck
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-22-2008 12:09
From: Jesse Barnett
OK I concede cause I don't know what they are and can't even spell monotremes.

Always kind of took fancy to the notion of the stars as having intelligence and the Gods as portrayed by one scif fi writer. Course then you get back to the loop of who created the stars but it still sounds cool.

monotremes include platypii and echidnas, and while they don't have nipples, they do have mammary glands....

PS they lay eggs, no pouch, marsupials have pouches.. and nipples, and bifuricated genital tracts :: shakes head ::
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-22-2008 12:57
From: Void Singer
PS they lay eggs, no pouch, marsupials have pouches..
You're right, I was mixing up the platypus and the yapok (an aquatic marsupial... and incidentally one in which the males have a pouch, too).
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
11-22-2008 14:38
You guys arguing this should try to grab a consensus within LL. Go and read the client code, where they often have 6 arguments for functions and other large code blocks, and until very recently never even tried to rectify it. :s

The last giant merge into their latest 1.21 code base contained a LARGE number of whitespace changes, which have the general feel of at least containing more consistency rather than less, which is good.
_____________________
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
11-22-2008 17:42
OK I'm confused --- is God a mammal or what?
_____________________
http://slurl.com/secondlife/Together
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
11-22-2008 20:23
http://i197.photobucket.com/albums/aa222/Setian_Sins/God.jpg
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-22-2008 23:39
::looks up 'yapok' ::
huh never knew there were any aquatics in the marsupials, learn something new every day =) looks like a cross between a ferret and and a beaver to me.

and I'm with strife... spaghetti monster gets my vote... although you have to give credit to cthulhu... his worshipers have a few fun quaint sayings, like "my god can eat your god" and "worship now and be eaten last".... then again discordians have the benefit of not having to make any linear sense (frequently not any non-linear sense either)... I suppose that would explain the sticker on my old computer... "hail Eris, all hail discordia" plus that whole "my god is a four letter word" thing =)

Note: I'm not advocating any of those. but to be safe...
http://flickr.com/photos/53577841@N00/174928520/
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
11-22-2008 23:53
From: Argent Stonecutter
CODE

while (something) {
...
}


Instead of:

CODE

while(something)
{
...
}


It makes it REAL clear that you've got surplus semicolons; {

And, no, it doesn't make code hard to read. Indentation matters.
In LSL? "The tab is a lie!"


No No NO. The second method makes reading code MUCH easier, and makes no difference in detecting a semi colon where it doesn't belong. As far as semi colons go, just remember that the go at the end of FUNCTIONS not FLOW CONTROL or EVENTS. The best thing to aid in programming is knowing what the difference is between an event, a function, and flow control statements. Now and then, everyone plops down a semi colon where it doesn't belong, or forgets comparison equals (==) over a regular equal sign.

LSL could do better error reporting (i.e. ...expected '{' before ';') in the case above. That's where the main problem lies. LSL code that shouldn't compile sometimes does, and that's more the fault of the creators of LSL. In the end, when a script behaves other than expected, it's a fair bet to realize that you probably did something similar to the above error. The first things that should pop to mind are comparison equals and a semi colon where it doesn't belong.
_____________________
My tutes
http://www.youtube.com/johanlaurasia
1 2 3