Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ERROR: Arguments are not sufficiently instantiated

1,532 views
Skip to first unread message

bikenig

unread,
Feb 8, 2010, 4:39:45 PM2/8/10
to
Hi Everyone,
I'm trying to test some examples I found in Internet to use broadcast
system in prolog. I found this code (I added some lines to compiling):

% Autor:
% Fecha: 02/02/2010

:- use_module( library(pce) ).
:- use_module( library(broadcast) ).
name_of(a,ah).
name_of(b,bh).
name_of(c,ch).
name_of(d,dh).

:- pce_begin_class(name_item, text_item).

variable(id, any, get, "Id visualised"). % name, type, access,
[comment]

initialise(NI, Id:any) :-> name_of(Id, Name),
send_super(NI, initialise, name, Name,
message(NI, set_name, @arg1)),
send(NI, slot, id, Id),
listen(NI, name_of(Id, Name), send(NI,
selection, Name)),

unlink(NI) :-> unlisten(NI), send_super(NI, unlink).

set_name(NI, Name:name) :-> get(NI, id, Id), retractall(name_of(Id,
_)), assert(name_of(Id, Name)), broadcast(name_of(Id, Name)).


:- pce_end_class.


When I compile and create an object from this class, and try to use
set_name method, I find an error:

% library(win_menu) compiled into win_menu 0.00 sec, 11,760 bytes
% library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 2,024 bytes
% c:/users/ron/appdata/roaming/swi-prolog/pl.ini compiled 0.00 sec,
380 bytes
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.8.2)
Copyright (c) 1990-2009 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- consult('C:/project/workflow prolog/modularity/name_item.pl').
% library(quintus) compiled into quintus 0.02 sec, 10,768 bytes
% library(pce) loaded into pce 0.03 sec, 197,788 bytes
% library(broadcast) compiled into broadcast 0.00 sec, 3,944 bytes
% C:/project/workflow prolog/modularity/name_item.pl compiled 0.05
sec, 206,752 bytes
true.

3 ?- new( NIA, name_item(a) ).
NIA = @8394732/name_item.

4 ?- send( NIA, set_name, newName ).
ERROR: Arguments are not sufficiently instantiated


what's the reason for this error (ERROR: Arguments are not
sufficiently instantiated)?

thanks in advance for your help.

Ron

Feliks

unread,
Feb 8, 2010, 4:47:11 PM2/8/10
to

> 3 ?- new( NIA, name_item(a) ).
> NIA = @8394732/name_item.
>
> 4 ?- send( NIA, set_name, newName ).
> ERROR: Arguments are not sufficiently instantiated

This is Prolog: there are no global variables. NIA was instantiated
in the first query, but in the second query it is a new,
uninstantiated variable. If you wrote:

?- new( NIA, name_item( a ) ), send( NIA, set_name, newName ).

the results would be different.

Hope this helps,
-- Feliks

bikenig

unread,
Feb 8, 2010, 5:23:57 PM2/8/10
to

Thanks Feliks for your quick answer, I'm just learning this
interesting language. Unfortunately I found this error after I
modified the query:

ERROR: retractall/1: No permission to modify static_procedure `name_of/
2'

Is necessary to define the name_of/2 into a module to be accessed into
pce_class? I tried to define into pce_[begin|end]_class block but I
found the same error. Thanks

Paulo Moura

unread,
Feb 8, 2010, 6:20:43 PM2/8/10
to
On Feb 8, 10:23 pm, bikenig <bike...@gmail.com> wrote:
> ...

> ERROR: retractall/1: No permission to modify static_procedure `name_of/
> 2'
>
> Is necessary to define the name_of/2 into a module to be accessed into
> pce_class? I tried to define into pce_[begin|end]_class block but I
> found the same error. Thanks

Add the following directive to your code:

:- dynamic(name_of/2).

Cheers,

Paulo

bikenig

unread,
Feb 9, 2010, 1:42:16 PM2/9/10
to

Thanks Paulo, it was very useful

Ron

0 new messages