Skip to content

Instantly share code, notes, and snippets.

View marcoonroad's full-sized avatar
🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past

Marco Aurélio da Silva marcoonroad

🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past
View GitHub Profile
@marcoonroad
marcoonroad / hacking.pl
Created December 9, 2014 16:03
Some perl 5 hacking...
# small hacking over symbol table
use feature qw| state |;
sub say { print @_, "\n" }
sub _ (&) { $_[ 0 ] }
sub curry {
my $f = shift;
@marcoonroad
marcoonroad / cont.pl6
Created December 10, 2014 23:19
Call/cc-like stuff in Perl 6...
#!/usr/bin/perl6
use v6;
# call with current continuation
sub infix:<⇐> (&cont, &expr) {
my @rest = expr &cont;
return @rest[ 0 ] if @rest[ 1 ];
return cont @rest[ 0 ];
}
@marcoonroad
marcoonroad / outroal2.c
Last active August 29, 2015 14:11
Outro trabalho de AL2...
#include <stdio.h>
#include <stdlib.h>
// tipos
typedef struct node {
int here;
struct node *next;
} Node;
typedef Node * Linked;
@marcoonroad
marcoonroad / hello.mbc.dump
Created December 12, 2014 01:25
MoarVM dump of "say 'hello'";
# $ perl6 --target=mbc --output=./hello.mbc -e "say 'hello'"
# $ moar --dump hello.mbc > hello.dump
MoarVM dump of binary compilation unit:
SC_0 : 61C9069EAD2FEF4AF84D9D502EA124CAC63EB166
Callsite_0 :
num_pos: 0
arg_count: 0
Callsite_1 :
@marcoonroad
marcoonroad / trycatch.pl
Last active August 29, 2015 14:11
Exemplo de Try / Catch / Finally em Perl 5.
use warnings;
sub try (&;@;) {
my ($try, @tests, $finally) = @_;
# remove o bloco <finally> se ele veio junto
$finally = pop (@tests) -> { 'finally' } if ref ($tests[ -1 ]) eq "HASH";
push @tests, -1; # marcador de nenhum erro capturado
eval { &$try };
if ($@) { # houve um erro?
local $e = $@; # erro de escopo local (como uma variável de closure)
@marcoonroad
marcoonroad / smallideas.pl
Last active August 29, 2015 14:11
Small OOP ideas based on / for Perl 5.
# ...
### gather / take ###
gather {
@xs -> for { | $x | ($x + 1) -> take }
} -> eval -> say;
# or
{
@marcoonroad
marcoonroad / tasklike.lua
Created December 21, 2014 23:59
Task-like test on Lua...
-- scheduler / task test --
-- object, the base prototype --
local object = { }
-- bless / bind for lookup --
-- :: Ref <$> -> Pair % -> Obj %
function object: with (O)
return setmetatable (O, { __index = self })
end
@marcoonroad
marcoonroad / arrow_lambda.pl
Created December 22, 2014 01:19
Short arrow / lambda functions at Perl5...
use v5.12;
use utf8;
use strict;
use warnings;
# to declare short arrow functions
sub Ω {
my $in = shift;
return sub {
my $out = shift;
@marcoonroad
marcoonroad / output.txt
Last active August 29, 2015 14:12
Symbol table dumping at Perl 5...
Dumping 'main' symbol table.
Exporter:: => *main::Exporter::
*main::Exporter:: =>
" => *main::"
*main::" =>
utf8:: => *main::utf8::
*main::utf8:: =>
 => *main::
*main:: =>
DynaLoader:: => *main::DynaLoader::
@marcoonroad
marcoonroad / output.txt
Created December 24, 2014 11:15
Symbol table dumping at Lua...
setmetatable => function: 0x8060770
string => table: 0x9575d58
require => function: 0x9576740
coroutine => table: 0x95767a0
arg => table: 0x9578970
os => table: 0x9576930
tostring => function: 0x805fbf0
xpcall => function: 0x8060600
rawset => function: 0x805ff60
pairs => function: 0x8060910