Re: How to declare Integers?

*To*: mathgroup at smc.vnet.net*Subject*: [mg13130] Re: How to declare Integers?*From*: "Le Van Tri" <lvtri at cs.uwm.edu>*Date*: Tue, 7 Jul 1998 03:44:33 -0400*Organization*: UWM*References*: <199806280651.CAA24297@smc.vnet.net.> <6nc6oe$7oe$1@dragonfly.wolfram.com>*Sender*: owner-wri-mathgroup at wolfram.com

Dear Joe Oswald and Sean Ross, About your idea of having variable typing instead of pattern matching in Mathematica I think that idea is nice but some what "obsolete" - by which I mean variable typing is obsolete by the coming out of pattern matching. Why ? In traditional languages like Fortran, C++, Lisp, Scheme, ML, ... variable typing was done statically at compile time. By using pattern matching, that could be done dynamically at run time. Which way is better ? For example, the following operator * on the domain Dom: Dom operator * (Dom a,Dom b) { return some-calculation(a,b) } could easily rewrite in pattern matching language (like Mathematica) as: Times[a_,b_]/;Dom(a)&&Dom(b)=some-calculation(a,b). In the first place, using C++, a and b was checked by the compiler at COMPILE-time to see that they really belong to the domain Dom. In the second place, using Mathematica, the expression a*b is reduced to expression "some-calculation(a,b)" at RUN-time by the use of checking functions Dom(a) and Dom(b). So with pattern matching, we can manipulate classes (~ variable types) dynamically, instead of statistically like in traditional languages. This future will be clearly helpful when one need to do calculation with many types of data at one time. Though I did not say that one does not achieve anything in using these futures for simple calculations. --------- How ever, in my opinion pattern matching is more important with the following reason. It is a higher level programming language than other programming languages like Lisp, Scheme, ML (functional); and Fortran, C, C++ (procedural) because it resembles MORE CLOSELY to the way human thinking was carried out. If you really care about AI, you will know that in solving a new problem, human will look into his past history for SIMILAR situations and apply techniques or solutions he has successfully used there in order to solve the new problem. This is nothing else but pattern matching and searching. To some one who hate adding pattern matching rules to your library, I can assure that one fixed set of rules can never solve every the problems (Golden theorem tell me so). Tri. Sean Ross wrote in message <6nc6oe$7oe$1 at dragonfly.wolfram.com>... > In short, you can't. There is no variable typing in mathematica. The >only way are work around patern matchings and transformation rules that >are specific to each problem. For example, you can define n/;Sin[n >x]==0 and similar ideas. This doesn't mean that the problems are >insoluble, it just means that you will have to specify via >transformation rules the behavior of an integer expression. > > There are several of us that have been trying to explain to Wolfram >people what object oriented variable typing means, but they just play >dense and claim that the whole area is so vague that they can't do it. >Certainly the variable typing that you (and I) are after is radically >different from the variable typing done by Fortran or C++, which is for >purposes of memory allocation and interpretation. > > >