More arithmetic operations now implemented in compiler

<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js" type="text/javascript"></script>

The Fortress compiler now implements some additional arithmetic operations.


 $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectnot}(\KWDVAR{self})\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectand}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersector}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectxor}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MIN}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MINMAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}32)\COLON (\mathbb{Z}32, \mathbb{Z}32)}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{even}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{odd}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$

The first four are bitwise NOT, AND, OR, and XOR operations. $$\OPR{MINMAX}\mskip3mu$$ returns a 2-tuple of its two arguments, sorted so that the first element of the tuple is not larger than the second value.

For type$$\mskip3mu$$ $$\EXP{\mathbb{Z}64}\mskip3mu$$:

 $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectnot}(\KWDVAR{self})\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectand}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersector}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\twointersectxor}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MIN}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON \mathbb{Z}64}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MINMAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{Z}64)\COLON (\mathbb{Z}64, \mathbb{Z}64)}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{even}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{odd}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$

For type$$\mskip3mu$$ $$\EXP{\mathbb{R}64}\mskip3mu$$:

 $$\mskip3mu$$$$\EXP{\KWD{getter} \VAR{isNaN}(\ultrathin)\COLON \TYP{Boolean} }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MIN}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON \mathbb{R}64 }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON \mathbb{R}64 }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MINNUM}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON \mathbb{R}64 }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MAXNUM}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON \mathbb{R}64 }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MINNUMMAX}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON (\mathbb{R}64, \mathbb{R}64) }\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{MINMAXNUM}}(\KWDVAR{self}, \VAR{other}\COLON\mathbb{R}64)\COLON (\mathbb{R}64, \mathbb{R}64) }\mskip3mu$$

$$\OPR{MIN}\mskip3mu$$ and$$\mskip3mu$$ $$\OPR{MAX}\mskip3mu$$ return NaN is either argument is NaN;$$\mskip3mu$$ $$\OPR{MINNUM}\mskip3mu$$ and$$\mskip3mu$$ $$\OPR{MAXNUM}\mskip3mu$$, if either argument is NaN, return the other argument (and so the result is NaN only if both arguments are NaN).$$\mskip3mu$$ $$\OPR{MINNUMMAX}\mskip3mu$$ and$$\mskip3mu$$ $$\OPR{MINMAXNUM}\mskip3mu$$ both return a 2-tuple of the two arguments, sorted so that the first element of the tuple is not larger than the second value; but if one argument is NaN and the other is some non-NaN value$$\mskip1.5mu$$ $$\VAR{v}\mskip1.5mu$$, then$$\mskip3mu$$ $$\OPR{MINNUMMAX}\mskip3mu$$ returns$$\mskip3mu$$ $$\EXP{(v,\TYP{NaN})}\mskip3mu$$ but$$\mskip3mu$$ $$\OPR{MINMAXNUM}\mskip3mu$$ returns$$\mskip3mu$$ $$\EXP{(\TYP{NaN},v)}\mskip3mu$$.

For type$$\mskip1.5mu$$ $$\TYP{String}\mskip1.5mu$$:

 $$\mskip3mu$$$$\EXP{\KWD{opr} \unicode{x5E}(\KWDVAR{self}, n\COLON \mathbb{Z}32)\COLON \TYP{String}}\mskip3mu$$

(This last operation returns the concatenation of$$\mskip1.5mu$$ $$\VAR{n}\mskip1.5mu$$ copies of the string.)

One can also make a character, given its codepoint, by using$$\mskip1.5mu$$ $$\VAR{makeCharacter}\mskip1.5mu$$:

 $$\mskip3mu$$$$\EXP{\VAR{makeCharacter}(n\COLON \mathbb{Z}32)\COLON \TYP{Character}}\mskip3mu$$

I'm curious, at what stage is this project? Is anyone actually using Fortress today for small projects in scientific computing? Would you recommend that people do, at the project's current state? If not, when do you expect it'd get there?

Posted by Szabolcs on August 08, 2011 at 01:44 AM EDT #

I noticed ZZ32 and ZZ64 have methods even() and odd(), but Character has lots of method names starting with 'is', e.g. isFortressIdentifierPart(). Sure, most of the latter names come straight from Java, but are you adopting the convention that methods returning Boolean start with 'is' or not?

I only ask because names of methods/classes tend to get set in stone and are difficult to change later...

(FWIW given the mathematical flavour of Fortress I'd suggest not using 'is'.)

Posted by Jonathan on August 19, 2011 at 01:58 AM EDT #

@Jonathan: You make a good point about the inconsistency of the use of the prefix "is" in the names of predicate methods. Part of the problem is tradition: mathematicians tend not to use "is", especially for short adjectives such as "even" and "odd" and "prime". On the other hand, the character predicates and their names were taken pretty much wholesale form Java. We need to think this issue through more carefully.

Posted by Guy Steele on September 02, 2011 at 11:50 AM EDT #

@Szaboics: The intepreter works (and has for several years), but supports a version of the type system that is now obsolescent. We are pushing to get the compiler to process some small demonstration scientific applications so that we can measure parallel scaling.

Posted by Guy Steele on September 02, 2011 at 11:52 AM EDT #

Hello, I'm wondering if this project is still alive?

Posted by Astrych on July 11, 2012 at 10:21 AM EDT #

Guy Steele was here in London talking about Fortress (which I missed alas), so I assume it's alive and kicking:
http://days2012.scala-lang.org/node/434

Nobody is waiting more eagerly than me to try out a near-complete version. It seems like the language I'd want to use for everything - a little like Scala but with added simplicity.

Posted by Jonathan on July 20, 2012 at 05:36 PM EDT #

• HTML Syntax: NOT allowed