User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 27 Jul 2003, 21:02   #1
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Language construct I miss

do once {
something
if(test){do something;break;}
something else
if(another test){do something;break;}
something to finish it off with
}

string a=string.empty
do once {
a=readline
do something with a
} while a isn't empty



as it is I'm resorting to stupid constructs like

bool first=true
while (first){
first=false
something
if(test){do something;break;}
something else
if(another test){do something;break;}
something to finish it off with
}

string a=readline
do something with a
while (a isn't empty){
a=readline
do something with a
}

Someone suggest a language for me other than basic
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 27 Jul 2003, 22:08   #2
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Re: Language construct I miss

Quote:
Originally posted by W
do once {
something
if(test){do something;break;}
something else
if(another test){do something;break;}
something to finish it off with
}
while (true) {
something
if(test){do something;break;}
something else
if(another test){do something;break;}
something to finish it off with
break;
}
?

Quote:

string a=string.empty
do once {
a=readline
do something with a
} while a isn't empty
string a=string.empty
while (true) {
a=readline
do something with a
if (a is empty) break
}
?
queball is offline   Reply With Quote
Unread 28 Jul 2003, 00:41   #3
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Much neater, thx

Still would like a whilewent construct tho
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 28 Jul 2003, 01:33   #4
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Re: Language construct I miss

Quote:
Originally posted by W
Someone suggest a language for me other than basic
I don't quite see the problem;
C has do { ...; if (...) break; ...; } while(...);,
VB has Do ... If stuff Then Exit Do ... Loop Until.

What language are you using? My obligatory language recommendation is Common Lisp, which has a very flexible loop construct which can do all this and more, and you can define your own language contructs too.
queball is offline   Reply With Quote
Unread 28 Jul 2003, 16:57   #5
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Re: Re: Language construct I miss

Quote:
Originally posted by queball
I don't quite see the problem;
C has do { ...; if (...) break; ...; } while(...);,
VB has Do ... If stuff Then Exit Do ... Loop Until.

What language are you using? My obligatory language recommendation is Common Lisp, which has a very flexible loop construct which can do all this and more, and you can define your own language contructs too.
I'm talking about

while a="":input a:print a:wend

Which you simply can't do that neatly in any other language.

Besides, the white(true) construct for a non-infinite loop just feels wrong, as does a manual break condition when you're already using loop keywords in addition.
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 29 Jul 2003, 11:06   #6
Cyp
∞+♪˛
 
Join Date: Nov 2000
Location: :uo!te]oŻ|
Posts: 428
Cyp is an unknown quantity at this point
Re: Language construct I miss

Quote:
Originally posted by W
do once {
something
if(test){do something;break;}
something else
if(another test){do something;break;}
something to finish it off with
}
Code:
switch(0){default:
 something
 if(test){do something;break;}
 something else
 if(another test){do something;break;}
 something to finish it off with
}
or

Code:
 something
 if(test){do something;goto broken;}
 something else
 if(another test){do something;goto broken;}
 something to finish it off with
broken:
or

Code:
try {
 something
 if(test){do something;throw 0;}
 something else
 if(another test){do something;throw 0;}
 something to finish it off with
} catch(int caught){}
or

Code:
#define begin switch(0){default:
#define end }

begin;
 something
 if(test){do something;break;}
 something else
 if(another test){do something;break;}
 something to finish it off with
end;
__________________
Structural Integrity for Creator - since he'll probably make PA turn 3D.
Wikipedia forum
Note to self - Don't write Chinese letters with bold and italics...
<!--Last incarnation: Nov 2000-->

Last edited by Cyp; 29 Jul 2003 at 11:22.
Cyp is offline   Reply With Quote
Unread 30 Jul 2003, 17:29   #7
Cyp
∞+♪˛
 
Join Date: Nov 2000
Location: :uo!te]oŻ|
Posts: 428
Cyp is an unknown quantity at this point
Re: Language construct I miss

or

Code:
do {
 something
 if(test){do something;break;}
 something else
 if(another test){do something;break;}
 something to finish it off with
} while(0);
Cyp is offline   Reply With Quote
Unread 30 Jul 2003, 20:31   #8
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Re: Re: Language construct I miss

Quote:
Originally posted by Cyp
or

Code:
do {
 something
 if(test){do something;break;}
 something else
 if(another test){do something;break;}
 something to finish it off with
} while(0);
Jesus, I didn't know it worked that way. You're a freaking genius, this was EXACTLY what I was looking for. Explains a whole lot of bugs as well!
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 5 Aug 2003, 14:53   #9
Pitchfork
Tourist
 
Join Date: Jun 2001
Location: moon
Posts: 90
Pitchfork is an unknown quantity at this point
Code:
something;
if(test) { do something; }
else { something else;
	if(another test) { do something; }
	else { something to finish it off with; }
}
using a do { ... } if you don't wanna loop isn't nice
__________________
Quote:
Originally posted by Bloomers III
sex is dirty and for losers who can't masturbate properly
Pitchfork is offline   Reply With Quote
Unread 6 Aug 2003, 01:41   #10
W
Gubbish
 
Join Date: Sep 2000
Location: #FoW
Posts: 2,323
W is a jewel in the roughW is a jewel in the roughW is a jewel in the rough
Quote:
Originally posted by Pitchfork
Code:
something;
if(test) { do something; }
else { something else;
	if(another test) { do something; }
	else { something to finish it off with; }
}
using a do { ... } if you don't wanna loop isn't nice
Nor is nesting your if's 30 levels deep unnecesarilly, it tends to hinder easy visualization of scope and purpose, and look silly.
__________________
Gubble gubble gubble gubble
W is offline   Reply With Quote
Unread 6 Aug 2003, 19:46   #11
Pitchfork
Tourist
 
Join Date: Jun 2001
Location: moon
Posts: 90
Pitchfork is an unknown quantity at this point
Quote:
Originally posted by W
Nor is nesting your if's 30 levels deep unnecesarilly, it tends to hinder easy visualization of scope and purpose, and look silly.
this will lead back to BASICS' spaghetti code. This construct is too similar to goto's (which will work in C as well btw). Plus imho it increases readability of code, because the "break"-way u don't have indents which will show you at which level you are.
But this presumably depends on personal flavours.
__________________
Quote:
Originally posted by Bloomers III
sex is dirty and for losers who can't masturbate properly
Pitchfork is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 12:44.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018