C++ Logo

STD-PROPOSALS

Advanced search

Subject: [std-proposals] Question about using _ for Pattern Matching
From: Михаил Найденов (mihailnajdenov_at_[hidden])
Date: 2019-10-31 04:02:54


Hello, I understand using _ as a Wildcard pattern is considered "out of
question" and now work is made to make the __ available for that purpose.

My question is, why is _ out of question?

I understand _ might be in use already, but is this really a problem?
The way I see it, there 2 cases _ might be in use:

   - As an identifier
   - As a macro

In the first case _ might be interpreted as "something else" - an existing
variable, a typename or function name. However in the context of Pattern
Matching this will not be a problem as _ can only be used in places where a
variable identifier is expected AND by default all variable identifiers are
NOT referencing existing ones - they are introducing new ones. In other
words, per current PM rules _ can never ever be interpreted as anything
different then a Wildcard.

The second case, having some _ macro. These cases will clash as the macro
will expand before PM is evaluated. This means one can't use Wildcard AND
have some _ macro visible. Is this a show-stopping problem though? It is
not that we are breaking user code. Or making _ a global keyword. It is
just that you can't have both that macro, that you can rename, and PM with
a Wildcard.

Am I missing something? What is the official reason _ can't be used in PM?

Thank You



STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups