dismantle - Maple Programming Help

Home : Support : Online Help : Programming : Low-level Manipulation : dismantle

dismantle

display a Maple data structure, optionally with addresses

 Calling Sequence dismantle(expr); dismantle[hex](expr); dismantle[dec](expr); dismantle[oct](expr);

Parameters

 expr - expression to display

Description

 • The dismantle functions display the structure of a Maple expression, showing each sub-expression, its length (in decimal), and optionally its address (in hexadecimal, decimal, or octal). The length corresponds to the number of terms in the sequence of addresses (see disassemble) of the sub-expression.
 • The dismantle[hex] function displays the addresses of each subexpression in hexadecimal, preceding the length.
 • The dismantle[dec] function displays the addresses of each subexpression in decimal, preceding the length.
 • The dismantle[oct] function displays the addresses of each subexpression in octal, preceding the length.
 • There are two additional options to dismantle that can be used in combination with the hex, dec, and oct options above to alter its behavior.
 • The dismantle[...,string] function outputs the dismantle data as a string rather than as output to the session.
 • The dismantle[...,address] function can be used with only a single argument that represents the address (see addressof) of the object to be dismantled. This is useful to display the structure of objects that cannot be passed as arguments (assignments for example).
 • The dismantle functions are intended as extra tools for the "hackware package". It is assumed that the user is familiar with Maple's internal representation, and can make use of the information provided by dismantle.
 • Maple names, integers, rationals, and floats are displayed on one line, as they would appear when typed or printed by lprint. For example, NAME(7): This is a string.
 • Local variables and parameters are displayed on one line, as the ordinal number of the variable or parameter in square brackets. For example, LOCAL(2): [3].
 • The exponents in a series are displayed on one line, as integers in square brackets.
 • A non-existent object (not to be confused with the Maple object NULL) is displayed as [NIL].
 • Other structures are printed as a header, followed by the components of the structure indented 3 spaces below the header.
 • The dismantle function is intended solely as an aid to debugging and/or understanding the internal structures of Maple. For example, it can be useful when writing external code using the OpenMaple API. As such, dismantle simply prints its output; it does not return a result. To produce an easily-manipulated inert form of a Maple structure, use ToInert instead.

Examples

 > f := proc(x) if x < 2 then x^2 else x^3 end if end proc:
 > $\mathrm{dismantle}\left(f\right)$
 NAME(4): f
 > $\mathrm{dismantle}\left(\mathrm{op}\left(f\right)\right)$
 PROC(11)    EXPSEQ(2)       NAME(4): x    EXPSEQ(1)    EXPSEQ(1)    EXPSEQ(1)    IF(4)       LESSTHAN(3)          PARAM(2): [1]          INTPOS(2): 2       PROD(3)          PARAM(2): [1]          INTPOS(2): 2       PROD(3)          PARAM(2): [1]          INTPOS(2): 3    EXPSEQ(1)    EXPSEQ(1)    EXPSEQ(1)    BINARY(2)       1    EXPSEQ(5)       LIST(2)          EXPSEQ(5)             INTPOS(2): 0             INTPOS(2): 1             INTPOS(2): 6             INTPOS(2): 55       LIST(2)          EXPSEQ(5)             INTPOS(2): 0             INTPOS(2): 1             INTPOS(2): 14             INTPOS(2): 46       LIST(2)          EXPSEQ(5)             INTPOS(2): 0             INTPOS(2): 1             INTPOS(2): 28             INTPOS(2): 32       LIST(2)          EXPSEQ(5)             INTPOS(2): 0             INTPOS(2): 1             INTPOS(2): 37             INTPOS(2): 41
 > $f≔{\left(a+b\right)}^{2}+{\left(a+b\right)}^{3}$
 ${f}{:=}{\left({a}{+}{b}\right)}^{{2}}{+}{\left({a}{+}{b}\right)}^{{3}}$ (1)
 > $\mathrm{dismantle}[\mathrm{hex}]\left(f\right)$
 SUM(100007FC5E0C81F4E,5)    PROD(100007FC5E0FB1A66,3)       SUM(100007FC5E0C81EFE,5)          NAME(100007FC5E0C660FE,4): a          INTPOS(10000000000000001,2): 1          NAME(100007FC5E0C7159E,4): b          INTPOS(10000000000000001,2): 1       INTPOS(10000000000000003,2): 2    INTPOS(10000000000000001,2): 1    PROD(100007FC5E0FB1A7E,3)       SUM(100007FC5E0C81EFE,5)          NAME(100007FC5E0C660FE,4): a          INTPOS(10000000000000001,2): 1          NAME(100007FC5E0C7159E,4): b          INTPOS(10000000000000001,2): 1       INTPOS(10000000000000005,2): 3    INTPOS(10000000000000001,2): 1
 > $\mathrm{dismantle}[\mathrm{hex},\mathrm{string}]\left(f\right)$
 ${"SUM\left(100007FC5E0C81F4E,5\right) PROD\left(100007FC5E0FB1A66,3\right) SUM\left(100007FC5E0C81EFE,5\right) NAME\left(100007FC5E0C660FE,4\right): a INTPOS\left(10000000000000001,2\right): 1 NAME\left(100007FC5E0C7159E,4\right): b INTPOS\left(10000000000000001,2\right): 1 INTPOS\left(10000000000000003,2\right): 2 INTPOS\left(10000000000000001,2\right): 1 PROD\left(100007FC5E0FB1A7E,3\right) SUM\left(100007FC5E0C81EFE,5\right) NAME\left(100007FC5E0C660FE,4\right): a INTPOS\left(10000000000000001,2\right): 1 NAME\left(100007FC5E0C7159E,4\right): b INTPOS\left(10000000000000001,2\right): 1 INTPOS\left(10000000000000005,2\right): 3 INTPOS\left(10000000000000001,2\right): 1"}$ (2)

An assignment

 > $f≔\mathrm{assemble}\left(\mathrm{kernelopts}\left(\mathrm{dagtag}=\mathrm{ASSIGN}\right),\mathrm{addressof}\left(a\right),\mathrm{addressof}\left(b\right)\right)$
 ${f}{:=}{18446884561569954958}$ (3)
 > $\mathrm{dismantle}[\mathrm{address}]\left(f\right)$
 ASSIGN(3)    NAME(4): a    NAME(4): b
 > $\mathrm{eval}\left(\mathrm{pointto}\left(f\right)\right)$
 ${b}$ (4)