Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.77.0/examples/instmethods/SCRIPT.txt

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.

% start by loading the example:

| ?- logtalk_load(instmethods(loader)). ...

% instance1 definition for method "method" is found in its class:

| ?- instance1::method.

This is the default definition for the method, stored in class root.

yes

% instance2 overrides definition of method "method"

| ?- instance2::method.

This is an overriding definition stored in the instance2 instance itself.

yes

% instance3 specializes definition of method "method"

| ?- instance3::method.

This is a specializing definition stored in the instance3 instance itself. It makes a super call to execute the default definition:

This is the default definition for the method, stored in class root.

yes