473,804 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what does two semicolns ';;' do

I am looking at some code which process an uploaded file and it has
loops like:

for(;;){ // for([two semicolons){

what is the function of the two semicolons? loop until break?

I've tried to google it but the text filter seems to remove the
semicolons.
Jun 28 '08 #1
38 6138
la***@portcommo dore.com wrote:
for(;;){ // for([two semicolons){

what is the function of the two semicolons? loop until break?
The two semicolons are *part* of the "for" construct. See any books on C or
C++ about "for" loops.

That means that the initial statement, the break condition and the loop
statement in that loop are the empty statement.

That means that the for loop does not initialize anything when starting,
does not check for any break condition, and does not perform anything at
the end of each loop.

Which means, that's an infinite loop (until it's broken by calling the
break() construct inside the loop)

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_********* *************** *@hotmail.com
Jabber:iv****** ***@jabber.org ; iv*********@kde talk.net
Jun 28 '08 #2
la***@portcommo dore.com wrote:
I am looking at some code which process an uploaded file and it has
loops like:

for(;;){ // for([two semicolons){

what is the function of the two semicolons? loop until break?

I've tried to google it but the text filter seems to remove the
semicolons.
Look up a for loop in the PHP doc. Three expressions, separated by
semicolons. In this case, the expressions are null (which is also valid).

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 28 '08 #3
On Jun 28, 1:43*pm, la...@portcommo dore.com wrote:
I am looking at some code which process an uploaded file and it has
loops like:

for(;;){ * * // for([two semicolons){

what is the function of the two semicolons? *loop until break?

I've tried to google it but the text filter seems to remove the
semicolons.
yes, that's an infinite loop
Jun 28 '08 #4
la***@portcommo dore.com wrote:
I am looking at some code which process an uploaded file and it has
loops like:
for(;;){ // for([two semicolons){
what is the function of the two semicolons? loop until break?
Yeah, same as while (1) {.

AIR for(;;) is slightly more efficient/faster than while(1).
--
Jim Pennino

Remove .spam.sux to reply.
Jun 28 '08 #5
I figured that out soon after I posted it, not very apparent what it
it does though.

Thanks
Jun 29 '08 #6
la***@portcommo dore.com wrote:
I figured that out soon after I posted it, not very apparent what it
it does though.

Thanks
Au contraire! It was **immediately** apparent to anyone who has done
any C, C++, Java, etc. coding.
Jun 29 '08 #7
ji**@specsol.sp am.sux.com schrieb:
AIR for(;;) is slightly more efficient/faster than while(1).
How come? Isn't

for ( init; cond; after ) { stuff }

just syntactic sugar for

init; while ( cond ) { stuff; after }

and should therefore internally be the same?

Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Jun 29 '08 #8
Thomas Mlynarczyk wrote:
ji**@specsol.sp am.sux.com schrieb:
>AIR for(;;) is slightly more efficient/faster than while(1).

How come? Isn't [for] just syntactic sugar for [while] and should
therefore internally be the same?
It really depends on how your compiler optimizes jumps and boolean
expressions. A good compiler will know that both while(1) and for(;;) are
infinite loops and will translate them to non-conditional jumps in
assembler, effectively rendering them the same.

A bad compiler won't.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Cristo ha muerto por nuestros pecados, asÃ* que no vamos a frustrarle.
Jun 29 '08 #9
Iv??n S??nchez Ortega <ivansanchez-alg@rroba-escomposlinux.-.punto.-.orgwrote:
Thomas Mlynarczyk wrote:
ji**@specsol.sp am.sux.com schrieb:
AIR for(;;) is slightly more efficient/faster than while(1).
How come? Isn't [for] just syntactic sugar for [while] and should
therefore internally be the same?
It really depends on how your compiler optimizes jumps and boolean
expressions. A good compiler will know that both while(1) and for(;;) are
infinite loops and will translate them to non-conditional jumps in
assembler, effectively rendering them the same.
A bad compiler won't.
And some compilers will recognize one but not the other.
--
Jim Pennino

Remove .spam.sux to reply.
Jun 29 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
34287
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
3
3007
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
125
14874
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
3
29686
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification says: "The 'visibility' property takes the value 'collapse' for row, row group, column, and column group elements. This value causes the entire row or column to be removed from the display, and the space normally taken up by the row or column to...
121
10199
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.