Language Notes

This is more for my personal reference than anything else.

Language NotesThis is more for my personal reference than anything else.
Prototype Parameter Styles
Syntax References

Prototype Parameter Styles

Parameters via Commas, Typed via Spaces

FunctionName ( type indentifier, type identifier = value, modifier type identifier )
FunctionName ( indentifier, identifier = value )

The general idea is that parameters are separated by commas.  Identifiers cannot contain spaces.  Types and modifiers, if available, are separated from the identifiers with spaces.  There may be an equals sign to set the default value.

So parsing means splitting by commas, stripping everything past an equals sign for the default value, stripping everything after the last space for the identifier, and the rest is the type.  If there are no internal spaces after the default value is stripped, it’s all identifier.

Note that internal parenthesis, brackets, braces, and angle brackets should be parsed out.  They may be present in default values or types and any commas and equal signs in them should not be included.

Applies to C++, Java, C#, JavaScript, Python, PHP, Ruby.

Applies to Perl as well, even though it doesn’t have any real parameter declaration structure.  Just adding it with comments is fine.

Parameters via Semicolons and Commas, Typed via Colons

FunctionName ( identifier: type; identifier, identifier: type; identifier: type := value )

Parameters via semicolons, types via colons.  However, there can be more than one parameter per type via commas.  Default values via colon-equals.

Applies to Pascal, Ada.


FunctionName ( identifier type, identifier modifier type, identifier type := value )

Parameters separated by commas.  Identifiers come before the types and are separated by a space.  Default values are specified with colon-equals.

FunctionName @identifier type, @dentifier modifier type, @identifier type = value

Microsoft’s SQL uses equals instead of colon-equals, doesn’t need parenthesis, and starts its parameter names with an @ symbol.

Visual Basic

FunctionName ( modifiers identifier as type, identifier = value )

Parameters separated by commas.  Default values via equals.  However, any number of modifiers may appear before the identifier.  Those modifiers are ByVal, ByRef, Optional, and ParamArray.


FunctionName { identifier identifier { whatever } } { code }

Identifiers are specified in the first set of braces and have no commas.  However, they can be broken out into sub-braces.