Open timotheecour opened 3 years ago
Too unspecific. What would the spec contain? When is customFor
considered inside Nim's for loop handling?
Is this problem due to the limitations of method-call syntax?
If so, would it be possible to improve the resolution logic instead? That way, not only would for-loop macros benefit, but general usability would too.
If so, would it be possible to improve the resolution logic instead?
that's a separate issue; without the RFC you can't have overloading.
Is this problem due to the limitations of method-call syntax?
actually that section needs to be updated now that https://github.com/nim-lang/Nim/pull/17196 was merged; var info = something().toSeq
now does work; and all templates that can take iterable instead of untyped also do work with MCS/UFCS. But again, untyped params are still problematic for MCS/UFCS and I can't think of a way to fix this because the problem is essentially ambiguous (outside of https://github.com/timotheecour/Nim/issues/630). In short, this RFC is a separate topic.
proposal
allow this:
macro customFor[T](a: T, b: ForLoopStmt): untyped = ...
benefits
ForLoopStmt
, which is currently not possible(ie would fix https://github.com/timotheecour/Nim/issues/473 but with a better solution)
pairs
,mpairs
implemented viaForLoopStmt
(which needs MCS + overloadability based on type to be a valid replacement)background
originally proposed in https://github.com/nim-lang/RFCs/issues/332#issuecomment-778433560
note
macro customCase[T](a: T, b: CaseStmt): untyped =
but that should be discussed separately. But the nice thing is the symmetry you'd get betweencase
andfor
macros.