Ticket #287 (closed enhancement: fixed)

Opened 6 years ago

Last modified 6 years ago

Make Pair<of T> inherit Pair<of T, T>

Reported by: jaegs Owned by:
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:


Currently methods which accept Pair<of TA, TB> as argument won't accept Pair<of T>. This means that a separate method must be made for Pair<of T> .

Instead, Pair<of T> should inherit Pair<of T, T>


Change History

Changed 6 years ago by Charles

  • status changed from new to closed
  • resolution set to fixed

This is done now in changeset:2790.

Also, I noticed Pair<of TA, TB>'s .init method was still taking dynamically typed params, no doubt a left over from the original Pair class which was all dynamic. This has been improved as appropriate for generics:

-       cue init(a, b)
+       cue init(a as TA, b as TB)

One notable change is that the indexer on Pair<of TA, TB> must necessarily return "dynamic?" since nothing is known about what TA and TB have in common. Hence there were several changes in MultiList? such as:

-               _shape = for range in ranges get range[1] - range[0]
+               _shape = for range in ranges get range.b - range.a

-                   addr += (index + _ranges[i][0]) * _strides[i]
+                   addr += (index + _ranges[i].a) * _strides[i]

...because .a and .b can be strongly typed since they are separate properties.

Please take this for a test spin and let me know if you have any issues.

Note: See TracTickets for help on using tickets.