Golo
— a lightweight dynamic language for the JVM.

back to the front page

 Just released: Golo 1.1.0

A picture is worth, well... something.

We haven’t posted much news over the last summer since Golo 1.0.0 was released. We haven’t stayed idle, and today we are pleased to share Golo version 1.1.0!

Golo 1.1.0 is mainly the result of contributions from new community members, and we are very happy to see enthusiasts join our effort.

New features

Python-style decorators

This is probably the major feature of this release, contributed by Sylvain Desgrais and Yannick Loiseau.

Golo decorators are not Java annotations, they are higher-order functions like in Python:

module tests.LogDeco

function log = |msg| -> |fun| -> |args...| {
  println(msg)
  return fun: invokeWithArguments(args)
}

@log("calling foo")
function foo = |a| {
  println("foo got a " + a)
}

@log("I'am a bar")
function bar = |a| -> 2*a

function main = |args| {
  foo("bar")
  println(bar(21))
}

which prints:

calling foo
foo got a bar
I'am a bar
42

The new gololang.Decorators module provides a set of useful decorators, including checkArguments, checkResult, memoizer and more.

Here is an example of using memoizer:

# (...)

let memo = memoizer()

@memo
function fib = |n| {
  if n <= 1 {
    return n
  } else {
    return fib(n - 1) + fib(n - 2)
  }
}

Finally, here is an example checking arguments:

function isInteger = |v| {
  require(v oftype Integer.class, v + "is not an Integer")
  return v
}

function isPositive = |v| {
  require(v > 0, v + "is not > 0")
  return v
}

@checkResult(isInteger)
@checkArguments(isInteger, isInteger)
function add = |a, b| -> a + b

@checkArguments(isInteger: andThen(isPositive))
function inv = |v| -> 1.0 / v

Command-line interface improvements

Romain Lespinasse improved the golo command line interface:

ctags generation

Yannick Loiseau improved the golo doc command to generate ctags, which is useful with certain text editors.

This will especially appeal to the fans of the venerable Vim, but people who prefer to hurt their brains and fingers with Emacs will also enjoy this feature.

Fixes and improvements

Many documentation typos have been fixed, and some missing parts have been added, such as small sections for standard modules that where already documented in golodocs.

Yannick Loiseau fixed some compilation error message bugs, too.

Alexis Thomas improved some test portions, and Philippe Charrière contributed his share of goodness.

Until next time…

…have fun!

comments powered by Disqus


Copyright © 2012 – 2016 INSA-Lyon and contributors.

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