DreamBerd icon indicating copy to clipboard operation
DreamBerd copied to clipboard

Generalized White Space Overloading from C++ 2000

Open SimHacker opened this issue 11 months ago • 0 comments

Generalizing Overloading for C++2000

https://www.stroustrup.com/whitespace98.pdf

Bjarne Stroustrup

AT&T Labs, Florham Park, NJ, USA

Abstract

This paper outlines the proposal for generalizing the overloading rules for Standard C++ that is expected to become part of the next revision of the standard. The focus is on general ideas rather than technical details (which can be found in AT&T Labs Technical Report no. 42, April 1,1998).

Introduction

With the acceptance of the ISO C++ standard, the time has come to consider new directions for the C++ language and to revise the facilities already provided to make them more complete and consistent. A good example of a current facility that can be generalized into something much more powerful and useful is overloading. The aim of overloading is to accurately reflect the notations used in application areas. For example, overloading of + and * allows us to use the conventional notation for arithmetic operations for a variety of data types such as integers, floating point numbers (for built-in types), complex numbers, and infinite precision numbers (user-defined types). This existing C++ facility can be generalized to handle user-defined operators and overloaded whitespace.

The facilities for defining new operators, such as :::, <>, pow , and abs are described in a companion paper [B. Stroustrup: "User-defined operators for fun and profit," Overload April, 1998]. Basically, this mechanism builds on experience from Algol68 and ML to allow the programmer to assign useful - and often conventional - meaning to expressions such as

double d = z pow 2 + abs y;

and

if (z <> ns:::2) // …

This facility is conceptually simple, type safe, conventional, and very simple to implement.

SimHacker avatar Mar 05 '24 12:03 SimHacker