Is "end" an undocumented reserved word or is this a bug, pos

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
westfw
 
Posts: 2008
Joined: Fri Apr 27, 2007 1:01 pm

Re: Is "end" an undocumented reserved word or is this a bug,

Post by westfw »

I bet using any of them is asking for trouble! In fact, it would probably behoove ME to look up all the keywords in all the libraries I use to make sure I don't use any of them since I'm not using the Arduino editor that would call it to my attention.

#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
end KEYWORD2
transfer KEYWORD2
setBitOrder KEYWORD2
setDataMode KEYWORD2
setClockDivider KEYWORD2
Most (all) of those are fine, because they have "scope" limited to the class that uses them.
In other words, SPI.end() and Serial.end() don't interfere with "end", because they are only actually keywords when used as methods of the particular objects (SPI, Serial)

Similarly, it would be fine to use local variables named "end" (you can think of this problem as a sort of "poster child" for the case against global variables.)

I don't think that the Arduino editor is smart enough to only highlight them in that context, though.

User avatar
TomHumbleAndHandsome
 
Posts: 99
Joined: Mon Feb 15, 2021 6:38 pm

Re: Is "end" an undocumented reserved word or is this a bug,

Post by TomHumbleAndHandsome »

westfw wrote:Most (all) of those are fine, because they have "scope" limited to the class that uses them.
In other words, SPI.end() and Serial.end() don't interfere with "end", because they are only actually keywords when used as methods of the particular objects (SPI, Serial)
Yup, that's very true. What a mess it would be if that wasn't true.
westfw wrote:you can think of this problem as a sort of "poster child" for the case against global variables.
I know - Just because you're allowed to use globals doesn't mean it's a good idea. My analogy is that you're allowed to walk around the city late at night waving hundred dollar bills in the air... doesn't mean it's a good idea though.

User avatar
TomHumbleAndHandsome
 
Posts: 99
Joined: Mon Feb 15, 2021 6:38 pm

Re: Is "end" an undocumented reserved word or is this a bug,

Post by TomHumbleAndHandsome »

This is what it looks like in FULL COLOR.
This is what it looks like in FULL COLOR.
Untitled.png (3.06 KiB) Viewed 74 times
westfw wrote:I don't think that the Arduino editor is smart enough to only highlight them in that context, though.
I think it's more accurate to say the person who wrote the offending library is, or is not smart enough. In this case, they were smart enough to include "end" in their list of KEYWORDS so it shows up RED in the Arduino editor.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”