No documentation on ternary operators ? : on language ref page. et al

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...

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 - Function Pointers in C and C++ - Cprogramming.com - might be a starting point for you.

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 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.

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?

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 :slight_smile:


Rob

#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.

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

Yes, well, it is my favorite, too.

Also missing is structs. Pointers are not explained either, except saying "its too complicated". "asm" is missing; for tight programming (when speed/space is essential).

And just about everything for the c++ part, which th compiler fully supports. Like classes, and all the object-stuff. Of course, with only 2K RAM you do not want the overhead of too much object-oriented stuff.

BUT

The Arduino enviroment is designed for/targeted to beginners. The fact that some advanced users can use it too is just a benefit. If the Arduino had used some "lego"-like language with very few language contructs and a "BASIC" like syntax, then there would be no advanced users.

All in all, I have to acknowledge that they have made quite a good choice: Real C/c++ so users can get advanced but only expose/document a reasonable subset.

RRolf:
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"

Yes, well, there are a number of inconsequential documentation and a few mistakes, too. Only the siteowners have write access, and in this forum there are a number of "bug reports" on documentation and tutorials ... and nothing has been corrected/enhanced. Even those blessed(?) with GlobalModerator access can not change it, and they have volunteered.

Well, it is for free, so some minor flaws to be accepted. And it enhances the experience :slight_smile: :slight_smile:

All in all, I have to acknowledge that they have made quite a good choice: Real C/c++ so users can get advanced but only expose/document a reasonable subset.

I think they made a brilliant choice and is a big factor for the tremendous popularity of the Arduino platform. They took a lot of flack early on from many of the established microcontroller 'expert' users and sites, but once explained that none of the Arduino 'short cuts', terminology, and predefined functions prevents one from using the full power of the C/C++ language that criticism as dropped down to a small noise factor.

Lefty

I admit that when I first looked at what appeared to be the Arduino "language" as presented on the reference page it put me off and I went looking at other platforms.

At the time though there weren't any good other platforms (IMO) so I came back to Arduino and delved a bit deeper. Then of course I realized that there are no real restrictions on what you can do, it's just C/C++.

I still reckon that there should be an "advanced user" section(s) to the docs, but like I think everyone else I've given up on anything getting changed in this area.

I haven't looked at the reference for ages, it may have improved but maybe someone into tech pubs could grab what's there and create a PDF language manual or another site/wiki with more advanced docs. I used to do that in a past life but have enough of my own stuff to document these days :slight_smile:


Rob

Graynomad:
At the time though there weren't any good other platforms (IMO) so I came back to Arduino and delved a bit deeper. Then of course I realized that there are no real restrictions on what you can do, it's just C/C++.

I still reckon that there should be an "advanced user" section(s) to the docs, but like I think everyone else I've given up on anything getting changed in this area.

I personally think of these sites as the "advanced user" section:

http://www.nongnu.org/avr-libc/
http://www.avrfreaks.net/

The Arduino hardware is nothing more than a custom "carrier board" for the ATMega processor; if you wanted to treat it like a specialized AVR board, you are more than free to do that. The Arduino library(s) hide a lot from the user, but nothing (other than licenses, depending on what you are doing) prevents you from reusing the code, stripping out what you don't need and keeping what you do (to reduce the binary size and such) for your own project.

The problem with having an "advanced user" section to the docs (and this is pure conjecture on my part) is that you would have beginner users trying to use and do things that they have no understanding of, or even have the base concepts down to form the understanding. They might even try to use and do things with the idea that it is what their project needs because it is "more advanced" or because they have an incomplete (or wrong) understanding of what the advanced concepts allow them to do.

Ultimately leading them back here to ask questions (which they may not even know how to phrase, making our task just that more difficult)...

No - I think the balance as it exists is the best one struck; none of this keeps the user who is advancing "in the dark"; since this topic has been rehashed so many times, they can easily find information on such topics as the standard library and AVR freaks, from more than one source/thread - and continue their learning at that point when they are ready.

cr0sh:
The problem with having an "advanced user" section to the docs (and this is pure conjecture on my part) is that you would have beginner users trying to use and do things that they have no understanding of, or even have the base concepts down to form the understanding. They might even try to use and do things with the idea that it is what their project needs because it is "more advanced" or because they have an incomplete (or wrong) understanding of what the advanced concepts allow them to do.

Indeed ! (my highlight) It matches with my experience with the in-experienced (also with so called professionals who turn up at the "advanced course", without haven taken the pre-requisite "basic" ...)