United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 4877954 RFE: Special syntax for core interfaces
4877954 : RFE: Special syntax for core interfaces

Details
Type:
Enhancement
Submit Date:
2003-06-12
Status:
Open
Updated Date:
2013-04-24
Project Name:
JDK
Resolved Date:
Component:
specification
OS:
generic,windows_xp
Sub-Component:
language
CPU:
x86,generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
1.4.2,5.0,6
Targeted Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: rmT116609			Date: 06/12/2003


A DESCRIPTION OF THE REQUEST :
It would be really nice to provide special syntax for methods of certain core interfaces:

1) Variable x declared to be an instance of a class implementing java.util.List,
     x[i] could be compiled as x.get(i)
  and
     x[i] = y could compiled as x.set(i, y)

2) Variable x declared to be an instance of a class implementing java.util.Map,
      x{k} could be compiled as x.get(k)
    and
      x{k} = y could be compiled as x.put(k, y)

3) For x and y that are instances of classes implementing an interface (yet to be specified, maybe java.lang.Number) that defines arithmetic operations as add, subtract, multiply, lessThan etc.

    x + y is compiled as x.add(y)
    x - y is compiled as x.subtract(y)
    x * y is compiled as x.multiply(y)
    ...
    x < y is compiled as x.lessThan(y)

etc.

JUSTIFICATION :
These are patterns that appear in code again and again, so it's worth providing syntax for making code more concise and make the intention of the code clearer.
(Review ID: 187748) 
======================================================================

                                    

Comments
EVALUATION

The master RFE for compiler-defined operator overloading.
                                     
2006-11-17



Hardware and Software, Engineered to Work Together