[fpc-pascal] with in classes/records
pascaldragon at googlemail.com
Tue Sep 4 07:35:57 CEST 2018
On 03.09.2018 09:15, Ryan Joseph wrote:
> Thank you for bearing with me, so finally here are my questions:
> 1) Given this is critical to make management operators work smoothly what does the compiler team think about this idea to have a default property or “with" in classes/records?
> 2) If there is any plausible way the compiler team will allow this I’m willing to develop it myself to what every specification the team decides. I already looked into how this could be implemented and did some tests. It’s not complicated and within the range of something I could accomplish.
> Please let me know what you guy think of this proposal.
(Note: I read the other messages in the thread, but I'm replying here
for brevity's sake)
I think you need to be clearer what you want to achieve in the end. The
default property as intended by Maciej has the idea that it hoists the
operators of the default property type to the record it is contained in.
E.g. if the type has a "+" defined then using "+" on the record will use
it on the default field instead. From what I remember from one of your
previous mails your idea seems to be more to make other records part of
the record, basically like compositing. Here the question would be if
the operators of the contained type are at all hoisted to the container
type (especially if you have multiple ones and one of them defines a
certain operator and the other doesn't, not to forget other fields of
the container record).
So this would need to be explained/explored/specified first.
Also the way you used the "with" as a modifier is a no-go. If you look
at the other modifiers that Pascal uses ("public", "default",
"external", "alias", "deprecated", etc.) you'll notice that they're
either adjectives or nouns, but not a preposition. So if you want to
keep the "with" it needs to be used differently, not as a modifier (same
would be true for existing identifiers "uses" and "contains"), e.g.
"with SomeField: SomeType;". Or indeed a separate section like "public
contains" or so...
More information about the fpc-pascal