Go Down

Topic: No documentation on ternary operators ? : on language ref page. et al (Read 1 time) previous topic - next topic

RRolf

Although the Aruduino environment supports the ternary "Conditional Operator", there is NO mention of
it in ANY of the online documentation. There should be an a additional heading on the language reference page:

"Conditional Operator"
"? : (ternary operator)"

With appropriate explanation so that newbies can discover it's usefulness.

The doc on 'variables' should mention what VALUE is set for "HIGH" and "LOW" and that it requires an INT type,
not boolean, which is what one would assume for a two state "type".

The 'integer constants" needs to make it clear that "0" is not "O". eg. "Leading ZERO, not Oh."
Logically one would think that with B for binary, and X for heX, that OH would be the prefix for Octal.

The business of case sensitivity for the prefixes and suffixes on var types should also be addressed.

It would also be extremely useful if the B operator worked for more than 8 bits.
One should be able to specify a int or long with binary notation too.
The AVR assembler supports insertion of underscores "_" in a binary constant to make it easier to group the bits.
Why not add this to Arduino?

The data type 'array' needs to have an example of how to use multiple lines to initialize a long or
multidimensional array.

More later...

robtillaart


The Arduino language is C/C++ (based) and I propose you just buy - http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628 - to get the details of the C language.

Furthermore there are allready many good C/C++ websites to search for constructs so it make little sense to replicate them. On the other hand some links to good sites could be added and would be valuable. One I bookmarked recently - http://www.cprogramming.com/tutorial/function-pointers.html - might be a starting point for you.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

cr0sh


Although the Aruduino environment supports the ternary "Conditional Operator", there is NO mention of
it in ANY of the online documentation. There should be an a additional heading on the language reference page:

"Conditional Operator"
"? : (ternary operator)"

With appropriate explanation so that newbies can discover it's usefulness.


The only thing the ternary operator does is make for shorter, quicker-to-type code constructs, which are identical to if-then-else constructs (and likely compile to the same code, though I haven't checked this). Most "newbies" have trouble enough with the standard if-then-else construct (typically with some form of malformation of the conditional check); trying to get them to understand the ternary form would likely only confuse them more, which is probably why it isn't mentioned.

If anything, it should be noted "in passing" in the documentation on the if-then-else construct, with an admonishment to users to first become expert in the "standard" if-then-else construct -before- moving to the ternary form.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Graynomad

The Arduino documentation is lacking in many places, however a lot of that is really up to the C/C++ language documentation which is well covered in many places.

I'm not familiar with most of the issues you mention, can you point to exact pages? 

Quote
B operator worked for more than 8 bits.

Don't quote me but I think that's just 256 #defines. If so it would be a bit much to go to 16 bits :)

_____
Rob

Rob Gray aka the GRAYnomad www.robgray.com

Msquare

Code: [Select]
#ifndef Binary_h
#define Binary_h

#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1

and so on for about 500 more.

Go Up