There isn't a control structure that does this right now, but it's
very easy to write one. The only problem is that the necessary
functions in the Context class are package-private, so you have to
either change them to be public or define the Userfunction itself in
the jess package. Cleaning up the Context class and exposing more of
an interface is on my to-do list.
Anyway, given the caveats above, here's a version of (progn) which
uses a local context. All I've done is added the lines that call
push() and pop(). You could use this as
Jess> (progn* (bind ?y 0) (bind ?z 0) (then some stuff))
class PrognStar implements Userfunction, Serializable
{
public String getName() { return "progn*" ;}
public Value call( ValueVector vv, Context context )
throws JessException
{
context = context.push();
Value v = Funcall.NIL;
for (int i=1; i<vv.size(); i++)
v = vv.get(i).resolveValue(context);
context.pop();
return v;
}
}
I think Buddy Kresge wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Is there a way in Jess to perform the equivalent of
> the Lisp (let...) command?
>
> Here is what I want to do. I am doing some integration work
> between Jess and Prot_g_ and I want to construct some expression
> that then gets evaluated by the Jess engine. Part of this expression
> will require the declaration of variables. However, I want these variables
> to have local scope not dynamic scope.
>
> Also, declaring a function is not too useful for the expression is build
> at run-time. So, I would be looking to do the equivalent Lisp-ish thing:
>
> Lisp> (let ((?y 0) (?z 0)) (then some stuff))
>
> Thanks in advance!!
>
> Buddy Kresge
> Essential Logic, Inc.
> 59 Sycamore Street, Suite 301
> Glastonbury, CT 06033
>
> Web: www.essential-logic.com
> E-Mail: [EMAIL PROTECTED]
> Office: (860) 633-6872 x-229
> Fax: (888) 343-9351
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [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 (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------