C++ Logo

std-proposals

Advanced search

Re: Std-Proposals Digest, Vol 28, Issue 27

From: Gašper Ažman <gasper.azman_at_[hidden]>
Date: Tue, 13 Jul 2021 19:36:49 +0100
Yes, and type_info gives you a runtime object representing a type.

On Tue, Jul 13, 2021 at 7:18 PM Jaroslav Moravec via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> To understand what I need:
>
> I need the type-casting to be "run-time" process.
> Understand me ?
>
> Jerry
>
> ---------- Původní e-mail ----------
> Od: std-proposals-request_at_[hidden]
> Komu: std-proposals_at_[hidden]
> Datum: 13. 7. 2021 19:01:01
> Předmět: Std-Proposals Digest, Vol 28, Issue 27
>
> Send Std-Proposals mailing list submissions to
> std-proposals_at_[hidden]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> or, via email, send a message with subject or body 'help' to
> std-proposals-request_at_[hidden]
>
> You can reach the person managing the list at
> std-proposals-owner_at_[hidden]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Std-Proposals digest..."
>
>
> Today's Topics:
>
> 1. Re: A new proposal, new key-word definition for dynamic,
> run-time type-cast operations (Antoine Viallon)
> 2. Re: a new proposal. (Ga?per A?man)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 13 Jul 2021 15:01:31 +0200
> From: Antoine Viallon <antoine_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] A new proposal, new key-word definition
> for dynamic, run-time type-cast operations
> Message-ID: <79FA6351-C0A4-4A70-9C28-73FD3C87341F_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> Hello,
> I quickly read what you sent,
> And I have a question:
> Isn't there a "typeinfo" header containing something able to hold type
> information? There is typeindex also, if I'm not mistaken.
> Maybe the only thing you need is to be able to use such types in a
> dynamic_cast
>
> In any case, I see a very useful use-case for an argument parser for
> instance.
>
> Antoine Viallon
>
>
> -------- Courriel d?origine --------
> De?: Jaroslav Moravec via Std-Proposals <std-proposals_at_[hidden]>
> Envoy??: 13 juillet 2021 14:44:50 GMT+02:00
> ??: std-proposals_at_[hidden]
> Cc?: Jaroslav Moravec <j.moravec.email_at_[hidden]>
> Objet?: [std-proposals] A new proposal, new key-word definition for
> dynamic, run-time type-cast operations
>
>
> New proposal, version 2.
>
>
>
>
>
> Abstract
>
>
>
> The C++ language is here for more that 36 years and is still under
> development. Sometimes, C++ borrows some ideas from other programming
> languages, sometimes works on its own way. Presented proposal try to
> introduce a new type of basic variable which would be capable to hold a
> type
> of a variable or a type of a class or a struct. This variable should be
> capable to define target new type in type-cast operations such us: static_
> cast or dynamic_cast etc. Both at running time and at compilation time.
> Type
> of a variable or a class/struct is usually given by its unique name. Thus,
> the new basic variable should contain a string ? the name of basic
> datatype
> or a type of user defined datatype. This name is then used in the
> type-cast
> operation at running time. The target type is, of course, well known at
> compilation time.
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 2
> Date: Tue, 13 Jul 2021 17:42:32 +0100
> From: Ga?per A?man <gasper.azman_at_[hidden]>
> To: Std-Proposals <std-proposals_at_[hidden]>
> Subject: Re: [std-proposals] a new proposal.
> Message-ID:
> <CAANG=kUPxVURJhCJFqzYWRhsxDv6_Fz0rrbavj091d3OXvz71Q_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> the dynamic_cast to a type-id is a really interesting call-site syntax for
> open multimethods - the problem isn't that this hasn't been tried (just
> look for multimethods) - the problem is we don't know of an efficient and
> correct way to implement the dispatch tables.
>
> If you are forced to write the switch statement based on the type-index
> yourself, then at least you need to list, exhaustively, the types you care
> about. Pattern matching is another way to do this. I'm not sure your
> proposal is implementable.
>
> G
>
> On Tue, Jul 13, 2021 at 11:26 AM Marcin Jaczewski via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> > I look like `dynamic` form C# but this mean it relay on reflection to
> > work correctly:
> > ```c#
> > dynamic d = x;
> > int i = d.item;
> > ```
> > is equal to
> > ```c#
> > DynamicType d = new DynamicType(x);
> > int i = (int)d["item"];
> > ```
> > C++ could have static reflection but this requires dynamic reflection
> > to work (static could generate dynamic but it will be costly).
> > Another thing is dynamic code generation other wise you can't have code
> > like:
> >
> > ```c++
> > std::cout << declarative_cast<type_var>(var);
> > ```
> > where type can be `int`, `long` or `std::vector<int>` and all need
> > have its own `<<` that is templated function that usually is inlined.
> > Does this mean `type_var` needs to store all possible template
> functions?
> >
> > Beside syntax like `declarative_cast<arg[0]->i>` is wrong as it mix
> > compile time template arguments with runtime arguments, something only
> > could work
> > if you use constexpr variables but it's not something your example wants
> > to do.
> >
> >
> > Lot better would expand `std::any` and allow easy way to have multiple
> > type callbacks like:
> > ```c++
> > std::any z = 17;
> >
> > vist_any<int, long, std::vector<int>>(z, [](auto& w) { std::cout <<
> > w; }); //you need name all types you want use
> > ```
> > and this is possible even if C++14
> >
> > wt., 13 lip 2021 o 11:27 Jaroslav Moravec via Std-Proposals
> > <std-proposals_at_[hidden]> napisa?(a):
> > >
> > > The proposal is in attachments. --
> > > Std-Proposals mailing list
> > > Std-Proposals_at_[hidden]
> > > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> >
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Subject: Digest Footer
>
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
> ------------------------------
>
> End of Std-Proposals Digest, Vol 28, Issue 27
> *********************************************
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2021-07-13 13:37:04