Did you know ... | Search Documentation: |
Pack logtalk -- logtalk-3.86.0/tools/wrapper/NOTES.md |
This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2023 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.
wrapper
This is a prototype tool to help port a plain Prolog application to Logtalk. It can also be used to enable applying other Logtalk developer tools, such as the documenting and diagramming tools, to plain Prolog code.
The tool takes a directory of Prolog files or a list of Prolog files, loads and wraps the code in each file using an object wrapper, and advises on missing directives to be added to those objects by using the compiler lint checker and the reflection API. The user can then either save the generated wrapper objects or copy and paste the printed advice into the Prolog files (updating them to Logtalk files by adding the object opening and closing directives to the Prolog files). The wrapper objects use include/1 directives to include the Prolog files and can be loaded for testing and for use with other tools. The wrapped Prolog files are not modified and thus require only read permission.
This tool API documentation is available at:
[../../docs/library_index.html#wrapper](../../docs/library_index.html#wrapper)
This tool can be loaded using the query:
| ?- logtalk_load(wrapper(loader))
.
The typical porting workflow is:
| ?- wrapper::rdirectory(root_directory_of_prolog_code)
.
...
| ?- wrapper::save.
...
See the next section on how to customize the API calls for more flexible processing.
The tool can be customized by extending the wrapper
object. A common
scenario is when wrapping plain Prolog code just to take advantage, for
example, of the documenting tool or for generating cross-referencing
diagrams. In this case, we can workaround any compiler errors by
specializing the inherited definitions for the term_expansion/2 and
goal_expansion/2 predicates and then load the wrapper objects for
further processing by using the include_wrapped_files(false)
option
described below.
The API predicates also accept a set of options for customization:
['.pl', '.pro', '.prolog']
)'.lgt'
)[]
)[]
)true
)
The use, by default, of include/1 directives to wrap the code in Prolog source files facilitates running in parallel the Logtalk port and the original Prolog code. This is specially useful when the Prolog code being ported lacks a comprehensive set of tests that could be adapted to verify the Logtalk port. The generated Logtalk files can also take advantage of uses/2 directives, including predicate aliases and predicate shorthands to minimize the changes to the original Prolog code and help verify if replacement calls to Logtalk library predicates provide the same semantics as the original calls.