go

March 11, 2016 ยท View on GitHub

  • experimental support: almost everything except for error handling and several methods
  • generator api translator tests
  • target version: Go 1.2+

Go equivalents used for pseudo types and concepts:

PseudoGo
List[T]slice[T]
Dictionary[K, V]map[K]V
Set[T]map[bool]struct{}
Tuple[T1, T2..]a custom struct
Array[T, count]T[count]
Intint
Floatfloat
Stringstring
for-loopsfor
classesstructs
methodsstruct methods

error handling

error handling is currently not supported for go.

it's going to be supported in v0.3 and almost everything is ready for that: there's a sketchup of the GoErrorHandlingMiddleware that's going to transform exception-based code to return-errors-based code it will probably reuse some of the leaking handlers logic, because for e.g.

def process_pair(a, b):
    return process(parse_int(a), parse_float(b)).result

where parse_x throws ParseError and process throws WatError we'll need to inject error handling code in the surrounding block:

func ProcessPair(a string, b string) Result {
    parsed_a, err := parse_int(a)
    if err {
        return nil, err
    }
    parsed_b, err := parse_float(b)
    if err {
        return nil, err
    }
    processed, err := process(parsed_a, parsed_b)
    if err {
    	return nil, err
    }
    return processed.result
}

not really beautiful, but hey, we're not letting those evil errors go away /s