Category: Update

0.5.2: Case folding and hash! support

4 April, 2015 | By Nenad Rakocevic

This is minor release mainly motivated by the need to fix some annoying issues and regressions we have encountered in the last release:

  • the help function was displaying an error when used with no arguments, preventing newcomers from seeing the general help information

  • the console pre-compilation issue with timezones was back.

Some significant new features managed to sneak into this release too, along with some bugfixes.

Case folding

Red now provides uppercase and lowercase natives and more generally, better support for Unicode-aware case folding. Red runtime library contains now a general one-to-one mapping table for case folding that should cover most user needs.

red>> uppercase "hello"
== "HELLO"
red>> uppercase/part "hello" 1
== "Hello"
red>> uppercase "français"
red>> uppercase "éléphant"
red>> lowercase "CameL"
== "camel"

This applies also to words, so now case insensitivity is Unicode-aware in Red:

red>> É: 123
== 123
red>> é
== 123
red>> "éléphant" = "ÉLÉPHANT"
== true
red>> "éléphant" == "ÉLÉPHANT"
== false

For special cases, we will expose, in a future release, the collation table we use internally, so that anyone can provide a customized version that is a better fit for some local special rules or usages. For example, some lower case characters (such as “ß”) actually map to two or more upper case code points (“SS” in this case). So in Red, by default, you will get:

red>> lowercase "ß"
== ß
red>> uppercase "ß"
== ß

You can read more about our plans for full Unicode support on the wiki.

Hash datatype

The new hash! datatype works exactly the same way as in Rebol2. It provides a block-like interface but with fast lookups for most values (block series can be stored in hash! too, but they will not be hashed, so no faster access). It is a very flexible container for any kind of hashed tables (not only associative arrays) while keeping the handy navigational abilities of blocks. The underlying hashing function is a custom implementation of the MurmurHash3 algorithm.

Some usage examples:

red>> list: make hash! [a 123 "hello" b c 789]
== make hash! [a 123 "hello" b c 789]
red>> list/c
== 789
red>> find list 'b
== make hash! [b c 789]
red>> dict: make hash! [a 123 b 456 c 789]
== make hash! [a 123 b 456 c 789]
red>> select dict 'c
== 789
red>> dict: make hash! [2 123 4 456 6 2 8 789]
== make hash! [2 123 4 456 6 2 8 789]
red>> select/skip dict 2 2
== 123

A map! datatype (strictly associative array) should also be provided in the next release, though, we are still investigating some of its features and use-case scenarios before deciding to release it officially.

Good news also about our Mac build server, a new one was kindly provided by Will (thanks a lot for that).

Our next release should mainly feature the Redbin format support for the Red compiler, providing much faster compilation times and reduced generated binaries.

Enjoy! :-)

Don’t just wait for new blog entries; join us on Gitter

Chat with the team, keep up with the latest design issues, and be part of a great community
Join Us
We're on a Mission to Fight Software Complexity Join us! →