Revision history for KeyPgNamespace


Revision [23961]

Last edited on 2020-05-22 07:39:48 by fxm [reordered sentences]

No Differences

Revision [23767]

Edited on 2019-12-02 14:45:33 by fxm [added note about anonymous Namespaces]
Additions:
**Note:** The parser allows to define anonymous Namespaces (without ##//identifier//## term), but this is the only similarity with the actual ""C++"" capability: The FB compiler automatically generates multiple separate anonymous Namespaces instead of one only per module in such a case.
The FB anonymous Namespaces are almost unusable because all their declarations are inaccessible, even from the body of the module that contains them. Apart from encapsulating module constructors/destructors also inside, nothing else can be done with them.


Revision [22520]

Edited on 2018-10-26 11:17:43 by fxm [Added a sentence on the access syntax from outside]
Additions:
To access from outside a defined symbol in a namespace, add the namespace identifier followed by a dot as a prefix of the symbol, or bring the namespace symbols into the current scope by means of the [[KeyPgUsing|Using (Namespaces)]] statement.
Deletions:
From outside, to access a defined symbol in a namespace, add the namespace identifier followed by a dot as symbol prefix, or bring namespace symbols into the current scope by means of a [[KeyPgUsing|Using (Namespaces)]] statement.


Revision [22519]

Edited on 2018-10-25 16:34:35 by fxm [Added a sentence on the access syntax from the outside]
Additions:
From outside, to access a defined symbol in a namespace, add the namespace identifier followed by a dot as symbol prefix, or bring namespace symbols into the current scope by means of a [[KeyPgUsing|Using (Namespaces)]] statement.


Revision [21946]

Edited on 2017-10-09 05:50:53 by fxm [Clarified syntax description to access duplicated symbols (by adding one ot two dots as prefix)]
Additions:
To access duplicated symbols defined in the global namespace, add one (or two) dot(s) as prefix: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith|With..End With]] block).
Deletions:
To access duplicated symbols defined in the global namespace, use: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith|With..End With]] block).


Revision [20990]

Edited on 2016-03-13 04:52:42 by fxm [Formatting]

No Differences

Revision [20338]

Edited on 2016-02-10 16:03:17 by DkLwikki [Update link format]
Additions:
**Namespace** //identifier// [ [[KeyPgAlias|Alias]] "//aliasname//" ]
A variable declared inside a namespace is always implicitly static and visible throughout the entire program even if the declaration modifier [[KeyPgShared|Shared]] is not specified (static and shared are optional, but this may improve code readability).
To access duplicated symbols defined in the global namespace, use: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith|With..End With]] block).
- Namespaces are not supported in the //[[CompilerOptlang|-lang qb]]// dialect.
- [[KeyPgUsing|Using (Namespaces)]]
Deletions:
**Namespace** //identifier// [ [[KeyPgAlias Alias]] "//aliasname//" ]
A variable declared inside a namespace is always implicitly static and visible throughout the entire program even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional, but this may improve code readability).
To access duplicated symbols defined in the global namespace, use: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith With..End With]] block).
- Namespaces are not supported in the //[[CompilerOptlang -lang qb]]// dialect.
- [[KeyPgUsing Using (Namespaces)]]


Revision [17738]

Edited on 2015-08-01 06:32:15 by FxMwikki [Formatting]
Additions:
To access duplicated symbols defined in the global namespace, use: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith With..End With]] block).
Deletions:
To access duplicated symbols defined in the global namespace use: ##.""SomeSymbol""## (or ##..""SomeSymbol""## if inside a [[KeyPgWith With..End With]] block).


Revision [16943]

Edited on 2013-09-08 11:27:34 by FxMwikki [Added a detail in one sentence (same as for KeyPgStaticMember)]
Additions:
A variable declared inside a namespace is always implicitly static and visible throughout the entire program even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional, but this may improve code readability).
Deletions:
A variable declared inside a namespace is always implicitly static and visible throughout the entire program even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional).


Revision [16357]

Edited on 2012-09-29 09:13:09 by FxMwikki [The keyword supports specifiers of nested names]
Additions:
The name of the namespace (including nested names specifier).
Deletions:
The name of the namespace.


Revision [16223]

Edited on 2012-07-20 06:17:37 by FxMwikki [Some complements of description]
Additions:
A variable declared inside a namespace is always implicitly static and visible throughout the entire program even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional).
Deletions:
A variable declared inside a namespace is always implicitly static and visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional).


Revision [16221]

Edited on 2012-07-13 15:47:15 by FxMwikki [Some complements of description]
Additions:
A variable declared inside a namespace is always implicitly static and visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (static and shared are optional).
Deletions:
A variable declared inside a namespace is always implicitly static and visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (shared is optional).


Revision [16220]

Edited on 2012-07-13 15:25:09 by FxMwikki [Some complements of description]
Additions:
A variable declared inside a namespace is always implicitly static and visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (shared is optional).
Deletions:
A variable declared inside a namespace is always visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (Shared is optional).


Revision [16219]

Edited on 2012-07-13 14:48:10 by FxMwikki [Some complements of description]
Additions:
A variable declared inside a namespace is always visible throughout that entire namespace even if the declaration modifier [[KeyPgShared Shared]] is not specified (Shared is optional).


Revision [16216]

Edited on 2012-07-02 16:24:34 by FxMwikki [Some complements of description]
Additions:
Namespaces allow to group entities like objects (predefined data-types and UDTs including Union and Enum) and procedures (including their declarations) under a name. This way the global scope can be divided in "sub-scopes", each one with its own name.
Deletions:
Namespaces allow to group entities like objects (predefined data-types and UDTs) and procedures (including their declarations) under a name. This way the global scope can be divided in "sub-scopes", each one with its own name.


Revision [16215]

Edited on 2012-07-02 14:08:23 by FxMwikki [Some complements of description]
Additions:
Namespaces allow to group entities like objects (predefined data-types and UDTs) and procedures (including their declarations) under a name. This way the global scope can be divided in "sub-scopes", each one with its own name.
Whether or not explicitly declared a namespace in a source file, the compiler adds a default namespace. This unnamed namespace, called the global namespace, is present in every file.
Any identifier in the global namespace is available for use in a named namespace (even global symbols with the same name as keywords may be declared inside a namespace).
Namespaces implicitly have public access and this is not modifiable.
Namespaces do not have any effect on the visibility of a define.
It is possible to define a namespace in two or more declarations.
Namespaces are commonly used in libraries where you don't want all the symbols from that library to crowd the user's space (called the global namespace).
Deletions:
Namespaces are commonly used in libraries where you don't want all the symbols from that library to crowd the user's space (called the Global Namespace).


Revision [15320]

Edited on 2011-10-01 12:32:19 by DkLwikki [Add C++ compat example]
Additions:

Namespaces are GCC ""C++"" compatible, the following code aims to test that.
%%(cpp)
// mylib.cpp
// To compile:
// g++ -c mylib.cpp -o mylib.o
// ar rcs libmylib.a mylib.o
#include <string.h>
#include <ctype.h>
namespace mylib
{
int test()
{
return 123;
}
}
%%(freebasic)
'' test.bas
extern "c++" lib "mylib"
namespace mylib alias "mylib"
declare function test() as integer
end namespace
end extern
print mylib.test()


Revision [14373]

Edited on 2009-08-29 21:54:56 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [13439]

The oldest known version of this page was created on 2008-06-03 18:58:32 by JeffMarshall [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode