Influence Object-ID

Help requests on developing Logtalk applications

Moderator: Paulo Moura

Posts: 6
Joined: Tue Jun 16, 2009 2:44 pm

Influence Object-ID

Post by mike »

Is it possible to influence the object-ID?

The following code delivers me a desired objects:

Code: Select all

:- public(new/3).
	:- mode(new(-object_identifier, +atom, +atom), one).
	new(Domain, LowBorder, HighBorder) :- self(Self),
	                                      create_object(Domain, [extends(Self)],	[],[lowBorder(LowBorder), 
domain::new(PID_A_FU_DOM, 0, 3) returns a


Now is it possible that o1 is the PID_A_FU_DOM ? Because I'd like to write

PID_A_FU_DOM::myClause instead of o1::myClause. At the moment I get

ERROR: Arguments are not sufficiently instantiated
Exception: (10) throw(error(instantiation_error, done)) ?

Best regards,


Paulo Moura
Logtalk developer
Posts: 533
Joined: Sat May 05, 2007 8:35 am
Location: Portugal

Re: Influence Object-ID

Post by Paulo Moura »

PID_A_FU_DOM is a variable, that gets instantiated to an object identifier, which is automatically generated by the Logtalk runtime. You may also pass to the create_object/4 call your own identifier (as long as there is no name conflict with an existing object identifier). If you want to use the PID_A_FU_DOM name, you've to write it between single quotes in order to make it a Prolog atom. E.g.:

Code: Select all

domain::new('PID_A_FU_DOM', 0, 3)
Is usually simpler to use an atom that starts with a lower case letter in order to avoid the single quotes:

Code: Select all

domain::new(pid_a_fu_dom, 0, 3)
Paulo Moura
Logtalk developer