— a lightweight dynamic language for the JVM.

back to the front page

 Golo 2.0.0

Auvergne FTW

Golo 2.0.0 is here with new language features, improvements and fixes. This is the result of a great community effort: we are glad that new contributors joined us, and the new language features are contributions developped outside of the Dynamid research group.

As Golo tries to stick to the semantics of semantic versioning, we bumped to a new major version. Indeed, named augmentations are a new language feature, and they turn with into a keyword, which introduces a tiny backwards incompatibility.

Before we dive into the highlights of this new release:

Noteworthy changes

UTF-8 characters (and Emoji)

Yes, one can now have fun with UTF-8 symbols:

let ていすう = 1
var ヘンスウ = 1
function 関数 = |인수| -> 인수
struct структура = { عنصر }

Even better (or worse), Emoji is possible:

module Emoji.Me.IM.Famous

function main = |args| {
  let 👍 = "Golo"

which prints: 🍻 Golo

Named augmentations

Augmentations can now be given names, as in:

augmentation FooBar = {
  function foo = |this| -> "foo"
  function bar = |this, a| -> this: length() + a

augmentation Spamable = {
  function spam = |this| -> "spam"

Then, such augmentations can be applied to types as in:

augment java.util.Collection with FooBar
augment MyStruct with Spamable
augment java.lang.String with FooBar, Spamable

See the documentation for more details about named augmentations

Banged function calls

Banged function calls allow caching the result of a first call:

function take_a_while  = {
  # ... complex computation
  return 42

# (...)
foreach i in range(0, 100) {

In this contrieved example, take_a_while would be called only once, and the value would serve as a result for all subsequent calls to this call site.

Banged function calls shall only be used to cache the result of calls to pure functions.

The performance improvements done by caching with banged function calls are especially interesting when used on decorators. Indeed, Golo decorators are simply high-order functions, and they need to be evaluated for each decorated function call. This is not the case for banged decorators:

function decorator =  |func| -> |x| -> func(x)

function identity = |x| -> x

which expands to:

function decorator =  |func| -> |x| -> func(x)

function identity = |x| -> decorator!(|x| -> x)(x)

See the documentation for more details about banged function calls

Range objects improvements

Range objects now have a literal syntax:

let r1 = [1..10]
let r2 = ['a'..'f']

Ranges now support incrementedBy / decrementedBy methods, which allows code such as:

foreach i in [0..10]: incrementBy(2) {
  print(i + " ")

Number type conversion functions

Sometimes one needs to make explicit type conversions in a dynamically-typed language.

The intValue(n), longValue(n), charValue(n), doubleValue(n) and floatValue(n) functions do just that:

let i = intValue("666")   # 666 (string to integer)
let j = intValue(1.234)   # 1 (double to integer)
let k = intValue(666_L)   # 666 (long to integer)
# etc

New standard library functions

A few additions have been made to the standard library, including:

Other changes

The compiler has been tightened to reject referencing uninitialized references, such as in:

let a = a + 1

The golodoc generation has been improved.

Under the hood, the method / function runtime resolution has gone through several refactorings and fixes.

Until next time…

Many thanks again to our community members, and have fun with Golo!

comments powered by Disqus

Copyright © 2012 – 2018 INSA Lyon, CITI Laboratory and contributors.

Privacy Policy | Terms of Use | Copyright Agent | Eclipse Public License | Legal Resources