I think Glenn Williams wrote:
>
> Ernest,
>
> I've got some questions about defclass and array's based on an email you
> responded to several weeks ago.
>
> > Now if you defclass a Bean with a method like getN123, the
> > corresponding deftemplate will look like
> >
> > (deftemplate my-object (multislot n123) ...)
> >
> Does this mean I have to create a deftemplate to support the defclass?
>
No, Jess does this automatically; that's how defclass works. An
internal deftemplate is generated for each defclass, and it is
actually this deftemplate that you match with on rule LHSs. This is
explained (fairly well, I thought, anyway!) in section 7.7.1 of the
Jess README that ships with Jess 4.1.
> > Now, for any of these three methods, if you want to set the
> > property/the variable/call a setter method, you have to assemble a
> > multifield with all the values, and set the whole thing at once.
> >
> Can you give me an example?
>
An example of a method that takes an array as an argument in the Java
API is the three-argument constructor for java.awt.Polygon. If I want
to create a Polygon with vertices at (0,0), (1,1), (1, 0) from Jess, I
could say
(new java.awt.Polygon (create$ 0 1 1) (create$ 0 1 0) 3)
> > Jess does not currently handle what the Beans spec calls 'indexed
> > properties', which are methods like int getn123(int idx), in the
> > defclass statement.
> Is this something your looking at in the future?
Not really: LISP has no appropriate array indexing syntax, so I'm not
even sure how you'd map these into the Jess language. Of course, you
always can just call such a method directly, which is
indistinguishably harder than some imagined special mapping. Even for
non-indexed properties, we're only talking about the difference
between (get ?x foo) and (call ?x getFoo).
>
> Thanks.
>
> glenn
>
>
> >> -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Ernest Friedman-Hill
> > Sent: Friday, September 25, 1998 4:24 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: JESS: Jess defclass/array question
> >
> >
> > I'm a little bit confused by your mentioning 'defclass' and 'instance
> > variables' in the same sentence, as defclass deals with Bean
> > properties, which are not variables but methods. But, in any case,
> > when you fetch an array from Java into Jess, you get it as a
> > multifield. If Jess calls a Java method
> >
> > int[] getN123() { return new int[] { 1, 2, 3 }; }
> >
> > using 'call', as in
> >
> > (call ?anObject getN123)
> >
> > the return value is the multifield (1 2 3). You can then access
> > individual elements using the multifield functions like nth$.
> >
> > Similarly, if you call get-member to retrieve a Java instance variable
> > which is an array.
> >
> > Now if you defclass a Bean with a method like getN123, the
> > correseponding deftemplate will look like
> >
> > (deftemplate my-object (multislot n123) ...)
> >
> > Now, for any of these three methods, if you want to set the
> > property/the variable/call a setter method, you have to assemble a
> > multifield with all the values, and set the whole thing at once.
> >
> > Jess does not currently handle what the Beans spec calls 'indexed
> > properties', which are methods like int getn123(int idx), in the
> > defclass statement.
> >
> >
> >
> >
> >
> > I think [EMAIL PROTECTED] wrote:
> > >
> > > [I'm using Jess4.1 Final]
> > >
> > > I've been using defclass to communicate between Jess and Java,
> > as described
> > > in Section 7.7 of the Jess manual.
> > >
> > > So far, I've used simple data types for instance variables, and this has
> > > worked fine.
> > >
> > > Now I'm trying to get access to an array that is an instance variable.
> > >
> > > According to the documentation in 7.7.1, "Array properties give rise to
> > > multislots in Jess."
> > >
> > > I take this to mean that I can have arrays as instance
> > variables in the Java
> > > class, and that these arrays become multislots in the Jess class.
> > >
> > > Am I interpreting this right? If so, does anyone have an
> > example that shows
> > > how to get access to the array, and the individual array elements?
> > >
> > > Thanks in advance.
> > >
> > > Tom Hamilton
> > > United Technologies Research Center
> > > ---------------------------------------------------------------------
> > > 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]
> > ---------------------------------------------------------------------
> >
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------