\chapter{S-Lang 2 Interpreter NEWS} This chapter describes features that were added to various 2.0 releases. For a much more complete and detailed list of changes, see the \file{changes.txt} file that is distributed with the library. \sect{What's new for \slang 2.2} #d tagexmp#1 \tag{\exmp{$1}} \begin{itemize} \item The ternary expression was added: #v+ expression = condition ? val1 : val2 #v- If \em{condition} is non-zero, then \em{expression = val1}, otherwise \em{expression = val2}. \item The break and continue statements support an optional integer that indicates how many loop levels the statement affects, e.g., the break statement in #v+ while (1) { loop (10) { break 2; } } #v- will cause both loops to be terminated. \item Multiline strings have been added: #v+ "This is a \ multiline \ string" `This is another multiline string that does not require a \ for continuation` #v- \item \dtype{List_Type} objects may be indexed using an array of indices instead of just a single scalar index. \end{itemize} The following intrinsic function were added in version 2.2: \begin{descrip} \tagexmp{sumsq} Equivalent to \exmp{sum(x*x)}. \tagexmp{expm1} More accurate version of \exmp{exp(x)-1} for \exmp{x} near 0. \tagexmp{log1p} More accurate version of \exmp{log(1+x)} for \exmp{x} near 0. \tagexmp{list_to_array} Creates an array from a list. \tagexmp{string_matches} A convenient alternative to the \exmp{string_match} and \exmp{string_match_nth} functions. \tagexmp{_close} Close an integer descriptor. \tagexmp{_fileno} Returns the descriptor as an integer. \tagexmp{dup2_fd} Duplicates a file descriptor via the \exmp{dup2} POSIX function. \tagexmp{getsid, killpg, getpriority, setpriority} These functions correspond to the corresponding POSIX functions. \tagexmp{ldexp, frexp} If \exmp{x == a*2^b}, where \exmp{0.5<=a<1.0} then \exmp{(a,b)=frexp(x)}, and \exmp{x=ldexp(a,b)}. \end{descrip} The following functions have been enhanced: \begin{descrip} \tagexmp{hypot} If given a single array argument \exmp{X}, it returns the equivalent of \exmp{sqrt(sum(X*X)}. \tagexmp{polynom} The calling interface to this function was changed and support added for arrays. \end{descrip} The following modules were added to version 2.2: \begin{descrip} \tagexmp{zlib} A module that wraps the popular z compression library. \tagexmp{fork} A module that wraps the \exmp{fork}, \exmp{exec*}, and \exmp{waitpid} functions. \tagexmp{sysconf} A module that implements interfaces to the POSIX \exmp{sysconf}, \exmp{pathconf}, and \exmp{confstr} functions. \end{descrip} The following library files and functions were add to \slsh: \begin{descrip} \tagexmp{process.sl} The code in this file utilizes the \exmp{fork} module to implement the \exmp{new_process} function, which allows the caller to easily create and communicate with subprocesses and pipelines. \end{descrip} \sect{What's new for \slang 2.1} \begin{itemize} \item Short circuiting boolean operators \exmp{||} and \exmp{&&} have been added to the languange. The use of \exmp{orelse} and \exmp{andelse} constructs are nolonger necessary nor encouraged. \item \em{Qualifiers} have been added to the language as a convenient and powerful mechanism to pass optional information to functions. \item Structure definitions allow embeded assignemnts, e.g, #v+ s = struct {foo = 3, bar = "hello" }; #v- \item Comparison expressions such as \exmp{a 1}. Instead, \exmp{str} will now become a \exmp{Char_Type[nread]} object. In order to read a specified number of bytes from a file in the form of a string, use the \ifun{fread_bytes} function: #v+ #if (_slang_version >= 20000) nread = fread_bytes (&str, num_wanted, fp); #else nread = fread (&str, Char_Type, num_wanted, fp) #endif #v- The above will work with both versions of the interpreter. \tag{strtrans} The \ifun{strtrans} function has been changed to support Unicode. One ramification of this is that when mapping from one range of characters to another, the length of the ranges must now be equal. \tag{str_delete_chars} This function was changed to support unicode character classes. Code such as #v+ y = str_delete_chars (x, "\\a"); #v- is now implies the deletion of all alphabetic characters from \exmp{x}. Previously it meant to delete the backslashes and \exmp{a}s from from \exmp{x}. Use #v+ y = str_delete_chars (x, "\\\\a"); #v- to achieve the latter. \tag{substr, is_substr, strsub} These functions use character-semantics and not byte-semantics. The distinction is important in UTF-8 mode. If you use array indexing in conjunction with these functions, then read on. \end{descrip}