Hi David,
This is the same 'bug' reported by Alan Littleford about a month ago
("Strange behaviour of "call"" was the heading.) What's happening is
that Jess is seeing the first argument to 'call' is a Jess string, and
assuming, quite reasonably, that you're trying to call a static
function and the arg is the name of the class. If there is no such
class, Jess will proceed to try to call the function on a Java version
of the Jess string. WHat goes wrong is that if the argument string is
syntactically not a valid class name, Java throws an exception that
Jess isn't expecting, and the whole process aborts. This is why, for
example, your fucntion would work on FOO and FOO.BAR and even FOO$BAR
but not FOO-BAR or (FOOBAR) or FOO*BAR, etc.
Your workaround works, of course, because it turns the argument from
being a Jess string into a Java string, and the fact that you want to
call the method on the string itself is then unambiguous.
There's going to be a release 4.2 very soon, which will be
bugfix-only. There are about half-a-dozen little ones like this that
I've fixed.
I think David Young wrote:
>
> Greetings. The following simple function incorrectly fails when handed
> strings containing embedded hyphens ('-'):
>
> (deffunction str-intern (?str)
> (printout t "str-intern(): " ?str " (" (stringp ?str) ")" crlf)
> (call ?str intern))
>
> Jess> (batch schtum.clp)
> TRUE
> Jess> (str-intern "FOO")
> str-intern(): FOO (TRUE)
> "FOO"
> Jess> (str-intern "FOO-BAR")
> str-intern(): FOO-BAR (TRUE)
> Rete Exception in routine call while executing deffunction str-intern.
> Message: Invalid argument to intern at line 2: ( str-intern "FOO-BAR" ) .
> at java.lang.Throwable.<init>(Compiled Code)
> at java.lang.Exception.<init>(Compiled Code)
> at jess.ReteException.<init>(Compiled Code)
> at jess.reflect.Call.call(Compiled Code)
> at jess.Funcall.simpleExecute(Compiled Code)
> at jess.Funcall.execute(Compiled Code)
> at jess.Funcall.execute(Compiled Code)
> at jess.Deffunction.call(Compiled Code)
> at jess.Funcall.simpleExecute(Compiled Code)
> at jess.Funcall.execute(Compiled Code)
> at jess.Funcall.execute(Compiled Code)
> at jess.Jesp.parseAndExecuteFuncall(Compiled Code)
> at jess.Jesp.parseSexp(Compiled Code)
> at jess.Jesp.parse(Compiled Code)
> at jess.Main.main(Compiled Code)
> Jess>
>
> Regards,
>
> --
>
> -------------------------------------------------------------
> David E. Young
> Fujitsu Network Communications "I claim not to have controlled
> ([EMAIL PROTECTED]) events, but confess plainly
> that events have controlled me."
> -- Abraham Lincoln (1864)
> Apology is Policy
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (510) 294-2154
Sandia National Labs FAX: (510) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------