April 18, 2022 Re: Static struct initialization syntax behavior & it being disabled upon adding a constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On 4/17/22 17:35, Ali Çehreli wrote: > compared to C++, the amount of constructor, destructor, copy > constructor, etc. that I do *not* write in D is very liberating to me. > It feels like I just write what is needed and it mostly just works. The following is a quick and dirty grep-based stats from a largish successful project that implements multiple libraries and binaries. The figures are numbers of times each construct appears in source code: struct: 231 interface: 3 class: 12 union: 0 this(/* ... */): 72 [1] shared static this(): 8 static this(): 1 [2] shared static ~this(): 0 static ~this(): 0 ~this(): 8 this(this): 0 [3] [1] Most operations in most constructors are trivial assignments to members. [2] It contains just an enforce expression to ensure the environment is as expected. (It is an oversight that this is not a 'shared static this' as well.) [3] There are no copy constructors either because the project started with an older compiler. It is remarkable that I did not implement a single copy or move behavior ever. Compare that to countless C++ articles on attempting to teach how to deal with fundamental operations of object. Forgotten to be called or not, there are no 'move' (which does not move in C++) or 'forward' (which does not forward in C++) expressions at all. What a price the programming community keeps on paying just because their powerful programming language was there first... Ali |
April 18, 2022 Re: Static struct initialization syntax behavior & it being disabled upon adding a constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On 4/18/22 09:17, Ali Çehreli wrote: > shared static ~this(): 0 > static ~this(): 0 > ~this(): 8 Apologies for omitting 'scope' statements: scope(exit): 34 scope(success): 6 scope(failure): 8 Ali |
Copyright © 1999-2021 by the D Language Foundation