Influence Object-ID

Help requests on developing Logtalk applications

Moderator: Paulo Moura

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

Influence Object-ID

Post by mike » Fri Jun 19, 2009 11:05 am

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), 
													     highBorder(HighBorder),
													     counter(0)]).
domain::new(PID_A_FU_DOM, 0, 3) returns a

PID_A_FU_DOM = o1

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,

Mike

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

Re: Influence Object-ID

Post by Paulo Moura » Fri Jun 19, 2009 11:49 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest