Date: Fri, 25 Apr 2025 00:08:08 -0400
On Thu, Apr 24, 2025 at 8:10 PM Paul Robert Stackhouse via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> Hello,
>
> I've just looked at the file for std::any, and it seems to operate differently than the classes that I've tried to create. The any does not seem to be able to accept string values, which my var and varDeque types can.
It most assuredly can: https://gcc.godbolt.org/z/n1GP76GGv
> My classes also can do so without the use of templates. The biggest downside, in addition to my varDeque class being incomplete, is that there are still a few bugs that I have to work out, mainly with the comparison (>, >=, etc) operators for the var class.
This is where we need to talk about what exactly you *mean* by all of this.
In your original post, you talked about having a type that can hold
any "value". But you also seem to define "value" as if you're writing
JavaScript or something. Where "values" are only numbers and strings,
and any bigger than that is not a value; it is just an aggregation, a
mindless data structure which contains values.
If this is what your intro-to-C++ education has taught you about C++,
then you have not been well-served by it.
In C++, types are not just bundles of "values". An object of a
specific type *is a value* in and of itself. A `std::string` is not
merely a pointer to some characters; it *is a string*. It acts like a
string, it can do string-like things. Its value is not the value of
its pointer; it is the value of its characters. And we know this
because if you have two different string objects that have the same
characters in it, they will compare equal.
So, when you say that you want a type that can store "any value", do
you mean "value" in the JavaScript sense or the C++ sense?
>
> Here are the files as I've created them. I converted them into txt files so that they can be safely sent to you.
>
> Despite not being template-based, they both store enough information in them to pass as variables. They store a double for the numerical value, and two strings for the text value and type value. The var type returns any value type, from string and char to bool, float, and double. It contains the operators for that. And once the varDeque is complete, it will be able to return any list or map of variables if one of those is what was stored inside them all along.
As other people have commented on, this is a pretty poor type. I'm
unsure of why you seem to give `std::list` such a prominent place in
the API.
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> Hello,
>
> I've just looked at the file for std::any, and it seems to operate differently than the classes that I've tried to create. The any does not seem to be able to accept string values, which my var and varDeque types can.
It most assuredly can: https://gcc.godbolt.org/z/n1GP76GGv
> My classes also can do so without the use of templates. The biggest downside, in addition to my varDeque class being incomplete, is that there are still a few bugs that I have to work out, mainly with the comparison (>, >=, etc) operators for the var class.
This is where we need to talk about what exactly you *mean* by all of this.
In your original post, you talked about having a type that can hold
any "value". But you also seem to define "value" as if you're writing
JavaScript or something. Where "values" are only numbers and strings,
and any bigger than that is not a value; it is just an aggregation, a
mindless data structure which contains values.
If this is what your intro-to-C++ education has taught you about C++,
then you have not been well-served by it.
In C++, types are not just bundles of "values". An object of a
specific type *is a value* in and of itself. A `std::string` is not
merely a pointer to some characters; it *is a string*. It acts like a
string, it can do string-like things. Its value is not the value of
its pointer; it is the value of its characters. And we know this
because if you have two different string objects that have the same
characters in it, they will compare equal.
So, when you say that you want a type that can store "any value", do
you mean "value" in the JavaScript sense or the C++ sense?
>
> Here are the files as I've created them. I converted them into txt files so that they can be safely sent to you.
>
> Despite not being template-based, they both store enough information in them to pass as variables. They store a double for the numerical value, and two strings for the text value and type value. The var type returns any value type, from string and char to bool, float, and double. It contains the operators for that. And once the varDeque is complete, it will be able to return any list or map of variables if one of those is what was stored inside them all along.
As other people have commented on, this is a pretty poor type. I'm
unsure of why you seem to give `std::list` such a prominent place in
the API.
Received on 2025-04-25 04:08:21