Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/perl6
# sockets-test.pl - trying out Parrot sockets from Rakudo
# Interim subs for Parrot (r37707) socket functions (PDD 22) in Rakudo.
# Later, when this code moves to rakudo/src/setting/IO.pm, the 'sub'
# definitions will become 'method' to augment the IO class.
# Later still, the socket functions in Parrot will disappear because
# they are deprecated, to be replaced by methods on ParrotIO objects.
sub socket( IO $socket, Int $domain, Int $type, Int $protocol ) {
return Q:PIR{ # from q:PIR in socket() in Daemon.pm
.local pmc sock
.local int domain
.local int type
.local int protocol
find_lex sock, "$socket" # socket object
find_lex $P0, "$domain" # 2=PF_INET (read 'man socket')
find_lex $P1, "$type" # 1=SOCK_STREAM ?=SOCK_DGRAM
find_lex $P2, "$protocol" # is 6=tcp ?=udp
sub socket( IO $socket, Int $domain, Int $type, Int $protocol ) {
return q:PIR{ # from q:PIR in socket() in Daemon.pm
.local pmc sock
.local int domain
.local int type
.local int protocol
find_lex $P0, "$socket" # handle to be opened
find_lex $P1, "$domain" # 2=PF_INET (read 'man socket')
find_lex $P2, "$type" # 1=SOCK_STREAM ?=SOCK_DGRAM
#!/bin/bash
#
# NAME
# hello.bash - a canonical "hello, world!" project for proto
#
# SYNOPSIS
# bash hello.bash # creates and uploads everything in /tmp/hello
#
# DESCRIPTION
# Implements proto's PIONEER plan in code
Pod::Parser performance (therefore also Pod::Server) is disappointingly
slow when handling medium size (5k-50k) files. Memory usage climbs rapidly
because it seems Parrot or Rakudo leaks memory until the process exits.
The operating system resorts to swapping hectically in a hopeless effort
to provide more, but Parrot doesn't recycle and keeps calling malloc().
After almost hanging the computer for a long time the kernel usually kills
the Parrot.
Running L<Pod::Server|http://github.com/eric256/perl6-examples/blob/master/lib/Pod/Server.pm>
# Makefile creator in Perl 6, reads Makefile.in and writes Makefile.
# Use your values of /my/ to run either (always in current directory):
# '/my/perl6 Makefile.p6' or '/my/parrot /my/perl6.pbc Makefile.p6'
use v6;
# say %*VM<config>.perl;
# say "osname = {%*VM<config><osname>}";
# say "revision = {%*VM<config><revision>}";
# say "MAJOR.MINOR.PATCH = {%*VM<config><MAJOR>}.{%*VM<config><MINOR>}.{%*VM<config><PATCH>}";
# say "prefix = {%*VM<config><prefix>}";