Hello,
A simple example of a class stack using the examples supplied from the documentation showed ERROR: No handle.... For more complex examples, I've seen a segmentation error. Are some environmental variables incorrectly set causing these errors?
The system is a 64 bit Debian based Mint 14.
Case 1 There are no compilation error; however, the program cannot be executed without the ERROR: No handle....
michael(a)14Mint64VM ~/Program Development/Prolog/stack $ ciaoc teststack michael(a)14Mint64VM ~/Program Development/Prolog/stack $ ./teststack {ERROR: No handle found for thrown error error(existence_error(procedure,class_rt:asserta_attr/2),class_rt:asserta_attr/2)}
Case 2 Can the error seen when trying to load the package objects in the shell be causing the thrown error?
From inside a shell the following is seen:
michael(a)14Mint64VM ~/CiaoDE-1.15-1685-g2d800d8/ciao/library/class/examples/geometry $ ciaosh -f Ciao 0: Sat Mar 16 13:03:15 EDT 2013 ?- use_package(objects). {Using package /home/michael/CiaoDE-1.15-1685-g2d800d8/ciao/library/objects/objects.pl ERROR: (lns 36-36) add_clause_trans/2 directive not allowed in shell }
yes ?-
The program does run in a shell correctly. In addition, it will run correctly in emacs.
michael(a)14Mint64VM ~/Program Development/Prolog/stack $ ciaosh -f Ciao 0: Sat Mar 16 13:03:15 EDT 2013 ?- [teststack].
yes ?- main. 89 yes ?-
For reference program teststack :- module(teststack,[main/0],[objects]).
:- use_class('/home/michael/Program Development/Prolog/stack/stack').
main :- St1 new stack, St2 new stack, St1:push(8), St2:push(9), St1:top(I), St2:top(K), display(I), display(K).
program stack %%----------------------------------------------%% %% A class for stacks. %% %%----------------------------------------------%%
%% Class declaration: the current source defines a class. :- class(stack,[],[]).
% State declaration: storage/1 is an attribute. :- dynamic storage/1.
% Interface declaration: the following predicates will % be available at run-time. :- export(push/1). :- export(pop/1). :- export(top/1). :- export(is_empty/0).
% Methods
push(Item) :- nonvar(Item), asserta_fact(storage(Item)).
pop(Item) :- var(Item), retract_fact(storage(Item)).
top(Top) :- storage(Top), !.
is_empty :- storage(_), !, fail. is_empty.