Pages: [1]   Go Down
Author Topic: No documentation on ternary operators ? : on language ref page. et al  (Read 1002 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.

Logged

Rob Tillaart

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

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

_____
Rob

Logged

Rob Gray aka the GRAYnomad www.robgray.com

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 26
Posts: 1148
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
#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.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 26
Posts: 1148
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16542
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8458
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 26
Posts: 1148
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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" ...)
Logged

Pages: [1]   Go Up
Jump to: