Boost logo

Boost :

From: Paul A Bristow (boost_at_[hidden])
Date: 2004-03-11 13:22:25


>From a very quick study of this, this radical proposal avoids nasty
brackets "pi()" by adding a new C++ keyword implicit to make "pi" have
the same effect.

One could write:

double pi() implicit // << Note new keyword here.
{
  return 3.145926;
}

and double circumference = pi * diameter; // Note No nasty ()s

and more usefully:

and template<class T = double>
T pi() implicit // << Note new keyword here.
{
  return 3.1459265358793;
}

and specialisations like:

template<> float pi<float>()
{
  return 3.1459F;
}

template<> myVeryLongDouble pi<myVeryLongDouble >()
{ // UserDefined floating point Type.
  return 3.1459265358793432986549023478943257;
}

template<> int pi<int >()
{ // For indiana Legislature lawyers only ;-)
  return 3;
}

and define functions like

template<class T>
T area (T radius)
{
  return pi<T> * radius * radius;
}

Language design implications is way outside my competence, but
"implicit" sweetens a serious language nastiness.

Pragmatically, I sense that a kludge, such as several people, most
recently Daniel Frey, are working on promises a nasty but quicker
partial solution for math constants. It would not seem much trouble to
convert if the new keyword "implicit" is actually working, so I don't
conclude we should stop the on-going battle to present math constants.

Paul

Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539 561830 +44 7714 330204
mailto: pbristow_at_[hidden]

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Beman Dawes
| Sent: 10 March 2004 02:18
| To: Boost mailing list
| Subject: [boost] Implicitly-Callable Functions in C++0x?
|
| There's a proposal (N1611) "Implicitly-Callable Functions in C++0x" by

| Walter Brown in the C++ committee's pre-meeting papers. See
| http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1611.pdf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk