Did you know ... | Search Documentation: |
Pack logtalk -- logtalk-3.86.0/manuals/_sources/faq/programming.rst.txt |
.. This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2024 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
.. _faq_programming:
Prototypes and classes provide different patterns of code reuse. A prototype encapsulates code that can be used by itself and by its descendent prototypes. A class encapsulates code to be used by its descendent instances. Prototypes provide the best replacement to the use of modules as encapsulation units, avoiding the need to instantiate a class in order to access its code.
.. _faq_programming_both_prototypes_classes:
Yes. In addition, you may freely exchange messages between prototypes, classes, and instances.
.. _faq_programming_hierarchy:
No. However, you may define as many prototype hierarchies and class hierarchies and classes as needed by your application.
.. _faq_programming_protocols_categories:
Yes. A protocol may be implemented by both prototypes and classes in the same application. Likewise, a category may be imported by both prototypes and classes in the same application.
.. _faq_programming_components:
Logtalk supports component-based programming (since its inception on
January 1998), by using categories (which are first-class entities
like objects and protocols). Logtalk categories can be used with both
classes and prototypes and are inspired by the Smalltalk-80
(documentation-only) concept of method categories and by Objective-C
categories, hence the name. For more information, please consult the
:ref:categories_categories
section and the examples provided with
the distribution.
.. _faq_programming_reflection:
Logtalk supports meta-classes, behavioral reflection through the use of event-driven programming, and structural reflection through the use of a set of built-in predicates and built-in methods which allow us to query the system about existing entities, entity relations, and entity predicates.