You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried overloading a scheme definition with multiple define_scheme_primitive on the same scheme function name, see ngeiswei@ee6995c
When calling cog-fc with a single argument it works, but when calling with 2 it tells me that the number of arguments is wrong.
I'd like to upgrade define_scheme_primitive to somehow support optional arguments, but before I start doing that I'll like to know if that's a good idea, maybe there's already an available workaround I am not aware of. Thanks.
The text was updated successfully, but these errors were encountered:
William's solution is the easiest, by far. That is, write a very small scheme wrapper (only 3-6 lines of scheme code) that takes an optional number of arguments, have it supply defaults for the missing values, and then always call C++ with a fixed number of arguments.
Example in next post ...
We need a version of cog-bind which takes an optional integer N for the number of solutions N to return. Currently, we have cog-bind, which returns all solutions (and may take too long, e.g. for the genetic data) The 'cog-single` accepts N but is hardwired for N=1.
So for example, use C++ to define cog-fc-full, and the in the (opencog query) module, add something like this:
(define* (cog-fc arg-a #:optional opt-arg-b)
(if (not opt-arg-b) ;;; it arg-b is #f i.e. if arg-b is missing ...
(cog-fc-full arg-a 42) ; default arg-b is 42
(cog-fc-full arg-a opt-arg-b) ;; user supplied arg-b
))
this way, cog-fc can be called with one or two args.
I found the best solution is to define dedicated functions for each rule-based system. For instance in the scm config file of PLN the following 2 functions are defined
I tried overloading a scheme definition with multiple define_scheme_primitive on the same scheme function name, see ngeiswei@ee6995c
When calling cog-fc with a single argument it works, but when calling with 2 it tells me that the number of arguments is wrong.
I'd like to upgrade define_scheme_primitive to somehow support optional arguments, but before I start doing that I'll like to know if that's a good idea, maybe there's already an available workaround I am not aware of. Thanks.
The text was updated successfully, but these errors were encountered: