Re: OON: generalizing restrict

From: Michael Soliman (michel@alannah.dki.tu-darmstadt.de)
Date: Tue Apr 11 2000 - 04:09:35 EST


Moin Moin.
Bill Homer wrote:

> jsiek wrote:
>
> > Of course, ultimately it would be nice if programmers were given the
> > language constructs needed to express exactly what they mean. Then
> > they could stop lying and playing tricks. That way experienced
> > programmers and library implementors could provide the kind of
> > information needed for compilers. restrict is a step in the right
> > direction... but, as I said before, much work needs to be done to

Ok. How about the Mathematica method of providing a function, that has to be
true, in order to pass the restriction:
    template<typename T:f>function_use(T restricted_Parameter);
with a relation f like
    int f(int){return 0;}
    long int f(long int){return 1;}
    double f(double){return 2;}
can be compiled at runtime.
In Mathematica this approach solved ALL CONCRETE restriction problems (, i.e.,
those, where no symbolic pattern matching is used. ).

Mathematica-Syntax ( The "In"s and "Out"s mark the Lines as Mathematica-In- and
-Output; "\[Pi]" denotes the number pi; "NumericQ[Objectname]" yields true, if
and only if "Objectname" denotes a numeric quantity at the evaluation's time;
"aaa" is undefined here but could be a string as well, in order to produce the
same results ):
        In[1]:= jhgjkhgkjhgjkhgjkhgjkhgjhg[aaa : _?NumericQ] := \[Pi]
        In[2]:= jhgjkhgkjhgjkhgjkhgjkhgjhg[aaa]
        Out[2]:= jjhgjkhgkjhgjkhgjkhgjkhgjhg[aaa]
        In[2]:= jhgjkhgkjhgjkhgjkhgjkhgjhg[\[Pi]]
        Out[2]:= \[Pi]

        Tschuess,
            Michael.

--
_____________________________________________________________________________
Michael Soliman.
Email: michel@soliman.de
       michel@alannah.dki.tu-darmstadt.de
       michel@sunny.dki.tu-darmstadt.de
Adresse: Hauptstrasse 11a
         64401 Rodau
         GERMANY
Telephon: +(49)616660178
Fax:      +(49)6166920683
 ------------------------------------------------------------------------

--------------------- Object Oriented Numerics List -------------------------- * To subscribe/unsubscribe: use the handy web form at http://oonumerics.org/oon/ * If this doesn't work, please send a note to owner-oon-list@oonumerics.org



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:12 EST