XPCE Optional Arguments

I know XPCE is, if not deprecated, not really being worked on anymore; regardless, I’ve been trying to give it a try. I’m wondering how I can make my own code have the “optional” arguments, like new(S, path(kind := poly, points := [point(0, 0)])).

What do I need to do so, for example, I can do:

:- pce_begin_class(foo, device, "Foobar").

initialise(F, Baz:[int], Bar:[int]) :->
   "Create a new foobar"::
   format("baz = ~w, bar = ~w", [Baz, Bar]).

:- pce_end_class.

% how do I make this work?
?- new(F, foo(bar := 100)). % want: baz = @default, bar = 100
% ERROR: foo ->initialise: No argument named bar
?- new(F, foo(bar := 1, baz := 2)). % baz = 2, bar = 1

What is the problem? The initialise method should call the super implementation and do something with the @default (typically call default/3 or pass it on to some other method that handles it.

The problem is that what I’ve written gives the error foo ->initialise: No argument named bar. How do I tell it what the names of the arguments are?

I see. A quick look at the pce library suggests this:

initialise(F, Baz:baz=[int], Bar:bar=[int]) :->

my xpce is also getting rusty :frowning:

Ah, that did it! Thanks Jan!