From: Eric S. Raymond Date: Sat, 6 Jun 1998 19:09:59 +0000 (-0400) Subject: Check in Andrew Arensburger's operator-overloading proposal. X-Git-Tag: 0.19~7 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=fb43eba6d386c85e0a7d1acfdd2328ff2157a6a2;p=intercal.git Check in Andrew Arensburger's operator-overloading proposal. --- diff --git a/website/overloading.html b/website/overloading.html new file mode 100644 index 0000000..b5d3bf6 --- /dev/null +++ b/website/overloading.html @@ -0,0 +1,95 @@ + + + + + + +Overloading proposal for INTERCAL + + + +
Back to Intercal Home Page +Up to Site Map +$Date: 1998-06-06 15:09:59 $ +
+
+

Operator Overloading in INTERCAL

+ +Andrew Arensburger <arensb@cfar.umd.edu> writes:

+ +While rereading the INTERCAL reference manual, it occurred to me that +INTERCAL is a bit dated, since the languages whose features it avoids +(Fortran, COBOL, etc.) are pretty much dead. Shouldn't INTERCAL start +avoiding features found in some more modern languages, like C++, Java +and Perl?

+ +In this vein, let me suggest a direction for future +development: overloaded operands. I suggest the following syntax:

+ +

+        <var>/<expr>
+        <expr1>\<expr2>
+
+ +In the first form, <var> is a variable (16- or 32-bit, scalar or +array). Subsequently, any time it appears as an operand to $ , ~ , & , +V , or ? , it will be silently replaced by <expr>. Thus,

+ +

+        DO .7/#&77
+        DO :8<-.7
+
+ +will have the same effect as

+ +

+        DO :8<-#&77
+
+ +In the second form, <expr1> is a 32-bit expression, divided into two +16-bit numbers (high 16 bits and low 16 bite). This defines a range. +Any time a variable whose number is in the range thus defined appears +as an operand, it is replaced with the value of <expr2>.

+ +Furthermore, any time the special token ) appears in <expr2>, +it is replaced with the number of the variable being affected. Thus,

+ +

+        DO #196608\#99
+
+ +will affect variables .3 through .10, :3 through :10, ,3 through ,10 , +and ;3 through ;10 , replacing them with #99 whenever they appear as +an operand to $ , ~ , & , V , or ? .

+ +

+        DO #196608\;)SUB".&)"
+        DO :1<-.9
+
+ +has the same effect as

+ +

+        DO :1<-;9SUB".&9"
+
+ +Since overloading is not indicated by a keyword, there can be +no PLEASE ABSTAIN FROM OVERLOADING directive, but overloading can be +undone by mapping variable numbers back to their original values.

+ +There are, of course, various issues that still need to be +ironed out, but it seems to me that operand overloading can be a +powerful technique, on a par with Perl closures or Java's on-the-fly +class definitions.

+ +


+ +
Back to INTERCAL Home Page +Up to Site Map +$Date: 1998-06-06 15:09:59 $ +
+ +

Eric S. Raymond <esr@snark.thyrsus.com>
+ + +