In most languages you can cheaply and idiomatically use an Option or something similar to achieve the same thing. We canāt, so weāve got to work with what we have.
I donāt think itās actually important to signify the difference - itās accomplishing the same thing, in almost the same way, just with minor accommodations for language-level differences. The important thing is, what do you reach for when you have a problem of this shape? And the answer is that you reach for filterMap, no matter what language youāre using, and then the question of exactly how you use that thing will depend on details about the language. Or conversely, as a reader of code, seeing filterMap is on its own sufficient to tell you what the problem being solved is, and then you can look at the details of how itās being used and how it works in this particular language if you need that level of resolution.
I think the optional parameter will be pretty niche, so people who are encountering it for the first time will probably have to look it up. Iām OK with that; in the absence of named parameters, thatās usually what happens. For the common case where you donāt need the optional parameter, I think it will be obvious enough.
That said I think in a lot of cases it will still be pretty clear even with the optional parameter:
let skip = {};
return list.filterMap(x => x.isValid ? x.value : skip, skip);
or in the case that the values are known to be non-negative numbers if not null you can do something like
return list.filterMap(x => x.isValid ? x.value : -1, -1);
or whatever. I think for many readers just seeing that this is filterMap would be enough to figure out whatās going on here.
Even leaving aside the question of whether to take the optional parameter, I really think we should go with the common name for this and not Kotlinās bespoke name. Thereās a lot of value in using the common names for things.
(⦠Again, if browsers are even willing to try shipping this, under any name.)