Re: Operator overloading in C



Philip Potter wrote, On 05/09/07 15:19:
jacob navia wrote:
The lcc-win compiler is an experimental compiler
freely available at

http://wwww.cs.virginia.edu/~lcc-win32

It features among other enhancements operator overloading.

The specifications for that can be downloaded from:

http://www.q-software-solutions.de/~jacob/proposal.pdf

I would be interested in feedback from this group.

Thanks in advance.

Jacob

To provide some context for those who haven't been following this in comp.lang.c, I believe Jacob is advocating adding operator overloading to standard C, and thinks that the benefits of it far outweigh the downsides. He has made this suggestion a few times in comp.lang.c but the locals suggested that proposals for changing the C standard should be made here rather than there.

Jacob: I suggest you post your proposal rather than link to it, simply because people are more likely to read it if you do this. Also the link seems to be broken - I can't get your proposal at all.

The link works from here. However, I agree it is likely to be more widely read if posted in its entirety.

Re: the need for references to do operator overloading. I don't see why you could not do the definition as:
Type operator=(Type * const arg1,Type arg2);
Obviously behaviour on trying to access anything other than the actual item pointed to and a good quality implementation would warn if you attempted to do that. By the way, yes I am saying make the pointer constant, that is deliberate.

You need to define what you mean by "user defined data types" since you say operator overloading can only be done if one of the types is a user defined data type. Do you mean structures, or any alias created by a typedef or what?

Does the return type have to be one of the two types specified? Can you use different functions depending on what the result is assigned to which, in my opinion, could make reading the code far harder.

I'm not commenting at the moment on whether the extensions are a good idea or not, just suggesting some tightening up that I think you need in your proposal.
--
Flash Gordon
.



Relevant Pages

  • Re: Operator overloading in C
    ... To provide some context for those who haven't been following this in comp.lang.c, I believe Jacob is advocating adding operator overloading to standard C, and thinks that the benefits of it far outweigh the downsides. ... He has made this suggestion a few times in comp.lang.c but the locals suggested that proposals for changing the C standard should be made here rather than there. ... By the way, yes I am saying make the pointer constant, that is deliberate. ...
    (comp.std.c)
  • Re: Implicit int
    ... Richard Tobin wrote: ... C standard group saying that you find C++ operator overloading ... And Jacob, who has actually implemented an operator ... Several proposals pending for approval by the committee are proposals about numbers, and if we allow a new special syntax for each it will ...
    (comp.std.c)
  • Re: Collection
    ... defining some of the Unicode operators to map to methods ... ``Everyone I've talked to who does numerical work insists ... operator overloading was frequently used inappropriately. ... several proposals in the last few years, but have not made any progress ...
    (comp.lang.java.advocacy)
  • Re: .NET generics & the .NET framework: not generic enough?
    ... > suggestion I specifically endorse. ... It'd help out *alot* in data situations where you ... Well, I for one am not a huge fan of operator overloading in general, but it ... is frustrating not to be able to perform basic mathematics with generics. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# or VB.NET in Windows CE?
    ... C# Learner wrote: ... > is getting operator overloading in Whidbey. ... > I hope you don't mind me giving this suggestion. ...
    (microsoft.public.dotnet.languages.csharp)