Dynamic-constraint-checking and allowed-class

  • xyando

    xyando - 2013-11-27


    CLIPS fails the test program "test.clp". (as RESULT below).

    ---- test.clp ----
    (defmodule FOO
    (export ?ALL)

    (defclass FOO::DUMMY (is-a USER)
    (slot foo)

    (defmodule BAR
    (import FOO ?ALL)

    (defclass BAR::BAR (is-a USER)
    (slot bar (allowed-classes DUMMY))

    (deffunction BAR::bar()
    (set-dynamic-constraint-checking TRUE)
    (bind ?x
    (make-instance b of BAR
    (bar (make-instance f of DUMMY))

    ---- RESULT ----
    CLIPS (6.30 8/15/11)
    CLIPS> (load test.clp)
    Defining defmodule: FOO
    Defining defclass: DUMMY
    Defining defmodule: BAR
    Defining defclass: BAR
    Defining deffunction: bar
    CLIPS> (bar)
    [CSTRNCHK1] [FOO::f] for slot bar of instance [b] found in put-bar primary in class BAR
    does not match the allowed classes.
    [PRCCODE4] Execution halted during the actions of message-handler put-bar primary in class BAR
    [PRCCODE4] Execution halted during the actions of deffunction bar.

    I think this behaviour is curious, because the deffunction BAR::bar failed to find FOO::DUMMY,
    nevertheless the defclass BAR::BAR can find it.

    One solution is to modify cstrnchk.c.

    444: cmpClass = (DEFCLASS ) LookupDefclassByMdlOrScope(theEnv,ValueToString(tmpPtr->value));
    445:// cmpClass = (DEFCLASS
    ) EnvFindDefclass(theEnv,ValueToString(tmpPtr->value));

    It is preferable for me the dynamic constraint checking can recognize the classes imported form other modules.

  • Gary Riley

    Gary Riley - 2014-08-22

    A fix has been checked into the repository.

  • xyando

    xyando - 2014-08-24

    I hava comfirmed it with r190.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks