What purpose does the “ledger" serve? I’m not sure what this even means.
anyone can write parts of your class ->
Anyone in the same module, but only if you explicitly declare your class as partial in the first place.
Impartial.swift:
class Impartial {}
Impartial.extra.swift:
partial class Impartial {} // error
Partial.swift:
partial class Partial {}
Partial.extra.swift:
partial class Partial {} // OK
Partial.othermodule.swift:
partial class Partial {} // Error
···
On Nov 1, 2017, at 8:28 AM, Mike Kluev <mike.kluev@gmail.com> wrote:
anyone can add variables to your class ?! ->
anyone can access private members of your class ?!
Again, though, “anyone” here only means “anyone working in the same module”. Which is a very restricted set of “anyone”: it only includes people who already have full access, and could just modify the original struct anyway.
-BJ
···
On Nov 1, 2017, at 9:28 AM, Mike Kluev via swift-evolution <swift-evolution@swift.org> wrote:
On 1 November 2017 at 15:22, Adam Kemp <adam.kemp@apple.com <mailto:adam.kemp@apple.com>> wrote:
I don’t see why “parts” would need to be named. That seems overly complex for little benefit.
name and ledger are essential in this proposal.
no name ->
no ledger (how to reference it?) ->
anyone can write parts of your class ->
anyone can add variables to your class ?! ->
anyone can access private members of your class ?!
by this logic we can conclude that "private" in C++ is absolutely useless,
as anyone (like "anyone in the world with the header") can change the
header from: "private: void foo();" to "public: void foo();" even without
the need of having the corresponding source file with "void foo()". right?
i'd say wrong. i'd say that even if i have a physical write access to, say,
30 third party libraries and use them in my project doesn't mean i am
"free" to go to those other people classes and change private things to
public willy nilly, or add variables to their classes, etc. my proposal, as
well as the above example with C++ private - only works if people "behave".
ledger is an explicit list of parts allowed. a guest list if you wish.
"party crashing" is not addressed in this proposal.
Mike
···
On 1 November 2017 at 15:31, BJ Homer <bjhomer@gmail.com> wrote:
Again, though, “anyone” here only means “anyone working in the same
module”. Which is a very restricted set of “anyone”: it only includes
people who already have full access, and could just modify the original
struct anyway.
Swift doesn’t have headers so this doesn’t really make sense here. The idea of a module is to be able to provide someone an immutable binary with a public interface. Someone consuming your code via a module won’t be able to modify the contents of that module and shouldn’t be able to access private methods of classes in that module or add new private fields or methods to classes in that module. I think we all agree on that. A module that your code uses is immutable to you.
But people who are building that module and already editing code within that module can and should be able to modify a class in that module any way they want. That should be obvious, right? That person can choose to directly edit the class in its main definition file, but (with partial classes as I’ve described) they could also choose to mark that class as partial and then add to it from a different swift file from within the same module. As a maintainer of that module there is absolutely nothing wrong with this. That’s why it’s important that this only be possible within that module.
···
On Nov 1, 2017, at 11:09 AM, Mike Kluev via swift-evolution <swift-evolution@swift.org> wrote:
On 1 November 2017 at 15:31, BJ Homer <bjhomer@gmail.com <mailto:bjhomer@gmail.com>> wrote:
Again, though, “anyone” here only means “anyone working in the same module”. Which is a very restricted set of “anyone”: it only includes people who already have full access, and could just modify the original struct anyway.
by this logic we can conclude that "private" in C++ is absolutely useless, as anyone (like "anyone in the world with the header") can change the header from: "private: void foo();" to "public: void foo();" even without the need of having the corresponding source file with "void foo()". right?