1 Differences between C++ and lwc -- most of them
4 A. C++ features not present in lwc
5 ==================================
7 1. Access control (public, private, protected, friend) in classes
8 is absent. Everything is accessible.
10 2. The scope operator '::' is not there. In lwc we have the
11 dot '.' for declarations that would require '::'.
12 In order to access specific members of parent classes
13 (casts) are used. Example:
23 3. No initialization lists in constructors.
24 Constructors can be called at any time with "ctor()",
25 so calling ctors of parent classes does not require a section
26 where expressions are interpreted differently.
28 3b. In constructors, virtual calls, are still virtual.
29 In C++ in a constructor calls always call the current
30 type's function as if the object type was known.
32 4. Destructors do not automatically call destructors of
33 parent classes. This is generally cofused in C++.
34 Constructors of Base not automagically called when
35 constructing Derrived objects.
37 4b. Also, in the case below, no destructor is called at all!
44 because 'B' doesn't have a destructor. Also, as a consequence
45 of this, where C++ would require 'virtual destructors' to do
46 proper deletion without crashes, lwc'd better have 'auto virtual
49 5a. Exceptions do not throw types. Exceptions in lwc can
50 be identified by a simple integer value.
52 5b. Exceptions can't call the destructors of local objects
53 while unwinding the stack. Plain C can't help us implementing
54 that. We need compiler support (EH frame).
56 5c. type_id NOT PRESENT (virtual variables are the general case
59 6. Templates not implemented. Generic programming can be
60 alternativelly implemented with lwc's "template classes".
63 6b. No template functions.
65 7. Virtual inheritance accross different files does not work
66 without "virtual inheritance declarations": All files must
67 agree that a class has the same virtually derrived classes.
69 8. Operator overloading casts not implemented.
71 9. If a function returns an object which is passed as a tmp
72 to another function (common case in operator overloading),
73 the destructor of the temporary object is never called!!
75 10. unions may have data members only. They can only be PODs.
77 11. C++ casts are absent (static, reinterpret, dynamic, const).
79 12. 'mutable' not present.
81 13. Pointer to member, etc, not implemented.
83 14. The virtual table ABI is much different. lwc's vtable
84 ABI results in faster code.
86 15. At the moment, classes with virtual parents are not
89 16. lwc can call plain C functions without 'extern "C"'.
90 plain C code can call lwc functions (but not overloaded ones).
92 16a. lwc in a way resurrects 'overload'. lwc invokes mangled overloading
93 function names if it sees more than one declaration for a function.
94 A problematic case in lwc is:
100 void bar () { foo (); }
101 where in file1 foo is not an overloaded function while in file2 it is.
103 17. 'enum' is really an 'int' and it is not possible to overload
104 functions based on different enum type arguments. enums in lwc
105 are just 'generators of constants', as in C.
107 17b. Same applies to 'bool'. 'bool' in lwc is a synonym for 'int'
109 18. new and delete can't be used to allocate non-classes.
110 new and delete are compatible with malloc() and free().
112 19. Namespaces are not implemented. Nor is the 'using' keyword.
114 20. Static class members not implemented. static class members
115 only make sense with access control to 'hide' a global variable.
116 In lwc, "virtual variables" do the right thing.
118 21. consts can't be used as array initializers, for example.
121 generates C as it is, and it is invalid in C.
123 22. Destructors of global objects not called at exit (yet).
125 23. Inheritance and function overloading has slightly different rules.
138 In lwc it works and calls the foo(char*) function!
139 But in general, function overloading is very primitive in lwc except
140 from this design decission.
142 24. goto and destruction of local objects don't cooperate.
143 Goto is considered harmful unless you are an expert. So experts
144 can adjust their destruction of locals manually.
146 25. No generalized 'assignment is construction' declarations.
147 This is not possible in lwc:
150 26. No trigraphs :(((((