Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Introspection/Logtalk/introspection.logtalk
Normal file
33
Task/Introspection/Logtalk/introspection.logtalk
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
:- object(my_application).
|
||||
|
||||
:- initialization((
|
||||
check_logtalk_version,
|
||||
compute_predicate_if_available
|
||||
)).
|
||||
|
||||
check_logtalk_version :-
|
||||
% version data is available by consulting the "version_data" flag
|
||||
current_logtalk_flag(version_data, logtalk(Major,Minor,Patch,_)),
|
||||
( (Major,Minor,Patch) @< (3,0,0) ->
|
||||
write('Logtalk version is too old! Please upgrade to version 3.0.0 or later'), nl,
|
||||
halt
|
||||
; true
|
||||
).
|
||||
|
||||
% Logtalk is not a functional language and thus doesn't support user-defined functions; we
|
||||
% use instead a predicate, abs/2, with a return argument to implement the abs/1 function
|
||||
compute_predicate_if_available :-
|
||||
( % check that the variable "bloop" is defined within this object
|
||||
current_predicate(bloop/1),
|
||||
% assume that the abs/2 predicate, if available, comes from a "utilities" object
|
||||
utilities::current_predicate(abs/2) ->
|
||||
bloop(Value),
|
||||
utilities::abs(Value, Result),
|
||||
write('Function value: '), write(Result), nl
|
||||
; write('Could not compute function!'), nl
|
||||
).
|
||||
|
||||
% our "bloop" variable value as per task description
|
||||
bloop(-1).
|
||||
|
||||
:- end_object.
|
||||
Loading…
Add table
Add a link
Reference in a new issue