Skip to content

Instantly share code, notes, and snippets.

View yloiseau's full-sized avatar

Yannick Loiseau yloiseau

View GitHub Profile

Since the plumbing behind macro compilation in Golo is not finished yet, here is some instructions to test your first macros.

File MyTestMacro.class

module MyTestMacro

import gololang.macros.CodeBuilder

macro sayHello = |name| {
 let msg = constant("Hello " + name: getValue())
@yloiseau
yloiseau / Pb_compiling_macros.md
Last active August 29, 2015 14:20
Macro definition and compilation process questions

Macro definition and compilation process

NOTE: this is a proposal, not the way thing are currently done.

For “global” macros

That is, macros that can be used in other modules, distributed as libraries, and so on.

Macros are just regular function. The module can contain all the usual constructs (struct, function, augment and so on).

@yloiseau
yloiseau / golo_macros.md
Last active January 22, 2017 18:04
List of my gists about Golo macros
class Human:
def __init__(self, **kargs):
object.__setattr__(self, '_fields', kargs)
def __setattr__(self, name, value):
self._fields[name] = value
def __getattr__(self, name):
return self._fields.get(name, None)
@yloiseau
yloiseau / macroOperator.md
Last active August 29, 2015 14:20
Macro operators

Just played with the idea of allowing user-defined operators via macros...

This is working code.

If we continue this idea, right/left associativity and distributivity priority must be implemented (options of the &operator macro).

module MacroOperators

union Option = {
@yloiseau
yloiseau / tailcall.md
Last active August 29, 2015 14:21
tail call considerations in golo

Playing with tail call optimisation emulation in Golo, I tried this code (inspired by https://github.com/kachayev/fn.py):

module TCO

union TcoResult = {
  Stop = { value }
  Continue = { arguments }
  Switch = { func, arguments }
}
@yloiseau
yloiseau / Overloading.md
Last active August 29, 2015 14:21
multimethod macro

Just a test for a macro to allow overloading existing functions! (actually, a multimethod generic dispatch)

NOTE: this is just a POC to eat my own dog food...

module A

function foo = |a, b, c| {
  return "A::foo"
}
@yloiseau
yloiseau / wtf.md
Created July 24, 2015 10:12
golo concurrency

What am I missing?

java:

import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutorService;

import static java.util.concurrent.Executors.newCachedThreadPool;
Verifying that +yloiseau is my blockchain ID. https://onename.com/yloiseau
module Test
# in reply to https://github.com/TypeUnsafe/golo-x/blob/master/main.functional.golo#L8
import gololang.Errors
@result
function divide = |a,b| -> a / b