[ ESL - Guidelines ]
Euphoria Standard Library (ESL) - Coding Standards
Status of this topic : Agreed upon
example : boolean.e
- Constant names are all written in all capital letters, ex.
constant TRUE = 1.
- Variables global to a module start with a capital letter.
(NOTE: Not RDS's coding style but many people do this and think it works very well)
ex.
integer Debug_switch
- Local variables are written in all lowercase letters, ex.
integer index.
- All routines and types are written in all lowercase letters, ex.
function foo().
- In multiple-word routine and type names, words are separated with a single underscore character, ex.
function foo_bar().
- Variable names are written in a "block" style, ex.
constant A = "a",
BC = "bc",
DEF = "def"
- Comments should have at least one space after the "--",
if there isn't one it's commented out code, ex.
-- This is a comment, below is a line
of code commented out
--line = "commented out"
- The beginning of a code block and the end should not be all on one line, ex.
function foo()
do_stuff()
end function
- All code blocks should be indented with 4 spaces like ed does (but not with one
tab of size 4!), ex.
if x = 5 then
do_stuff()
end if
- No line should be longer than 80 characters wide.
- If the next line is run off from a previous use 2 space indent, ex.
if a = 5 and b = 4
and c = 3 then
- For the most part, constants and routines should not be abbreviations (only local variables), ex.
procedure position()
integer pos
- Do not use either the lower- or uppercase character 'O' as variable name, because both are easily
confused with zero. Also don't use uppercase letter 'i' or lowercase letter 'L' which can both be confused
with the number 1.
- Inside a module file constants, types, and routines should be kept
separate from one another in clearly marked sections. However, due to how
Euphoria handles declarations and the logical structure of the file this
might not be desirable/possible. It should go constants, types, then
routines. Globals should be declared before locals when possible for
constants and types, ex.
-- Global constants
global constant ... -- Declarations go here
-- Local constants
constant ... -- Declarations go here
-- Global types
global type ... -- Declarations go here
-- Local types
type ... -- Declarations go here
-- Routines
-- Declarations go here