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

Ok, is *this* legal?

Okay, now we know the function name can be conditionalized, Can a
parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

Now THAT really looks weird.

Sep 13 '06 #1
9 1364
Ancient_Hacker wrote:
Okay, now we know the function name can be conditionalized, Can a
parameter list go into a conditional?
No.
Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

Now THAT really looks weird.
Yes, and it doesn't work.

Find out what your conditional statment would return.
It doesn't return a list of values. Just one value.

Sep 13 '06 #2
Ancient_Hacker posted:
Okay, now we know the function name can be conditionalized,

Confusing use of the verb "conditionalise".

Can a parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

Now THAT really looks weird.

Have you got a C compiler? If so, then why are you asking _us_?

--

Frederick Gotham
Sep 13 '06 #3
Frederick Gotham wrote:
Ancient_Hacker posted:
>Okay, now we know the function name can be conditionalized,


Confusing use of the verb "conditionalise".

>Can a parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

Now THAT really looks weird.


Have you got a C compiler? If so, then why are you asking _us_?
Because the compiler doesn't necessarily give an answer to the
question "is this allowed by the standard?".
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Sep 13 '06 #4
"Ancient_Hacker" <gr**@comcast.netwrites:
Okay, now we know the function name can be conditionalized, Can a
parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )
No, because an argument list is not an expression.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 13 '06 #5
On 2006-09-13, Ancient_Hacker <gr**@comcast.netwrote:
Okay, now we know the function name can be conditionalized, Can a
parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

Now THAT really looks weird.
I see what you're thinking, but this would only work if ?: were
interpreted by the preprocessor rather than by the compiler.

You can do this:

Result = Func(Mode == Debug ? 3.14 : Pi,
Mode == Debug ? "Debugging" : "Release");

or if Mode is known at compile time:

#if DEBUG
# define ARGS 3.14, "Debugging"
#else
# define ARGS Pi, "Release"
#endif

func(ARGS);
Sep 13 '06 #6
In article <11**********************@d34g2000cwd.googlegroups .com>,
Ancient_Hacker <gr**@comcast.netwrote:
>Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )
Read the grammar. A use of the conditional operator is an expression.
In the production for a function call, is the parenthesized argument
list an expression?

-- Richard
Sep 13 '06 #7
Nelu posted:
Because the compiler doesn't necessarily give an answer to the
question "is this allowed by the standard?".

I'd be happier if the post went something like:
I tried to compile it on my C89-conforming compiler, and it failed. Could
someone please confirm that this shouldn't compile?

--

Frederick Gotham
Sep 13 '06 #8
Frederick Gotham wrote:
Nelu posted:
>Because the compiler doesn't necessarily give an answer to the
question "is this allowed by the standard?".


I'd be happier if the post went something like:
I tried to compile it on my C89-conforming compiler, and it failed. Could
someone please confirm that this shouldn't compile?
The problem was not "not compiling" but if it compiled was it
because the standard says so or because my compiler has some
really strange extensions that I don't know about? :-).

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Sep 14 '06 #9

In article <sl*********************@bowser.marioworld>, Ben C <sp******@spam.eggswrites:
On 2006-09-13, Ancient_Hacker <gr**@comcast.netwrote:
Okay, now we know the function name can be conditionalized, Can a
parameter list go into a conditional? Something like:

int Func( float Angle, char * WhichMode ) { .. }
Result = Func Mode == Debug ? ( 3.14159, "Debugging" ) : ( Pi,
"Release" )

I see what you're thinking, but this would only work if ?: were
interpreted by the preprocessor rather than by the compiler.
It'd work just fine at runtime if C made argument list a first-class
type. But it does not.

There are languages - usually functional ones - where you can
construct arbitrary argument lists at runtime and apply them to
functions. You can do this sort of thing easily in an ML variant
such as SML or OCaml, for example.

--
Michael Wojcik mi************@microfocus.com

Some there are, brave, high-souled fellows, who could borrow the world to
play at ball, and never feel the responsibility, whereas others are uneasy
and not themselves with a single shilling that does not belong to them.
-- Arthur Ransome
Sep 14 '06 #10

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

Similar topics

1
by: Peter Young | last post by:
I'm seeing a problem with IE running on OS-X. When the user logs in to the website (ASP/IIS5), a Session is established properly, but somewhere along the line, a new Session is created and...
2
by: James | last post by:
Are there any style elements that work on select elements on Apple/IE? I want colored text, colored background, or just about anything colored in a select drop-down but can't seem to make it work...
4
by: Peter Larsson | last post by:
Hello everybody, I'm developing a system for a company that has production at two different locations. The production is stored in an Access database at each location, and I need to find a way...
1
by: Wiktor Zychla | last post by:
is it legal to distribute axshdocvw, shdocvw and mshtml.dll with my application? is it legal to distribute Microsoft.mshtml.dll from 'Primary Interop Assemblies' folder (I assume it comes with...
11
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /*...
3
by: Roy Osherove | last post by:
Hi folks. I have an ASP.Net application that runs a .Net dll that uses WMI and ADSI(both managed) to connect to a given IIS root and search through it. When not using the ASP.Net client, but...
2
by: Greg Donald | last post by:
Is it legal syntax to use <> instead of != in a Postgres query? I didn't see it listed on: http://www.postgresql.org/docs/7.4/static/sql-syntax.html but wanted to ask to make sure.
3
by: millind | last post by:
I have a small issue. I have a html page which i need to print it legal size. My default printer setting is letter. How can i set a script which will print just this page in legal without change...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
2
by: Army1987 | last post by:
Is this program legal C89? /* no headers included */ int main(void) { if (sizeof (exit(0), 0), ((void (* )(int))&exit)( (puts((const char *)"hello, world"), 0) ), 0) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.