Down With Some Lingo

Here are some common terms you'll likely see everywhere on the internet, especially when reading 
C++ or Java pages. If you're not familiar with some of these terms, here are how they relate to 
FreeBASIC code.


' TYPE (or object class) definition:
type Foo
public:        ' Member access rights specifier
     declare constructor                               ' Default constructor declaration
     declare constructor (byref as Foo)                ' Copy constructor declaration
     declare destructor                                ' Destructor declaration
     declare sub Bar                                   ' Non-static member procedure declaration
     declare static function Baz as integer            ' Static member procedure declaration
private:       ' Member access rights specifier
     m_data as integer                                 ' Member data declaration
end type

' TYPE (or object class) member procedure definitions:
constructor Foo                                        ' Default constructor definition
' ...
end constructor

constructor Foo (byref x as Foo)                       ' Copy constructor definition
' ...
end constructor

destructor Foo                                         ' Destructor definition
' ...
end destructor

function Foo.Bar as integer                            ' Non-static member procedure definition.
' ...
end function

function Foo.Baz as integer                            ' Static member procedure definition.
' ...
end function

' ...

scope
     dim x as Foo                                      ' A local object (or instance) 'x' is default-constructed.
     dim p as Foo ptr = new Foo(x)                     ' A dynamically allocated object (or instance) is copy-
                                                       ' constructed from 'x'. A local pointer (or reference) 'p' is
                                                       ' initialized with the address of that object (or instance).
     delete p                                          ' The object (or instance) that 'p' points to (or references)
                                                       ' is destroyed.
end scope                                              ' <- The local object (or instance) 'x' is destroyed.


"Foo.Bar" and "Foo.Baz" are called "qualified names"; "Bar" and "Baz" are qualified with the name of the type they 
are members of using "Foo" and the scope resolution operator (operator .).

When referring to subs or functions, I like to say "procedure" rather than "function" to avoid confusion. Member 
procedures are sometimes called "methods" (by Java people in particular). Member procedures, member data and other 
things within the type definition (like constants and enums - and eventually nested type or class definitions) are 
all called "members".

When objects (or "instances") are created, they are said to be "instantiated". Local objects are "destroyed" when 
leaving scope and objects dynamically allocated with new or new[] are "destroyed" when their address is given to 
delete or delete[], respectively. Instantiating an object means to allocate memory for and construct it (call 
one of its constructors), while destroying an object means to destruct it (call its destructor) and deallocate 
its memory.

Pointers are sometimes called "references", because they point to - or "reference" - some memory. "references" includes 
both pointers and reference types:


sub f (byval p as Foo ptr)                             ' The parameter 'p' is a pointer (or reference) to some
' ...                                                  ' Foo object instance.
end sub

sub g (byref x as Foo)                                 ' The parameter 'x' is a reference (or alias) to some
' ...                                                  ' Foo object instance.
end sub

sub h (byref rp as Foo ptr)                            ' The parameter 'rp' is a reference to a pointer
' ...                                                  ' to some Foo object instance.
end sub


Reference types "reference" existing variables or objects. In FreeBASIC, like in C++, reference types behave like 
aliases; they provide a different name for another variable or object instance - just as type aliases


type AnotherNameForTypeFoo as Foo


provide a different name for a data type. For all intents and purposes, references are the variable or object 
instance that they reference, as opposed to pointers, which should be considered separate from what they reference. 
Some like to say that reference types are like pointers that are implicitly dereferenced - that's how they are 
implemented "behind the scenes" by fbc. This view is OK as long as you remember that reference types, unlike pointers, 
are guaranteed to reference existing variables or objects, and that they can never be "reseated" - they always 
reference the same variable or object.