I’m using: SWI-Prolog version 8.0.2 on Ubuntu Linux 18.04.
I’m having trouble configuring the Pengine instance with certain options that are described in the pengine_create/3 page:
http://www.swi-prolog.org/pldoc/doc_for?object=pengine_create/1
For example, I try to pass an ID to the call yet the Pengine.id property remains null after the call.
I looked at the code for the client side Pengines code (i.e. - the code that makes Ajax calls to a Pengines server instance):
I don’t see where the id property would ever get copied to the client side Pengine instance? There are only two object methods that are involved with these operations during a create call, at least from what I can see: fillDefaultOptions() and copyOptions(). Here is the relevant code:
// private functions
function fillDefaultOptions(options) {
for(let k in Pengine.options) {
if ( Pengine.options.hasOwnProperty(k) &&
options[k] === undefined )
options[k] = Pengine.options[k];
}
return options;
}
function copyOptions(to, from, list) {
for(let i=0; i<list.length; i++) {
let k = list[i];
if ( from[k] !== undefined )
to[k] = from[k];
}
}
And here are the calls made to those two methods from the constructor:
// create instance
this.options = fillDefaultOptions(options);
this.id = null;
// On creation
let src = this.options.src ? [this.options.src] : [];
let createOptions = {
src_text: this.script_sources(src).join('\n')
};
copyOptions(createOptions, options,
[ "format",
"application",
"ask",
"template",
"chunk",
"destroy"
]);
The problem I see when I trace out the code, is that fillDefaultOptions() only copies over properties that already exist in the object and only if the existing property is currently undefined, and copyOptions() only copies over properties that are in the provided property name list, which does not include a list element for the id property. In the end, the id property provided by the caller during the pengine_create/3 call never gets assigned to the id property that exists in the object and when I inspect the Pengine object after the call the id property is null.
Am I wrong in this analysis?