Ecere SDK/eC Forums • View topic - default private public

Ecere SDK/eC Forums

Ecere Developers Community

default private public

General help with the eC language.

default private public

Postby redj » Wed Feb 09, 2011 11:25 am

Question from JF:
What does private and default mean at the source level (outside a class)?

Posts: 107
Joined: Sun Jan 17, 2010 10:03 am

Re: default private public

Postby jerome » Wed Feb 09, 2011 1:49 pm

(See also page 86-92 of the Tao)

The meaning of private / public is very different in eC (compared to e.g. C++).

Its meaning is the same inside and outside a class/struct .

public means it's accessible outside the 'executable module' (It only makes a different with a shared library).
private means it's only accessible from within the 'executable module'
static means it's only accessible from within the source file module (.ec file)

Now for the current limitations:

We're missing the 'static' declaration inside classes/structs. This limits the value of the 'static' access control in general, because anything that is non-static must use only non-static types.
Thus if you need to use any non-static type in any of the methods of the class you want to make static, that's not possible at the moment.

There are some special features that won't work well if you declare your constructs private, because it restricts the access to those constructs from within your module, and those features are implemented in a shared library (e.g. in the ecere shared library). Some of these should probably be fixed/improved.

See attached the latest test for access control.
(479 Bytes) Downloaded 870 times
(1.98 KiB) Downloaded 858 times
(2.05 KiB) Downloaded 861 times
(2.9 KiB) Downloaded 830 times
(151 Bytes) Downloaded 819 times
(7.02 KiB) Downloaded 859 times
Site Admin
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Re: default private public

Postby jerome » Wed Feb 09, 2011 3:23 pm

Sorry I forgot all about 'default'!

default brings eC in a 'C' mode, where nothing gets mangled at all (No name spaces, structs behave like in C and do not create a type (no struct class gets created)).

If you are not inside a namespace, a global function declared does not get mangled in any way and can be called as it is in C. The default keyword allows to do that even though you are inside a namespace.

Anything inside a .h file automatically is read in as if in the 'default' mode.
To have it understood as eC, you can use the .eh extension, although it is rarely necessary to use headers with eC, preferring the 'import' mechanism. (It would still be necessary to share e.g. C macros).

Using private, static, or public goes back in eC mode.
Site Admin
Posts: 623
Joined: Sat Jan 16, 2010 11:16 pm

Return to eC Language

Who is online

Users browsing this forum: No registered users and 0 guests