473,387 Members | 1,578 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,387 software developers and data experts.

How complex the conditional clause is allowed

someting like

return (a==b)?a:((b==c)?:..)................

thanks

Dec 2 '06 #1
15 1557

Peter Liu skrev:
someting like

return (a==b)?a:((b==c)?:..)................

thanks
There is no limit. Your compiler might have one, but it is unlikely you
will encounter it. So just go ahead with your machine-generated code
;-)

/Peter

Dec 2 '06 #2
Peter Liu wrote:
Subject: How complex the conditional clause is allowed
It is considered poor form around these parts not put your question in the
body of your post.
someting like

return (a==b)?a:((b==c)?:..)................
The standard does not impose a limit. It recommends that a compiler should
support at least 256 nesting levels of parenthesized expressions within a
full expression.
Best

Kai-Uwe Bux
Dec 2 '06 #3
Peter Liu wrote:
someting like

return (a==b)?a:((b==c)?:..)................
This is legal and useful.

return a == b ? 1
: a == c ? 2
: a == d ? 3
: 4;

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Dec 2 '06 #4
Kai-Uwe Bux <jk********@gmx.netwrote:
It is considered poor form around these parts not put your question
in the body of your post.
Really? I've never heard of such a rule.

Steve
Dec 2 '06 #5
* Steve Pope:
Kai-Uwe Bux <jk********@gmx.netwrote:
>It is considered poor form around these parts not put your question
in the body of your post.

Really? I've never heard of such a rule.
Check out Usenet netiquette pages. It must be there somewhere. If not,
write an updated such page yourself.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Dec 2 '06 #6
Alf P. Steinbach <al***@start.nowrote:
>* Steve Pope:
>Kai-Uwe Bux <jk********@gmx.netwrote:
>>It is considered poor form around these parts not put your question
in the body of your post.

Really? I've never heard of such a rule.
>Check out Usenet netiquette pages. It must be there somewhere.
I've been on Usenet for decades and could probably quote many
of the common etiquette FAQ's verbatim. (And I mostly agree
with them, even some of the quaint outdated clauses.)
If not, write an updated such page yourself.
Why should I do that when I don't consider it a decent rule?

Steve
Dec 2 '06 #7


On Dec 2, 2:19 pm, "Peter Liu" <ppp1234567890123456...@yahoo.co.id>
wrote:
someting like

return (a==b)?a:((b==c)?:..)................

thanks
aside from compiler limits or not, the real limit should be one of
readability.

Writing maintainable, easy to understand code is always more preferable
to companies, than macho 'look how clever I am, I can write a highly
deeply nested highly complex conditional cause'

Dec 2 '06 #8
Steve Pope wrote:
Kai-Uwe Bux <jk********@gmx.netwrote:
>It is considered poor form around these parts not put your question
in the body of your post.

Really? I've never heard of such a rule.
It interferes with proper quoting because it is easy to forget to manually
cut and paste the question from the subject field into the quotation.
Best

Kai-Uwe Bux
Dec 2 '06 #9
"Steve Pope" <sp*****@speedymail.orgwrote in message
news:ek**********@blue.rahul.net...
Alf P. Steinbach <al***@start.nowrote:
>>* Steve Pope:
>>Kai-Uwe Bux <jk********@gmx.netwrote:
>>>It is considered poor form around these parts not put your question
in the body of your post.

Really? I've never heard of such a rule.
>>Check out Usenet netiquette pages. It must be there somewhere.

I've been on Usenet for decades and could probably quote many
of the common etiquette FAQ's verbatim. (And I mostly agree
with them, even some of the quaint outdated clauses.)
>If not, write an updated such page yourself.

Why should I do that when I don't consider it a decent rule?
I've known that rule for years, and abide by it. What internet have you
been connected to?
Dec 3 '06 #10

Kai-Uwe Bux skrev:
Peter Liu wrote:
Subject: How complex the conditional clause is allowed

It is considered poor form around these parts not put your question in the
body of your post.
For what it is worth, I agree completely. It is annoying not to have
the whole context in the message body.

/Peter
[snip]

Dec 3 '06 #11
andrewmcdonagh <an************@gmail.comwrote:
On Dec 2, 2:19 pm, "Peter Liu" <ppp1234567890123456...@yahoo.co.id>
wrote:
>someting like

return (a==b)?a:((b==c)?:..)................

thanks

aside from compiler limits or not, the real limit should be one of
readability.

Writing maintainable, easy to understand code is always more preferable
to companies, than macho 'look how clever I am, I can write a highly
deeply nested highly complex conditional cause'
True, but with proper formatting this can be very readable (look at Pete
Becker's example).

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Dec 5 '06 #12


On Dec 5, 6:58 pm, ricec...@gehennom.invalid (Marcus Kwok) wrote:
andrewmcdonagh <andrewmcdon...@gmail.comwrote:
On Dec 2, 2:19 pm, "Peter Liu" <ppp1234567890123456...@yahoo.co.id>
wrote:
someting like
return (a==b)?a:((b==c)?:..)................
thanks
aside from compiler limits or not, the real limit should be one of
readability.
Writing maintainable, easy to understand code is always more preferable
to companies, than macho 'look how clever I am, I can write a highly
deeply nested highly complex conditional cause'True, but with proper formatting this can be very readable (look at Pete
Becker's example).

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
I'd disagree - the example is noddy at best...

with a more realistic bunch of conditionals, formatting wouldn't help
as much - YMMV

Andrew

Dec 5 '06 #13
CTG
My Question is why would you want to make the code as unreadble as
possible?
Peter Liu wrote:
someting like

return (a==b)?a:((b==c)?:..)................

thanks
Dec 6 '06 #14

CTG skrev:
My Question is why would you want to make the code as unreadble as
possible?
Peter Liu wrote:
someting like

return (a==b)?a:((b==c)?:..)................

thanks
Why does everybody find the above unreadable? Why I admit its not a
model of beauty, I fail to find a nicer way to do stuff like that.
Would you prefer a long series of if-then-else statements?

Dec 6 '06 #15

"""peter koch ΠΙΣΑΜ(Α):
"""
CTG skrev:
My Question is why would you want to make the code as unreadble as
possible?
Peter Liu wrote:
someting like
>
return (a==b)?a:((b==c)?:..)................
>
thanks

Why does everybody find the above unreadable? Why I admit its not a
model of beauty, I fail to find a nicer way to do stuff like that.
Would you prefer a long series of if-then-else statements?

http://magegame.ru/?rf=626f6764616e

Dec 6 '06 #16

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

Similar topics

7
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value...
34
by: Pmb | last post by:
I've been working on creating a Complex class for my own learning purpose (learn through doing etc.). I'm once again puzzled about something. I can't figure out how to overload the assignment...
1
by: RobbieGotNeeds | last post by:
Are there any conditional aggregate functions, such as SUM()? An example would probably be the best way to describe what I'm trying to do... I have the following table, named Orders, with the...
1
by: Sid Gudes | last post by:
Hi All, I'm converting a CLI application from Teradata to DB2. In Teradata, there is a conditional rollback, e.g. rollback where customer='1234' and ID=123 This does the rollback only if...
6
by: Chris Dunaway | last post by:
Consider this code (.Net 2.0) which uses a nullable type: private void button1_Click(object sender, System.EventArgs e) { DateTime? nullableDate; nullableDate = (condition) ? null :...
5
by: Gary Wessle | last post by:
Hi if I have a method like this bool myClass::myMothod(myType& mt, herType ht) throw ( SomeExp ); how can I use it in a conditional statement if ( try {
5
by: pwiegers | last post by:
Hi, I'm trying to use the result of a conditional statement in a where clause, but i'm getting 1)nowhere 2) desperate :-) The query is simple: -------- SELECT idUser,...
3
by: damodharan | last post by:
Hello and thanks in advance. I have two table in DB2 (ver 8). table details are table one(Cust_det) has two fields (Cust_cin and cust_name). table two(cust_add_det) has cust_cin and...
6
by: Jared | last post by:
Consider the following two functionally identical example queries: Query 1: DECLARE @Name VARCHAR(32) SET @Name = 'Bob' SELECT * FROM Employees WHERE = CASE WHEN @Name IS NULL THEN ELSE...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.