I have a few questions regarding operator overloading.
One, How do I forward-reference an operator redefinition? GPC complains when I leave out the parameter and result declarations in the actual definition:
TRoot.epb:83: error: missing operator result variable TRoot.epb:83: error: result type of operator undefined TRoot.epb:83: error: operator must have two arguments
If I can't do that, why not? Not being able to do that is awkward, when you're dealing with modules.
Two, Why does GPC spit out a warning when the arguments are classes (as opposed to pointers to classes)?
TRoot.eph:71: warning: object type declared as value parameter
P.S. I replied to most of the mails sent to me through -users and -doc; if you didn't receive it, please let me know. I've been having mail trouble for a few months now, and I've only recently been able to fix it.
Okay; never mind this. I can't figure out how to export an operator overload, anyway, so I've dropped down to units. :P
I'd still like to know about this, though. :D
Neil Santos wrote:
Since operators are not EP, there's no way to export them with EP syntax. You could use the GPC extension`export Foo = all' which does the same as unit export (i.e., export everything), and still allows for export renaming etc.
One yould think about how to allow operators (and overloaded routines in the future) to be named in `export' clauses. ATM, I don't really have a good idea.
Frank
Indeed; one can easily see the difficulties in trying to export an overloaded `='; when I first tried exporting it, I simply scratched my head while staring unbelievingly at how stupid `export ModRoot = (=);' looked. :))
Maybe something like `export ModuleName = (operator(SYMBOL));' would do?
Neil Santos wrote:
That's one thing. But how to tell between the overloaded variants? Always export all of them at once? Repeating the whole routine header in the export clause wouldn't seem too nice to me ...
Frank
Maybe something like `export ModuleName = (operator(SYMBOL));' would do?
*headsmack* Umm... Yeah. :P I forgot about those.
Let me know when you've solved this problem; in the meantime, I'll be content with sticking operator overloads in a unit. ;b
Neil Santos wrote:
Object assignments (of which value parameters are a special case) are generally not recommended, because they break polymorphy, object identity, etc. You might want to use reference or `const' parameters instead.
Frank