This is the constructor of the PerlMaple::Expression class. The first argument $expr is any Maple expression (not Maple statements though) from which the AST is constructed. The second argument $verified is optional. When it's set true, the expression will skip validity check in Maple's engine, otherwise the first argument will be evaluated by Maple to verify its sanity. If the second argument is absent, it is implied to be false. That's to say, verification will be performed by default.

Note that since version 0.04, this constructor has become quite "lazy". It only (partially) build the root of the AST during initialization. The construction of the child objects and also other pieces for the root will be delayed until the user actually asks for them (e.g. when user calls the ops method). This approach significantly improves performance since most users seldom require a whole AST for their Maple expression in practice. That is to say, constructing a PerlMaple::Expression object is not *that* expensive comparing to earlier versions of this module.

Returns the expression corresponding to the current PerlMaple::Expression object. Note that the string returned may be different from the one passed to the constructor. Because it will be evaluated in Maple to check the validity. Hence, the following tests will pass:

Get the type of the current Maple expression via Maple's whattype function. It is worth mentioning that the type of the expression is evaluated when the object is constructing, so there's no extra cost to invoke this method repeatedly.

When the expression is of type 'exprseq', this method won't use Maple's type function since it will croak on expression sequences. Instead, the ->type method will return true if and only if the given type is exactly the same as 'exprseq'.

Returns the number of elements which ops method may return. Note that this method calculates the result by calling Maple's `nops' function, without actually counting the elements itself. Therefore, it's very efficient.

The following methods are supposed to be used internally only and are very likely to change in the future. You should skip this section completely unless you're interested in this module's implementation.

If and only if the user asks for type and the `type' field has not yet initialized, this method will be invoked automatically by the type method to evaluate the expression object's `type', and the result will be saved into the `type' field for future uses.

If and only if the user asks for ops and the `ops' field hasn't initialized, this method will be invoked automaticaly by the ops method to evaluate the expression object's `ops', and the result will be saved into the `ops' field for future fetches.

Since PerlMaple::Expression share the same OpenMaple engine itself, so it will change the context variable in Maple environment, such as %, %%, or so. It's a general problem for PerlMaple, and I can't see easy way to fix that. Therefore, please don't use %, %%, or whatever like these in your Maple commands.