On 15 January 2011 11:32, Evert Penninckx <evert.penninckx@gmail.com> wrote:

I thought I had an error from the drools plugin when using instanceof even
in eval, but I'll try that again, I think I tried eval(this instanceof ...).

You cannot use this in an eval. The eval is "moved out" from the containing pattern,
and there this has no meaning.
 

Overloading getLikes() would be more elegant. Still, for me these are
workarounds.

Would it be that strange or unconventional to have the from only match on
the required subclass?

Given that getLikes() is your choice of method producing the data, and that
FrenchCheese is your choice of type for the receiver: would it be that strange
or unconventional to expect you to employ matching types? ;-)

Type checking should not result in the silent elimination of data at runtime. What
I would expect Drools to tell me is the incompatibility of the from and the receiving
pattern, at compile time.

-W


 

Grtz

Evert


Wolfgang Laun-2 wrote:
>
> If smell is a property of Cheese and not just of FrenchCheese you could
> use
>
>
> when
>        $person : Person ()
>        $c: Cheese( eval( $c instanceof FrenchCheese), smell == "good" )
> from
> $person.getLikes()
> then
>
> Also, I think that a selective retrieval with an overloaded version of
> getLikes():
>    getLikes( Class clazz )
> might be useful, avoiding useless elements in the returned collection.
>
> -W
>
>
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/About-for-and-inheritance-tp54110p2260831.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users