You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
Better overload conditional conformance mechanics
The main problem is when making several overloads for a generic type, there needs to exist a way to set them in a hierarchy for their calling or the compiler should use the unconstrained signature last.
Why this should be a priority
Broadly speaking, this will benefit generic programming in Mojo a lot.
Going into specifics, In order to achieve things like what Chris mentioned in a community meeting a couple of weeks ago of decoupling the algorithms from the data structures, we need to be able to do this kind of overload conditional conformance and help the compiler resolve which signature to call when more than 1 coincide.
What is your motivation for this change?
I was trying to bring in the code for reversing Array with SIMD into List.
The constrained reverse function is currently ignored
struct List2[T: CollectionElement]:
vardata: UnsafePointer[T]
fn__len__(self) -> Int:
return3fnreverse[A: DType](inoutself: List2[Scalar[A]]):
...fnreverse(inoutself):
"""Reverses the elements of the list."""varearlier_idx=0varlater_idx=len(self) -1vareffective_len=len(self)
varhalf_len= effective_len //2for _ inrange(half_len):
varearlier_ptr=self.data earlier_idx
varlater_ptr=self.data later_idx
vartmp= earlier_ptr.take_pointee()
later_ptr.move_pointee_into(earlier_ptr)
later_ptr.init_pointee_move(tmp^)
earlier_idx =1
later_idx -=1fnmain():
varitems= List("1", "2", "3")
items.reverse()
print(items.__str__()) # ['3', '2', '1']varitems2= List(1, 2, 3)
items2.reverse()
print(items2.__str__()) # prints: "[3, 2, 1]" , should print "[1, 2, 3]" i.e. not be reversed
Any other details?
No response
The text was updated successfully, but these errors were encountered:
Review Mojo's priorities
What is your request?
Better overload conditional conformance mechanics
The main problem is when making several overloads for a generic type, there needs to exist a way to set them in a hierarchy for their calling or the compiler should use the unconstrained signature last.
Why this should be a priority
Broadly speaking, this will benefit generic programming in Mojo a lot.
Going into specifics, In order to achieve things like what Chris mentioned in a community meeting a couple of weeks ago of decoupling the algorithms from the data structures, we need to be able to do this kind of overload conditional conformance and help the compiler resolve which signature to call when more than 1 coincide.
What is your motivation for this change?
I was trying to bring in the code for reversing
Array
withSIMD
intoList
.The constrained reverse function is currently ignored
Any other details?
No response
The text was updated successfully, but these errors were encountered: