Liste des Groupes | Revenir à cl c |
Am 02.05.2024 um 15:53 schrieb David Brown:No it is not. C-style functions (or C++ functions for that matter) are not objects, and do not have calling operators. Built-in operators do not belong to a type, in the way that class operators do.
That is a /long/ way from treating functions as first-class objects.A C-style function is also a function-object in C++ because it has
a calling operator.
You missed the point entirely. Lambdas can be used in many ways like functions, and it is possible for one function (or lambda) to return a different function, and can be used for higher-order functions (functions that have functions as parameters or return types). They do not mean that C++ can treat functions as first-class objects, but they /do/ mean that you can get many of the effects you might want if C++ functions really were first-class objects.But it is certainly a step in that direction, as are lambdas.Lambdas can be assigned to function<>-object to make them runtime
-polymorphic. Otherwise they can be generic types, which are compile
-time polymorphic - like the function-object for std::sort();
You repeatedly replied to Lawrence's posts confirming that you believed they were. (Re-read your posts in this thread.) I was fairly sure you were making completely unsubstantiated claims, but it was always possible you had thought of something interesting.You also claimed that classes are first-class objects in C++.I never said that and having sth. like class Class in Java is
beyond C++'s performance constraints.
Les messages affichés proviennent d'usenet.