Uptime


Why? While(1) is the best way to keep a program looping forever. Since it's meant to run in the background the only way you should be able to kill it would be to... well, kill it.

Would you prefer goto?
 
aapje89 posted on Mar 28 2006 at 01:28 PM said:
he said that that was too difficult for me to understand...

This is teacher code for:

"I did it at university but I am buggered if I can remember now and I really wish I hadn't mentioned it to an enquiring mind like your's in the first place."

I know this is true as I am a teacher, I would explain it to you in more depth but it's a bit too difficult for you to understand.
 
Last edited by a moderator:
FluffyPanda posted on Mar 28 2006 at 09:04 AM said:
Why? While(1) is the best way to keep a program looping forever. Since it's meant to run in the background the only way you should be able to kill it would be to... well, kill it.

Would you prefer goto?
I was just joking. I have just never seen it written as 1 = 1 before. I have been programming for 2 years now. So do know what you are talking about.
 
Last edited by a moderator:
Hanz™ posted on Mar 28 2006 at 01:43 PM said:
I was just joking. I have just never seen it written as 1 = 1 before. I have been programming for 2 years now. So do know what you are talking about.
You're quite right to think it's silly - it's written like that because whoever wrote it didn't realise that 1 would evaluate to true without any further messing around. Almost every case I've seen of someone doing something like that is because they've just tried something until it worked, rather than understanding how it should work best or most elegantly.

Essentially, assuming that you wanted to write it this way at all, you should just use:

Code:
while [ 1 ]
 
Last edited by a moderator:
to be fair, not every language is guaranteed to interpret 1 as true. 1 = 1 is pretty unorthadox, but it's also a fairly safe bet that it will evaluate correctly.

That's assuming that = is a comparison operator, not an assignment like in C...

I really wasn't going to criticise it since I don't know how bash handles while [ 1 ]
 
FluffyPanda posted on Mar 28 2006 at 03:05 PM said:
to be fair, not every language is guaranteed to interpret 1 as true. 1 = 1 is pretty unorthadox, but it's also a fairly safe bet that it will evaluate correctly.

That's assuming that = is a comparison operator, not an assignment like in C...

I really wasn't going to criticise it since I don't know how bash handles while [ 1 ]
Quite so. BTW, bash makes it even easier by letting you use the keyword 'true' too, which would have been significantly better:

Code:
while true

Alvin: while [ E ] works in the same way that while [ gerbil ] does.

Anyway, this isn't exactly fascinating stuff, so I'll shut up :)
 
Last edited by a moderator:
WrongEyedJesus posted on Mar 28 2006 at 01:36 PM said:
This is teacher code for:

"I did it at university but I am buggered if I can remember now and I really wish I hadn't mentioned it to an enquiring mind like your's in the first place."

I know this is true as I am a teacher, I would explain it to you in more depth but it's a bit too difficult for you to understand.
Hang on does that mean you were a teacher at university but you can buggered if you can remember where and you shouldn't have made this comment to a lot of cynical satirists?
 
Last edited by a moderator:
WrongEyedJesus posted on Mar 28 2006 at 01:36 PM said:
aapje89 posted on Mar 28 2006 at 01:28 PM said:
he said that that was too difficult for me to understand...
This is teacher code for:

"I did it at university but I am buggered if I can remember now and I really wish I hadn't mentioned it to an enquiring mind like your's in the first place."

I know this is true as I am a teacher, I would explain it to you in more depth but it's a bit too difficult for you to understand.
lol, this made me laugh. It's oh so true.

However...
WrongEyedJesus posted on Mar 28 2006 at 01:36 PM said:
"I did it at university but I am buggered if I can remember now and I really wish I hadn't mentioned it to an enquiring mind like your's in the first place."
I really hope you aren't an english teacher.

FluffyPanda - Spelling and Grammar Nazi Extraordinaire.
 
Last edited by a moderator:
My English teacher doesn't know the difference between effect and affect.

Anyway, I do know that 1 evaluates to true. I wasn't sure whether bash did this or not so I stuck with the safest option.
 
FluffyPanda posted on Mar 28 2006 at 05:23 PM said:
However...
WrongEyedJesus posted on Mar 28 2006 at 01:36 PM said:
"I did it at university but I am buggered if I can remember now and I really wish I hadn't mentioned it to an enquiring mind like your's in the first place."
I really hope you aren't an english teacher.

FluffyPanda - Spelling and Grammar Nazi Extraordinaire.

Whoops! I am normally so careful with my apostrophe usage too!

Still I'm a scientist not a linguist (Hmm that sounds a bit too Dr. McCoy for my liking). :rolleyes:
 
Last edited by a moderator:
Back
Top