## Friday Jul 22, 2011

### 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$$

## Tuesday Jul 05, 2011

### Character data type now implemented in compiler

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


Character literals are supported in three forms: single-character, named, and hexadecimal. The single character form has either the actual Unicode character or an escape sequence between the single quotes:$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{a}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{+}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\oplus\textrm{'}}\mskip3mu$$. The named form has a name for the character between the single quotes:$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{alpha}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{SIGMA}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{OPLUS}\textrm{'}}\mskip3mu$$. Not all names are currently supported. The hexadecimal form has four to six hexadecimal digits between the single quotes; as an experiment that goes beyond the current specification, the digits may optionally be preceded by "U+":$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{007C}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{1D164}\textrm{'}}\mskip3mu$$ or$$\mskip3mu$$ $$\EXP{\textrm{'}\mathtt{U+1D164}\textrm{'}}\mskip3mu$$.

The following methods of type$$\mskip1.5mu$$ $$\TYP{Character}\mskip1.5mu$$ are now implemented for compiled code:

 $$\mskip3mu$$$$\EXP{\KWD{getter} \VAR{asString}(\ultrathin)\COLON \TYP{String}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{getter} \VAR{asExprString}(\ultrathin)\COLON \TYP{String}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{getter} \VAR{codePoint}(\ultrathin)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{<}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\leq}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{>}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\geq}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{=}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\neq}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{LNSIM}}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{LESSSIM}}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{GNSIM}}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\OPR{GTRSIM}}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\simeq}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\KWD{opr}\, \mathord{\not\simeq}(\KWDVAR{self}, \VAR{other}\COLON\TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{getDirectionality}(\KWDVAR{self})\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{getNumericValue}(\KWDVAR{self})\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{getType}(\KWDVAR{self})\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isDefined}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isDigit}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isFortressIdentifierPart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isFortressIdentifierStart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isHighSurrogate}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isIdentifierIgnorable}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isISOControl}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isJavaIdentifierPart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isJavaIdentifierStart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isLetter}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isLetterOrDigit}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isLowerCase}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isLowSurrogate}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isMirrored}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isSpaceChar}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isSupplementaryCodePoint}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isSurrogatePair}(\KWDVAR{self}, \VAR{low}\COLON \TYP{Character})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isTitleCase}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isUnicodeIdentifierPart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isUnicodeIdentifierStart}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isUpperCase}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isValidCodePoint}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{isWhitespace}(\KWDVAR{self})\COLON \TYP{Boolean}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{javaDigit}(\KWDVAR{self}, \VAR{radix}\COLON \mathbb{Z}32)\COLON \mathbb{Z}32}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{toLowerCase}(\KWDVAR{self})\COLON \TYP{Character}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{toTitleCase}(\KWDVAR{self})\COLON \TYP{Character}}\mskip3mu$$ $$\mskip3mu$$$$\EXP{\VAR{toUpperCase}(\KWDVAR{self})\COLON \TYP{Character}}\mskip3mu$$

The first six comparison operators perform exact comparison on codepoint values; the second six ignore case by first converting to lowercase and then comparing the resulting codepoints.