Wiki

Ticket #95 (new enhancement)

Opened 16 years ago

Last modified 16 years ago

cue compare

Reported by: Chuck Owned by:
Priority: major Milestone: Cobra 0.9
Component: Cobra Compiler Version: 0.8.0
Keywords: cue Cc:

Description

    cue compare(other) as int
    cue compare(other as X) as int
  • Note that there is already a .compareTo method that Cobra will look for. That likely will need to be retired.
  • is override or base.compare are required if the base class also provides this cue
  • The normal means of invoking this is with a comparison operator.
  • But still externally visible in case you need the value (-, 0, +) of the result.
  • Need to consider if implementing this can serve as an implementation of cue equals when cue equals is not present.
  • Some research and consideration is required about whether the argument to this method is typed or not, or if both cues could be declared/overloaded. Consider various generic and non-generic interfaces of .NET and JVM like IComparable<of T>. For example, one possible approach:
    	class X
    	
    		cue compare(other as X) as int
    			...
    # Causes the dynamic cue compare to be implemented if not already as if you specified:
    		cue compare(other) as int
    			if other is this, return 0
    			if other inherits X
    				return .compare(other)  # will invoked the statically typed overload
    			else
    				throw <exception>
    

Change History

Changed 16 years ago by Chuck

For the well typed other arg, is the type nilable or not? I would generally say no if Cobra was a standalone language but it rides on top of VMs that are not savvy about nil vs. not.

Note: See TracTickets for help on using tickets.