There are a number of facilities in Maple which may be extended. Included amongst those are `type`, `print`, `evalf`, and `latex`. The help-page ?extension_mechanism claims that all the built-in functions allow for extension. It also mentions a few system Library routines such as `verify` (but does not mention `latex`).
There are some descriptions of varying completeness in a few of the relevant individual help-pages. Let's look at a few simple examples for routines which get some mention of extensibility in a corresponding help-page. These are simple examples, but with some thought, more inspiring and creative examples can be produced.
Let's start with `print`. A new routine named `print/foo` will control how unevaluated calls to foo() get displayed.
> `print/D2` := proc(x) D(x); end proc:
(y, x) -> - -------------
/ 2 \
2 | y |
x |1 + ----|
| 2 |
\ x /
Note that the call to D2() didn't return anything but an unevaluated function call, because there is no procedure `D2`. It's only in what gets printed that some other action or effect else is seen.
> D2(proc(a,b) a+b^2; end);
proc(a, b) 2*b end proc
D2(proc (a, b) a+b^2 end proc)
If you've ever used Maple's debugger on a LinearAlgebra computation, and followed the whole thing right through, you can often watch the control get to a routine named `print/rtable`. Viewing this routine is interesting because it shows a way to specialize the printing method according to which Maple interface is being used. Notice the call to IsWorksheetInterface() early on in the results that get displayed by Maple after one issues the following commands.
There are some caveats. I don't see how to override the way a Maple table() is printed, by creating a `print/table` procedure. The ?print help-page doesn't say much about what is and what is not possible here.
Now on to `evalf`, whose extensibility is documented in the help-page ?evalf,details . Here there is the same functionality as for `print`, in terms of creating a rule to deal with calls to particular function names. There's also some functionality for adding evalf rules for new defined constants. I won't give an example here, as the ?evalf,details help-page includes some.
The `type` facilities in Maple can get a similar treatment. But adding new routines like `type/foo` is now a deprecated method and not documented on the ?type help-page. In its stead there is now TypeTools:-AddType(). The new facility has some improvements, especially with regard to control of Maple's namespace. See Joe Riel's very nice posts related to this, here and here.
And then there is `latex`, whose help-page mentions the ability to control treatment of calls to a named procedure. Examples of how it works (very similar to extensions to `print` as above) are given on the help-page ?latex,functions . This page is nice about listing the named extensions about which Maple already knows. But it's a little strange, as it gives an example on how to get Maple's latex() to handle hypergeom() calls so that they get displayed in a .dvi file in the "standard notation". So, why isn't this one of the extensions which Maple knows about by default?
It would be good if all the extensible routines' primary help-pages gave at least one example of the mechanism in use. Also, the help-pages for evalf, latex, print, etc, do not have a cross-reference to ?extension_mechanism , not even in the See Also section. So unless one thinks to try ?extension then that page might hardly ever get found. Lastly, the help-page ?extension_mechanism should give a better definition to the term "built in", since otherwise it's hard to find a good description of that (I found ?type,builtin , but no complete listing).