[rules-users] MVEL strict mode -- when, why?

Edson Tirelli tirelli at post.com
Thu Jun 10 15:01:49 EDT 2010


   Hi Barry,

   Sorry, I missed the context on this... as a "drools user", you should
never have to worry about mvel strict/strong type configuration...

   Just FYI, Drools internally uses a 2 phase compilation of mvel
expressions, where the first is run in non-strict/strong mode to detect
expression inputs, and then on the second time Drools sets MVEL to strong
typing and provides the type information for all inputs. Again, this is
internal and you should never need to know this.

   What is happening?

   Edson


2010/6/9 Barry Kaplan <groups1 at memelet.com>

>
> >From the MVEL docs (http://mvel.codehaus.org/MVEL+2.0+Typing):
>
> Strict Typing
>
> Strict typing in MVEL is an optional mode for the compiler, in which all
> types must be fully qualified, either by declaration or inference.
>
> Enabling Strict Mode
> When compiling an expression, the compiler can be put into strict mode
> through the ParserContext by setting setStrictTypeEnforcement(true).
>
> Satisfying type strictness can be accomplished both by requiring explicit
> declaration of types inside the expression, or by notifying the parser
> ahead
> of time of what the types of certain inputs are.
>
> For example:
>
> ExpressionCompiler compiler = new ExpressionCompiler(expr);
>
> ParserContext context = new ParserContext();
> context.setStrictTypeEnforcement(true);
>
> context.addInput("message", Message.class);
> context.addInput("person", Person.class);
>
> compiler.compile(context);
>
> In this example we inform the compiler that this expression will be
> accepting two external inputs: message and person and what the types of
> those inputs are. This allows the compiler to determine if a particular
> call
> is safe at compile time, instead of failing at runtime.
>        Note about Generic Types
> You must use Strong Typing Mode to enable awareness of generic types. Type
> parameters for collections and other types will not be visible in
> strict-typing mode alone.
> Strong Typing
>
> Strong typing is a newly introduced mode in MVEL 2.0. It is different from
> strict mode in the sense that strongly typed mode requires that all
> variables be type qualified. Contrast this with strict mode which only
> requires that properties and method calls be qualified at compile-time.
>
> See the full article: Strong Typing Mode
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/MVEL-strict-mode-when-why-tp95666p883155.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100610/db98f079/attachment.html 


More information about the rules-users mailing list