________________________________________________________________________

This file is part of Logtalk <https://logtalk.org/>  
Copyright 1998-2021 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.
________________________________________________________________________


% start by loading the example with the debug statements activated:

| ?- logtalk_load(debug_hooks(loader_debug)).
...


% debug the definition of the "object" predicate append/3:

| ?- object::append([1,2,3], [4,5], List).
Recursive case: append([2, 3], [4, 5], _G340)
Recursive case: append([3], [4, 5], _G347)
Recursive case: append([], [4, 5], _G354)
Base case: append([], [4, 5], [4, 5])
List = [1, 2, 3, 4, 5].
yes


% debug calls to the "object" predicate sum/2:

| ?- object::sum([1,2,3,_], S).
Exception: error(instantiation_error, number::check(_G433), object)

| ?- object::sum([1,2,3,a], S).
Exception: error(type_error(number, a), number::check(a), object)

| ?- object::sum(wrong, S).
Exception: error(type_error(list, wrong), list::check(wrong), object)


% load the example with the debug statements discarded:

| ?- logtalk_load(debug_hooks(loader_production)).
...


% call the "object" predicate append/3 without the debugging statements:

| ?- object::append([1,2,3], [4,5], List).
List = [1, 2, 3, 4, 5].
yes


% call the "object" predicate sum/2 without the debugging statements:

| ?- object::sum([1,2,3,_], S).
Exception: instantiation_error

| ?- object::sum([1,2,3,a], S).
Exception: type_error(evaluable, a/0)

| ?- object::sum(wrong, S).
no
