As you can see, this technique implements quite full and simple functional objects for Maple.
It is very simple and efficient. All properties are private, you need to implement public get and set methods to make them public.
Public methods and stored in the last table structure of the procedure.
I'm deeply interested by comments...
retart;

Functional object programming with Maple
Simplest functional object
simplest_fo:=proc(n) local this, set_;
this := [n];
set_:=proc( p); this[1]:=p; end proc;
table(['get'= (x->this[1]), 'set'= set_]);
end proc;

foo:=simplest_fo( 2);

foo['get']();

foo['set'](5);

foo['get']();

Application to probability distributions
G:=(m,s)->(t->(exp(-(t-m)^2/(2*s^2))/(sqrt(2*Pi)*s)));

structured_distribution:=proc( f, A, B)
table(['density'= (x->f(x)), 'repartition'=(x->Int(f(t),t=A..x)), 'plot'=(t->plot(f(x),x=A..B))]);
end proc:
SD:=structured_distribution( G(0,1), -infinity, infinity):
SD['density'](1);

SD['repartition'](1);

SD['plot']();

This post was generated using the MaplePrimes File Manager
View 744_indexed-output.mw on MapleNet or Download 744_indexed-output.mw
View file details
Comments
Via modules too
It is possible to do the same thing, with a cleaner syntax and more information hiding via Maple's modules. This is fully documented in the Advanced Programming Guide (and I believe the text of the examples is online as well).
Note that you have re-discovered something quite classical in the theory of programming languages, namely how to embed OO programming into a higher-order lambda-calculus with references. See for examples the excellent textbook Types and Programming Languages (Chapter 18).
Nothing re-discovered
Thanks for your comment.
I did not "re discorver" anything, because I totally aware of OO embedding into high level lambda calculus (my favorite programming language is ocaml).
The only point here is that from my point of view, it seems lighter than modules.
I see
I prefer the modules way of doing it - but that is indeed a matter of taste. Internally, there is actually little difference between the two! The DAG for modules and proc are essentially the same.
My current favourite languages (in order) are Haskell, MetaOCaml, Maple, Scala, and Python.