User Resources
› What is Dylan? › Learning Dylan › Downloads › Documentation › Wiki › Community › Dylan Competes › Supported Platforms › Screenshots › Current Limitations › Our Goals
Developer Resources
› Repository Access › Browse Repository › Bug Tracker › CVSZilla Search › Buildbot › Current Projects › Dev Tools › Submit News

[ All Fragments ]

Limited Types

It's possible to write efficient numerical code in Dylan by using limited types. These are restricted versions of regular collection classes that have a known size or element type.

define constant $audio-buffer-size = 2048;
define constant <audio-buffer> =
  limited(<vector>,
	  of: <single-float>,
	  size: $audio-buffer-size);

define function mix-buffers
    (input1 :: <audio-buffer>, input2 :: <audio-buffer>,
     output :: <audio-buffer>)
 => ()
  for (i from 0 below $audio-buffer-size)
    output[i] = 0.5 * input1[i] + 0.5 * input2[i];
  end for;
end function mix-buffers;

Under future releases of Harlequin Dylan, this code will perform no bounds checking or type checking. It will also use an efficient representation of the vectors of floating point numbers. Optimization tests show that Harlequin Dylan already generates code comparable to popular C compilers in similar situations.

Gwydion Dylan still needs some more work to achieve equivalent performance, unfortunately. The basic primitives all exist, but they don't always get used in the right places.