473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

syntax ok?

emacs fails to hightlight the following line properly, when
I changed 'continue' to 'goto skip'.
So just to be sure there isn't any weired rule,
does the following do what I want?

if( yLog) if( y <= 0.0) goto skip; else y = log10( y);

Thanks,
marc

Jul 23 '05 #1
9 1409
m_schellens wrote:
emacs fails to hightlight the following line properly, when
I changed 'continue' to 'goto skip'.
So just to be sure there isn't any weired rule,
does the following do what I want?

if( yLog) if( y <= 0.0) goto skip; else y = log10( y);


It's well-formed. Please don't do it. Google for 'goto' to learn why. The
best way to prematurely exit a block is to return.

emacs obviously has a bug in its hiliter that bites code that most emacs
users would never write.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


Jul 23 '05 #2
"Phlip" <ph*******@yahoo.com> wrote in message
news:q0***************@newssvr17.news.prodigy.com. ..
does the following do what I want? if( yLog) if( y <= 0.0) goto skip; else y = log10( y);
It's well-formed. Please don't do it. Google for 'goto' to learn why. The
best way to prematurely exit a block is to return. emacs obviously has a bug in its hiliter that bites code that most emacs
users would never write.


Moreover, whether it does what you want depends on what you want. Do you
want this?

if( yLog) { if( y <= 0.0) goto skip; else y = log10( y); }

or do you want this?

if( yLog) { if( y <= 0.0) goto skip; } else y = log10( y);

They're different. (Without the { }, the first one of these examples is
what you get)
Jul 23 '05 #3
On 11 Apr 2005 07:19:08 -0700, m_*********@hotmail.com
<m_*********@hotmail.com> wrote:
emacs fails to hightlight the following line properly, when
I changed 'continue' to 'goto skip'.
So just to be sure there isn't any weired rule,
does the following do what I want?

if( yLog) if( y <= 0.0) goto skip; else y = log10( y);


1. there is an incorrect semicolon after "skip", else cannot be a
standalone statement.

2. much clearer style would be:

if( yLog)
{
if( y <= 0.0)
{
goto skip;
}
else
{
y = log10( y);
}
}

this is what your code would do without the wrong semicolon.

3. re-think on how you could avoid the "goto"
Jul 23 '05 #4

"ulrich" <ua********@aon.at> schrieb im Newsbeitrag
news:opso2pf6xan2mgp5@innsbruck-neu...
On 11 Apr 2005 07:19:08 -0700, m_*********@hotmail.com
<m_*********@hotmail.com> wrote:
emacs fails to hightlight the following line properly, when
I changed 'continue' to 'goto skip'.
So just to be sure there isn't any weired rule,
does the following do what I want?

if( yLog) if( y <= 0.0) goto skip; else y = log10( y);
1. there is an incorrect semicolon after "skip", else cannot be a
standalone statement.


You're right that "else" cannot be a standalone statement, but in this case
it isn't. The statement above could be rewritten as

if( yLog)
if( y <= 0.0)
goto skip;
else y = log10( y);

2. much clearer style would be:

if( yLog)
{
if( y <= 0.0)
{
goto skip;
}
else
{
y = log10( y);
}
}

this is what your code would do without the wrong semicolon.
The semicolon is all right. See Andrew's post regarding the effects of the
code.

3. re-think on how you could avoid the "goto"


I cannot agree more!!

Cheers
Chris
Jul 23 '05 #5
On 2005-04-11 11:03:32 -0400, ulrich <ua********@aon.at> said:
On 11 Apr 2005 07:19:08 -0700, m_*********@hotmail.com
<m_*********@hotmail.com> wrote:
emacs fails to hightlight the following line properly, when
I changed 'continue' to 'goto skip'.
So just to be sure there isn't any weired rule,
does the following do what I want?

if( yLog) if( y <= 0.0) goto skip; else y = log10( y);
1. there is an incorrect semicolon after "skip", else cannot be a
standalone statement.


There is nothing wrong with that semicolon. The above line is equivalent to:

if( yLog)
if( y <= 0.0)
goto skip;
else
y = log10(y);

In fact, you have the exact same semicolon in your example...
2. much clearer style would be:

if( yLog)
{
if( y <= 0.0)
{
goto skip; ....right here------^ }
else
{
y = log10( y);
}
}


--
Clark S. Cox, III
cl*******@gmail.com

Jul 23 '05 #6
On Mon, 11 Apr 2005 17:34:17 +0200, Chris Theis
<Ch*************@nospam.cern.ch> wrote:

"ulrich" <ua********@aon.at> schrieb im Newsbeitrag
news:opso2pf6xan2mgp5@innsbruck-neu...
> if( yLog) if( y <= 0.0) goto skip; else y = log10( y);


[...]

2. much clearer style would be:

if( yLog)
{
if( y <= 0.0)
{
goto skip;
}
else
{
y = log10( y);
}
}

this is what your code would do without the wrong semicolon.


The semicolon is all right. See Andrew's post regarding the effects of
the
code.


you're right. obviously i have typed my answer too quickly...


3. re-think on how you could avoid the "goto"


I cannot agree more!!


:)
Jul 23 '05 #7
Thanks everybody.
As I said, just wanted to make sure because so far almost always emacs
C++ mode did something 'strange' there was a reason (ie. missing
semicolon etc).
I know about the use of goto, but in some few cases a goto can be
cleaner.
(for what it's worth: return was no option here since there are
statements following)
Thanks,
marc

Jul 23 '05 #8
mschell...@gmail.com wrote:
Thanks everybody.
As I said, just wanted to make sure because so far almost always
emacs C++ mode did something 'strange' there was a reason (ie.
missing semicolon etc). I know about the use of goto, but in
some few cases a goto can be cleaner.
Cleaner? Gotos? wash your mouth out at once ;-)
(for what it's worth: return was no option here since there are
statements following)


FWIW, a return statement does not have to be the last statement in a
function (if that's what you were implying). You may also have as many
returns as you like.

int silly()
{
return 0;
std::cout << "Don't expect to see this...";
return 1;
std::cout << " ...or this";
return 2;
}

Anyway, I'm not sure that jumping out of functions at odd places via
returns is that much better an idea than gotos (needless to say I do it
myself all the time...).

Anyone remember "Structured Programming" (as taught, usually in Pascal
in the early 80's)?

--
Lionel B

Jul 23 '05 #9
(for what it's worth: return was no option here since there are
statements following


.... the goto statement.
These statements have to be executed after the goto statement.

Jul 23 '05 #10

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

Similar topics

699
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...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
14
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def...
16
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very...
23
by: Carter Smith | last post by:
http://www.icarusindie.com/Literature/ebooks/ Rather than advocating wasting money on expensive books for beginners, here's my collection of ebooks that have been made freely available on-line...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
4
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this...
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.