underscore usage

Topics related to the use of Oberon language features
Post Reply
steve64
Posts: 44
Joined: Mon Jul 09, 2018 8:56 am
Location: Italy

underscore usage

Post by steve64 » Sat Jul 14, 2018 8:45 am

Is the underscore accepted for all identifiers, even for lower case names?
Is it accepted for module names and module filenames?

cfbsoftware
Site Admin
Posts: 525
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: underscore usage

Post by cfbsoftware » Sat Jul 14, 2018 11:58 am

Underscore is accepted anywhere that a letter (uppercase or lowercase) is accepted. There are no arbitrary restrictions imposed by the compiler on its use. However, be aware that it is an Astrobe extension to Oberon and is not recommended for general use. The usual Oberon programming convention is to use camel caps to distinguish words in identifiers that are compound words (e.g. SlaveReadTxNoAck instead of slavereadtxnoack or slave_read_tx_no_ack).

Underscore was introduced in Astrobe specifically to allow the naming of MCU constants in the source code to be consistent with the names used in the manufacturer's reference manuals e.g. IOCON_PIO1_10.

If you are intending to share your code with others or port it to other Oberon systems (e.g. RISC5 FPGA) you should restrict the use of underscores in other scenarios to a minimum. Needless to say, if you are going to be the only person who ever sees your code then you can use them wherever you like ;)

steve64
Posts: 44
Joined: Mon Jul 09, 2018 8:56 am
Location: Italy

Re: underscore usage

Post by steve64 » Sat Jul 14, 2018 2:54 pm

that's good. must module names be always equal to their filenames (excluded the extension)?
is there a mandatory extension or in principle any reasonable extension could be used? some systems use .obn other .mod and so on...

cfbsoftware
Site Admin
Posts: 525
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: underscore usage

Post by cfbsoftware » Sun Jul 15, 2018 3:39 am

When using Astrobe for ARM Cortex-M targets the files containing Oberon source code should be named <modulename>.mod

The names of the generated files (object, symbol, executable files etc.) are formed from the <modulename> + an extension (.obj, .sym, .bin etc.)

The IDE, compiler and linker use these naming conventions when looking for files to open, import and link.

For more details refer to Chapter 2 File Descriptions in one of the three documents Oberon for Cortex-M Microcontrollers which you can download from Astrobe - The Oberon Programming Language webpage.

Post Reply