About Naming Things

Naming Things in BlocklyProp

In BlocklyProp, all named constants, variables, arrays, and functions are global, meaning that they can be accessed from any other point in a project at any time.  If you’d like to add constants, variables, functions, or arrays to your project, you will need to make up your own names when using these blocks:

define constant

 

variable set

 

array Initialize

 

define function

 

 

The Rules for Naming Things

Following the rules of naming is very important when using these blocks!

  • Use a unique name for each constant, variable, array, and function used in your project.  Do not try to give a function and a variable the same name, for example.
  • Names are case-sensitive, so be consistent with capitalization. To BlocklyProp, foo and Foo are two different names!
  • By C-language convention, constant names use all capital letters.  So, BlocklyProp automatically transforms each constant name you enter to all-caps.  That helps to tell apart variables and constants when reading your code.
  • Make a habit of using letters, numbers, and underscores only. BlocklyProp will replace “illegal” characters, including spaces with underscores. However, in general, its good to practice not using illegal characters, as they won’t work in C and many other languages. 
  • Begin names with letters only. Names cannot begin with a number; it will cause a compiler error. Do not use underscores at the beginning of names as this may cause conflicts with the names used in BlocklyProp’s underlying C code.

You may get a compiler error message when you try to run your project if you happen to use a name that is the same as a C reserved word. The BlocklyProp system attempts to compensate for this by beginning its names with double-underscores, but there are still exceptions that get through and cause trouble.

If you see compile error messages that say something like
    “error: ’name’ redeclared as different kind of symbol” or
    “note: previous declaration of ’name’ was here”
…try renaming your variable.