GNOME Bugzilla – Bug 696995
Add support for partial classes
Last modified: 2018-05-22 14:45:06 UTC
Created attachment 240254 [details] [review] Add support for partial classes This patch adds support for partial class definitions across multiple source files. The implementation merges all subsequent parts into the first encountered, much like vala already does for namespaces. In the generated vapi the class appears as complete type (no 'partial'). From IRC: 20:35 < bronzebeard> i just now wrote an implementation for partial classes, is there a specific reason not to support such a feature or is it ok to file a bug? 20:35 <@nemequ> not yet. i'll push it to git in a minute. 20:36 <@nemequ> bronzebeard, iirc there is already a bug about it, but yes, there are several reasons not to support them. 20:36 <@nemequ> bronzebeard, it's under (slow) debate, but if you have something working you should definitely attach it ... 20:55 <@nemequ> bronzebeard, so it doesn't work across multiple valac invocations. 20:55 < bronzebeard> nemequ, you mean i.e fast-vapis? 20:55 <@nemequ> i mean separate projects 20:56 <@nemequ> or multiple valac calls within the same project Not sure I understand correctly, but this is what the C#-Programming Guide says: - All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). - Partial definitions cannot span multiple modules. Things that still need to be done: - base types: if the same base-type appears in two partial classes, both are added to the list. Currently the symbol resolver doesn't check for duplicate base-types. This should probably be a separate bug.
Thanks for the patch, however what's the benefit of having partial classes that cannot span multiple projects? Just splitting a single file with huge class to many files? I don't see much of a benefit for this feature.
FWIW I'm -1 on this, especially if we do something about bug #681097. It would complicate the generated C, probably expose internal symbols unless people pass certain flags to the CC, and eliminates potential optimizations. Plus it makes the source harder to read.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/370.