Library PCE : send/2 get/3 ... or more?

Looking at the PCE library and its evolution, I reach what looks like inconsistencies in examples and the documentation, even mentionned in the manual.

For example: send(W, return, Typed) and on the next predicate send(W, return(@nil))

The logic should be to have send(W, return(Typed)) too, if the rule is now based on send/2 and get/3

What is the best practice ?

I mix them, depending on what I think reads better in that invocation. send/2 and get/3 are the newest versions but both are supported.


2.6 Send and get with more arguments

Though the principal predicates for invoking behaviour are send/2 and get/3, XPCE provides an alternative using send/[2-12] and get/[3-13]. The following goals are all identical.

send(Box, width(100)) send(Box, width, 100)
get(Point, distance(point(10,10), D) get(Point, distance, point(10,1), D)

This alternative is provided for compatibility to pre-5.0 versions as well as to support users that dislike the new-style send/2 and get/3. It is realised using goal_expansion/2 and thus poses only a small compile-time overhead.

OK thx so the criteria is readability rather than standardizing arity

That’s the criteria I use, since both are supported and I care about the readability of the code some years later, but from the history of the development of the API the new version is send/2.

Since goal_expansion/2 is used to provide send/[2-12] you may have some special situation in which you want to reduce compilation time, in which case send/2 would be better.

1 Like