C++ Logo

std-proposals

Advanced search

Re: [std-proposals] requires keyword (new use)

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Tue, 3 May 2022 09:24:27 +0200
On 03/05/2022 08.41, Abdullah Qasim via Std-Proposals wrote:
> Any idea how I can implement some keywords?
>
> So that I can test them out too?

I don't know what you mean.

If you want to experiment with language extensions,
I'd suggest to grab the gcc or clang sources and
hack away. They have all the infrastructure in place
that you'll need, for example a test suite and
a state-of-the-art compiler implementation.

Jens


> P. S. Sorry about so many suggestions; I had these for weeks, & only recently figured out tha std-proposals is for features other thatn library ones too.
>
>
>
> *From: *Jason McKesson via Std-Proposals <mailto:std-proposals_at_[hidden]>
> *Sent: *01 May 2022 22:00
> *To: *std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>
> *Cc: *Jason McKesson <mailto:jmckesson_at_[hidden]>
> *Subject: *Re: [std-proposals] requires keyword (new use)
>
>
>
> On Sun, May 1, 2022 at 4:15 AM Abdullah Qasim via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>> int menu (/**/requires/**/ unsigned int menu_option = 0)
>>
>>
>>
>> // Called as:
>>
>> menu(default);
>>
>>
>>
>> // OR:
>>
>> menu(5)
>>
>>
>>
>> // Compiler Error: function "menu(unsigned int)" requires //unsigned int variable
>>
>> menu()
>>
>>
>>
>> I do not want calls like menu(), but I do want ability to call menu(default), as, in this case, going to default screen makes perfect sense.
>
> So, you don't want the purpose of default parameters (ie: being able
> to not provide an argument for that parameter), but you want certain
> effects of default parameters (ie: having the function decide what the
> parameter is).
>
> So just take an `optional`:
>
> ```
> int menu (std::optional<unsigned int> menu_option)
> {
> if(!menu_option) menu_option = 0;
> ...
> }
> menu(std::nullopt);
> menu(5);
> menu(); //Does not work.
> ```
>
> Also, please don't spam the list with dozens of "proposals" like this.
> We would like proposals to be more considered than "here's an idea I
> had". C++ is a rich and varied language with many tools. You need to
> take time to understand what those tools are and how to use them
> *before* you can effectively start suggesting what tools the language
> ought to have.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
>
>
>
>

Received on 2022-05-03 07:24:34