Skip to content

Instantly share code, notes, and snippets.

@cognominal
Last active March 23, 2021 13:25
Show Gist options
  • Select an option

  • Save cognominal/1d572ba5398bb15895ecc5b9561c7183 to your computer and use it in GitHub Desktop.

Select an option

Save cognominal/1d572ba5398bb15895ecc5b9561c7183 to your computer and use it in GitHub Desktop.
Extending the raku languiage -- Breaking bad. Say my name
{
"$schema": "https://aka.ms/codetour-schema",
"title": "A tour",
"steps": [
{
"title": "Introduction",
"description": "Test.\nPrevious attempt lost"
}
]
}
{
"$schema": "https://aka.ms/codetour-schema",
"title": "Raku : extending the language",
"steps": [
{
"title": "Say my name",
"description": "## This code is a reference \n...to an iconic scene of the Breaking bad serie. The dialog goes as:\n* Say my name\n* You are Heisenberg\n\nIt is a pretext to demonstate the extensibility of the raku language\n\nhttps://www.youtube.com/watch?v=5eZOOEkrf6Q"
}
]
}
#! /usr/bin/env raku
BEGIN $*LANG.refine_slang: 'MAIN', role {
rule routine_declarator:sym<meth> {
<sym> <method_def('method')> };
};
class Heisenberg { meth say-my-name { say "you are $?CLASS.^name()" }})
Heisenberg.say-my-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment