2 ms·
> Why not use `if` and `when` directly? Is creating new names for variables — which is what `if-let` and `when-let` seems to contribute — that common of a patte
by JadeNB 8y ago
> Why not use `if` and `when` directly? Is creating new names for variables — which is what `if-let` and `when-let` seems to contribute — that common of a pattern?
This seems an awful lot like saying "Why use functions? All that they are doing is giving new names to variables" (although, to be very clear, I realise that there are meaningful differences between the two). To be sure, nothing can be done with these macros that could not be done without them—that's proven by the fact that they are coded as macros in a language that doesn't natively provide them—but it might be harder to read or write, or … whatever metric you value. I think that experience shows that any binding facility that is offered will make someone's programming life happier (although maybe many somebodies' debugging lives less happy).