Scope modifiers: Difference between revisions

Add Logtalk implementation
m (Added Erlang)
(Add Logtalk implementation)
Line 404:
end
</lang>
 
=={{header|Logtalk}}==
Logtalk supports scope modifiers in predicate declarations and entity (object, category, or protocol) relations. By default, predicates are local (i.e. like private but invisible to the reflection mechanisms) and entity relations are public (i.e. not change to inherited predicate declarations is applied).
<lang logtalk>
:- public(foo/1). % predicate can be called from anywhere
 
:- protected(bar/2). % predicate can be called from the declaring entity and its descendants
 
:- private(baz/3). % predicate can only be called from the declaring entity
 
:- object(object, % predicates declared in the protocol become private for the object
implements(private::protocol)).
 
:- category(object, % predicates declared in the protocol become protected for the category
implements(protected::protocol)).
 
:- protocol(extended, % no change to the scope of the predicates inherited from the extended protocol
extends(public::minimal)).
</lang>
 
=={{header|Mathematica}}==
<lang Mathematica>Module -> localize names of variables (lexical scoping)
Anonymous user