Skip to content

Instantly share code, notes, and snippets.

View yloiseau's full-sized avatar

Yannick Loiseau yloiseau

View GitHub Profile
@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 / 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 = {
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 / golo_macros.md
Last active January 22, 2017 18:04
List of my gists about Golo macros
@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).

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 / gist:c9e5c816e8cd04e4c3ea
Last active August 29, 2015 14:20
yet another macro use case for golo

Yet another macro use case for golo

actual working code...

module SomeFunctions

function bar = |somethingWithV, a, b| -> somethingWithV: v() + a + b
@yloiseau
yloiseau / gist:ca03668ef3d592a75f69
Last active January 22, 2017 17:47
more on golo macros

This was working! It's no more the case

module StructMacro

import gololang.macros.CodeBuilder

function pokemon = |typeName, sound| -> toplevel(
  structure(): name(typeName: getValue())
 : members("name", "owner"),

Keybase proof

I hereby claim:

  • I am yloiseau on github.
  • I am yloiseau (https://keybase.io/yloiseau) on keybase.
  • I have a public key whose fingerprint is B879 D9A8 89E2 9890 4647 CC62 3A00 423E 5C41 F928

To claim this, I am signing this object: