I think Eric Eslinger wrote:
> 
> Hi all.  Latest problem, running jess4.4...
> 
> (try
>     (get-var *foo*)
>  catch
>     (defglobal ?*foo* = moo))
> 
> This should define the global ?*foo* to moo, because get-var throws an
> unbound variable exception.  But it seems that the system doesn't like
> the defglobal in the catch part of a try-catch block.

An analogous construct wouldn't work in CLIPS either, because CLIPS
(and Jess, to a lesser extent) distinguishes between "functions" and
"constructs". Most of the def* things are constructs, handles by the
parser, not function calls that are really 'executed'. Removing the
distinction is something I've thought about. Some of these would be
very easy (defglobal) and some much harder (defrule) to convert.

All built-in functions are listed in the manual in the "Function Guide"
part. Everything else is a construct.

> 
> On a related note, what I am trying to do is set up some sort of include
> guard.  When a file is loaded I want to do something like:
> 
> If this file has never been loaded before,
>     do this stuff.
> Otherwise
>     Do nothing.
> 
> 
> I was planning on doing it with that try-catch block, since I couldn't
> poke a variable to see if it is bound any other way (maybe a predicate
> like boundp would be in order.)
> 
> Anyway, any tips / workarounds would be appreciated.
> 

Well, you could introduce a level of indirection by using "build":

 (try
     (get-var *foo*)
  catch
     (build "(defglobal ?*foo* = moo)"))

(build) sends its areguments through the parser, so it can handle
constructs. 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 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]
---------------------------------------------------------------------

Reply via email to