FC++ Changes since last version

This document summarizes the changes since the previous release of the FC++ library. (As always, see the FC++ web site for the latest.)

# Changes from v1.4 to v1.5

The library has a number of improvements and additions:

- Lambda. FC++ now supports `lambda`, so you can create anonymous functions on-the-fly. FC++'s lambda has a tiny functional sublanguage with features like `letrec`, `do`-notation for monads, and comprehensions. See "FC++ Lambda" for more details.
- Infix syntax. FC++ functoids now support infix syntax, so instead of saying "`f(x,y)`" you can also say "`x ^f^ y`". See "New infix syntax" for details.
- Smart functoids. Functoids now "know" how many arguments they expect, which makes it possible to implement some useful and general combinators.
- Full functoids. The `FullN` wrappers add all the extra FC++ functoid functionality (currying, lambda-awareness, smartness, infix syntax) to existing functoids. See "Full functoids" for details.
- There are a number of new functoids, including `funify`, `of`, `thunkFuncToFunc`, `hCurry`, `hUncurry`, `delete_`, `outStream`, and `inStream`. (`operator.h` and `prelude.h`)
- The new features required a number of new header files; the new header description is here.
- More C++ compilers are supported, see the compilers page for details.
- The distribution of client examples now has an index describing the more interesting clients.

The library also has a number of bug fixes and small changes:

- `ptr_to_fun` is now a functoid
- When `ptr_to_fun` is used on an instance method, the resulting functoid can now accept a smart pointer (e.g. `Ref`) as the first (receiver) argument
- Some of the combinators in `prelude.h` (like `ignore`) now work properly, regardless of the arity of the functoids passed in as an argument, thanks to "smartness".
- The `Ref` and `IRef` classes now have `operator==` and `operator!=`; this fixes minor bugs that can arise from implicit conversions to pointers.

# Changes from v1.3.1 to v1.4

The library has a number of improvements and additions:

- Added support for the Intel 6.0 compiler (with thanks to Terje Slettebo, who did the testing on this compiler).
- Changed the List implementation to conform to the proposed resolution of C++ Core Language Issue 270: "Order of initialization of static data members of class templates".
  (This change could potentially make the library run less efficiently if your compiler does not optimize function static data well. As a result, the old List implementation is still available via the compiler flag `FCPP_1_3_LIST_IMPL`. The old implementation technically has order-of-initialization (OOI) bugs which may cause programs to coredump, but in practice, these are easy to work around. If you are using FC++ in a setting where you need very high performance but are having trouble getting the old implementation working without crashes, email Brian and he'll show you how to get your code working fast.)
- A number of new (non-Haskell) utility functoids have been added to prelude.h: `id`, `noOp`, `before`, `after`, `uncurry`, `duplicate`, `ignore`, `constructN` and `newN`. Also, the `Maybe` type from Haskell has been added.
- Added functoids for `delay` and `force` (list.h).
- Added functoids for `dereference` and `addressOf` (operator.h).
- Monomorphic unary/binary functoids are now implicitly also STL functors (e.g. they define `F::result_type`, etc.).
- Tweaked the `Sig` structures in a way that enables a new class of combinators to be written (`compose`, `before`, `after`, and `uncurry` can discover whether or not their arguments are zero-arg functoids, and can act accordingly). Now rather than referring to `F::Sig::ResultType` for a zero-arg functoid of type `F`, you should refer to `F::Sig<>::ResultType` or just `RT<F>::ResultType` instead.
- The flag `FCPP_DEFER_DEFINITIONS` will prevent the .h files from creating definitions of the library functoids; the declarations remain, but you must separately compile `definitions.cc` and link it in. This is useful for applications using FC++ in multiple translation units--it prevents each TU from having its own (redundant) copy of each of the library functoid objects in favor of a single "master" copy.

The library also has a number of bug fixes and small changes:

- Added `ptr_to_fun` overloads for const member functions.
- Fixed minor type-system bugs in `binder1and2of2`, `stlN`, and `cat`.
- Made curry binders store `const` data members.
- Deprecated `Compose0`, as `Compose` now subsumes it.
- Fixed `flip` so it returns a curryable result.
- Fixed a number of the prelude functions (like `length`) so that they don't complain if you pass them an `OddList` instead of a `List`.
- Gave names `const_`, `and_`, and `or_` to corresponding functoids. Whenever a functoid's name clashes with a C++ keyword, we add a trailing underscore.

Finally, we have a new email discussion list, see the FC++ web site for details about how to subscribe.

# Changes from v1.3 to v1.3.1

###### Note: v1.3.1 was only released for the XR library.

- Fixed a small bug in the template version of `enumFrom()`
- Added copy constructor and assignment operator code to the `FunN` classes (shouldn't be necessary, but without it, exposes a compiler bug on at least one platform)

# Changes from v1.2.1 to v1.3

## Improvements

- The run-time performance of the library has been drastically improved. This has all been done "under the hood"; the interface to the library has barely changed. The main sources for the improvements are

  - intrusive reference counting
  - new implementation of `List`s
  - new techniques for "reusing" functoids in the prelude implementation

- The library now works with both g++2.95.2 and g++3.0. It should also work with any other standard-conforming C++ compiler. See this page for details.

- There are now many more example files.

## New additions

- The `Fun3` class has finally been implemented. Like `Fun2` it supports automatic currying.
- Class `IRef` (the intrusive version of `Ref`) has been added.
- `ListIterator` now supports `operator->`.
- The flag `FCPP_DEBUG` turns on extra run-time checking so that if you try to `head()` or `tail()` an empty list, an exception (of type `fcpp_exception`) is thrown. Without the flag, there is no run-time check (and the code fails un-gracefully).
- The flag `FCPP_SAFE_LIST` adds a destructor to the `List` class which ensures that list nodes are destroyed iteratively. The reference-counting in list nodes (`Cache`s) works recursively, and as a result, can blow the stack for large lists. In other words,

         {
            List<int> l = enumFromTo(1,200000);
            length(l);   // force evaluation of the list (actually create nodes)
         }  // Boom!  Recursion with a call-depth of 200000.

  is likely to "blow up" unless the `FCPP_SAFE_LIST` flag is set. Setting this flag degrades the overall performance of lists, however. In order to ensure that a specific instance of a list doesn't blow up, you can always just iteratively destroy that list, as in

         {
            List<int> l = enumFromTo(1,200000);
            length(l);   // force evaluation of the list (actually create nodes)
            while(l) l = tail(l);   // iteratively destroys list
         }  // no problem here

## Changes

- The library no longer has a

      using namespace fcpp;

  at the end of `prelude.h`. As a result, you should add this yourself to your `.cc` files that use the library.
- The signature of `cat` has changed slightly. The first parameter must be a list, but the second parameter can be either a list or a function that returns a list. (It used to be that both parameters could be either lists or functions.)
- Due to the new list implementation, the signatures of many of the functions in the prelude have changed. However, this should break very little client code. See this page for details.
- The `Sig`s of `Plus`, `Minus`, etc., now better reflect the true signatures of those functoids.

## Removals

- `OneElement` (`one_element`) has been removed. You should use `cons(x,NIL)` instead.
- `Nil<T>` has been removed. You should just use NIL instead, unless type inference fails, in which case you can always use `List<T>()`.

## Obscure flags

- The flag `FCPP_LEAK` turns off the reference counting in the `IRef` class. As a result, the application leaks away memory (but might run faster).
- The flag `FCPP_TEMPLATE_ENUM` makes `enumFrom()` and `enumFromTo()` be template functoids rather than just functoids that work on `int`s. They really probably should be template functoids, however g++2.95.2 seems to generate slow code for them when they templated, for no obvious reason. (g++3 generates fast code regardless of whether the functoids are templated or not.)
- The flag `FCPP_OOI_DEBUG` turns on some debugging output for the creation of global objects (that may be initialized before `main()`). This helped us debug order-of-initialization errors.
- The prelude functions are written with performance in mind, using `OddList`s, `Reuser`s, and iteration. The old implementations of many of the functions are still there, enclosed in `#ifdef FCPP_SIMPLE_LIST`s. We've kept the old implementations in the file mostly for instructional value (they illustrate the simplest ways to create functoids, and also help show the changes necessary to create optimized versions of functoids).

# Changes from v1.2 to v1.2.1

The library now compiles with the "-pedantic -ansi" options for g++, which means it will probably compile with more other compilers now, too. The previous release had a number of "typename" problems; C++ requires the "typename" keyword to appear in lots of places inside templates.

# Changes from v1.1 to v1.2

## New additions

- Automatic currying. Now (practically) all functoids are curryable by default. For example,

         minus(3,2);   // yields 1
         minus(3);     // yields a new function f, where f(x) = 3-x
         minus(3,_);   // same as above
         minus(_,2);   // yields a new function f, where f(x) = x-2

  This is accomplished by the `CurryableN` classes, which serve as wrappers around normal functions. The function `makeCurryable()` turns an uncurryable function into an automatically curryable version. See http://www.cc.gatech.edu/~yannis/fc++/currying.html for more info.
- Namespaces. Now the library is in namespace `fcpp`. However, bugs in the g++2.95.2 compiler force us to keep part of the library in the global namespace. If you have a working compiler, use the compiler option -DFCPP_USE_NAMESPACE to have the whole library be in the namespace. There's a

         using namespace fcpp;

  at the bottom of `prelude.h`, which dumps it all into the global namespace anyway. We've done that for backwards compatibility (you can drop in the new library and your old code should still work without changes), but feel free to remove it (we certainly will, in a future revision).
- There is now an implicit conversion from direct functoids to indirect functoids (`FunN`s). For example,

         Fun1<int,int,int> f          = fcpp::plus;
         Fun1<double,double,double> g = fcpp::plus;

  both "do the right thing".
- A number of "holes" in the library have been filled in; now practically all of the general functions/classes (like `ptr_to_fun()`, `monomorphizeN()`, `CurryableN`, etc.) work for all sets of functions with 0-3 arguments. (Previous versions of FC++ had spotty support.)
- This file: we plan to keep track of changes between versions from now on, and put the changes in the distribution.

## Changes (from v1.0 to v1.1)

- The `List` class has been completely re-implemented. The old version had a number of problems (the major ones being that (1) it was too eager (not lazy enough) in a number of cases, and (2) that functions like `cons` had un-intuitive interfaces) that have now been solved. In our limited tests, the new `List` seems to perform comparably with the old, but let us know if you notice a speed difference.
- `List::WrappedType` has been renamed to `List::ElementType`. The new name makes more sense, especially in papers/tutorials.
- Header dependencies have been minimized; the library should only suck in the headers it needs now, which means faster compile-times.
- A number of minor bugs have been fixed throughout the library.
- The function `list_until` has been renamed `listUntil` (consistent with naming convention of other list functions).

FC++ homepage