0.19.2 Released

Sunday, September 24, 2017 | Posted in Release

Pony 0.19.2 features a high priority fix for a bug in Pony serialization. Before 0.19.2, serialising an empty string would cause a segmentation fault.

Fix empty string serialisation

The Pony 0.15.0 release introduced a bug in Pony serialization. From Pony 0.15.0 to 0.19.1 the following code would cause a segfault:

use "serialise"

actor Main
  new create(env: Env) =>
    try
      let auth = env.root as AmbientAuth
      Serialised(SerialiseAuth(auth), "")?
    end

RFC #46 implemented

Pony 0.19.2 also includes the implementation of RFC #46: More random methods. The following methods were added to the Random trait, similar to the existing u8, u16, u32, u64, and u128 methods:

  fun ref ulong(): ULong =>
    """
    A random integer in [0, ULong.max_value()]
    """

  fun ref usize(): USize =>
    """
    A random integer in [0, USize.max_value()]
    """

  fun ref i8(): I8 =>
    """
    A random integer in [-2^8, 2^8)
    """

  fun ref i16(): I16 =>
    """
    A random integer in [-2^16, 2^16)
    """

  fun ref i32(): I32 =>
    """
    A random integer in [-2^32, 2^32)
    """

  fun ref i64(): I64 =>
    """
    A random integer in [-2^64, 2^64)
    """

  fun ref i128(): I128 =>
    """
    A random integer in [-2^128, 2^128)
    """

  fun ref ilong(): ILong =>
    """
    A random integer in [ILong.min_value(), ILong.max_value()]
    """

  fun ref isize(): ISize =>
    """
    A random integer in [ISize.min_value(), ISize.max_value()]
    """

Additionally, the existing int method of the Random trait was updated to allow specifying the integer type as a type parameter, instead of only supporting the U64 type:

  fun ref int[N: (Unsigned val & Real[N] val) = U64](n: N): N =>
    """
    A random integer in [0, n)
    """

The array-oriented shuffle method was added to the Random trait.

  fun ref shuffle[A](array: Array[A]) =>
    """
    Shuffle the elements of the array into a random order, mutating the array.
    """

To support Random.shuffle, the swap_elements was added to the Array class (because otherwise, it is not possible to swap two elements in place without aliasing them):

  fun ref swap_elements(i: USize, j: USize) ? =>
    """
    Swap the element at index i with the element at index j.
    If either i or j are out of bounds, an error is raised.
    """

Fixed

  • Fix codegen failure on field access (PR #2244)
  • Make Windows link step use the command-line --linker value if present. (PR #2231)
  • Fix empty string serialisation (PR #2247)

Added

  • Added Array.swap_elements, Random.shuffle and extends Random with methods for generating all Integer types (RFC 46). (PR #2128)

AUTHOR

Sean T. Allen

Sean is a member of the Pony core team. His turn-ons include programming languages, distributed computing, Hiwatt amplifiers, and Fender Telecasters. His turn-offs include mayonnaise, stirring yogurt, and sloppy code. He is one of the authors of Storm Applied, and VP of Engineering at Wallaroo Labs.