mattmoore
05/29/2020, 3:17 PMPerson(_, lastName) -> println(lastName)
but I have some thoughts on how to make that happen as well. My initial step here is to see what's possible and then optimize and improve things later.
The good news is the match works independently from when
(even though this example uses when
). It matches based on a KtCallExpression
to do the desugaring. This should mean we can match in other contexts as well (general function calls) with a little extra work. Meta doesn't yet have scopes defined for KtCallExpression
so I wrote out a scope for that as well to support this. I had a separate PR for it originally, but merge that into the pattern-matching branch for now. I also have to see what the other properties for KtCallExpression
are used for in other scenarios. I might also include a scope for KtReferenceExpression
if needed.
Additionally, I think I have an idea in mind for patterns with lists (head, tail patterns, etc...). I don't have this yet demonstrated (it's mainly a thought process in my head at the moment) but I might have an initial PoC around lists this weekend as well...
Overall, it's very early and there's a lot of work remaining, but it's a start. I am feeling more confident that pattern matching is definitely possible, and using Meta will make things so much easier! Thank you for having this within Meta.
I think it's possible to have a fairly solid prototype for most common scenarios ready within a couple months.