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 }
}
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 }
}
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) |
Some of these gists may be outdated since the golo macro feature is still in progress. However, I keep these for references.
NOTE: this is a proposal, not the way thing are currently done.
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())
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"),
Macros for Golo are becoming a reality 😄
See https://github.com/yloiseau/golo-lang/tree/wip/macro-quote
By the way, some choices need to be made, hence this RFC.
I hereby claim:
To claim this, I am signing this object: