lunes, 29 de junio de 2009

keep plaiyng

Recently, I joined a group of fringe languages fanatics (especially scheme and lisp, but smalltalk is welcome to, as well as haskell and so).

The first meeting was 2 weeks ago, and we talked about many things (well, I mostly listened, but...). Jos Koot explained us some usages of plt-redex, and made a lightning introduction to lambda-calculus. Jao said that in the next session, he would be explaining us a bit of Factor (a concatenative programming language (forth derivative)) , and probably, there will be some lightning talks.

After the presentations and the main talk, we decided it'd be good to make reading groups to examine cool books related to lisp/scheme/whatever.

Some proposed SICP, some others LiSP , but in the end, we chose to start with PLAI.

I started it last week, and red about 30 pages without many problems. Everything seemed sane. Then, when I decided to try it, I faced some problems, that other scheme newbies might have too. So let's try to fix them :) .

plt-scheme and DrScheme.

First things first. To try the codes there, you should install the complete plt-scheme (mzscheme alone won't work). That wasn't a problem for me because I'd already installed to try fluxus, but as there wasn't a proper package for vectorlinux, I decided to start packaging it (at the end, rbistolfi packaged it, as his comp is more powerfull than mine, and it's a looong compilation).

We decided to compile it with --enable-shared to make fluxus 'compatible' with it.

When I tried to use the sample codes in the book..... FAIL. define-type nor type-case existed in my plt-scheme. What I needed to do was install plai libraries through a simple require.

(require (planet plai/plai:1:3))

Reading the book

While reading the book, at first all made sense until I found this:


<wae> ::= <num>
| {+ <wae> <wae>}
| {- <wae> <wae>}
| {with {<id> <wae>} <wae>}
| <id>


(define-type WAE
[num (n number?)]
[add (lhs WAE?) (rhs WAE?)]
[sub (lhs WAE?) (rhs WAE?)]
[with (name symbol?) (named-expr WAE?) (body WAE?)]
[id (name symbol?)])


How come in the BNF with had only 2 arguments (the first one containing 2 elements), and when the author defines 'with' in scheme, it has 3?

The key to this is reading carefully the first chapters, when the author says that it's our job to modify the parse function to adequate the code to be properly evaluated. In fact, I was understanding the whole thing wrong, thinking that define-type was what should constrain my syntax, but it turned to be the other way around.

When I execute :
{calc {parse '{with {x 4} {+ x x} }}}
What I'm doing is calling parse first, so I have the full power to massage the 'parse' input and output it in a way calc can use. calc is the function that uses type-case, so it's the function that must obey the constraints defined at define-type.

Btw. I'm not passing all the tests for the 3rd chapter but only the first 4. Anyway, I think I just understood a new concept and the whole flux of what must go where.

Now the (unfinished) code. for the WAE parser (3rd Chapter)

(define-type WAE
[num (n number?)]
[add (lhs WAE?) (rhs WAE?)]
[sub (lhs WAE?) (rhs WAE?)]
[with (name symbol?) (named-expr WAE?) (body WAE?)]
[id (name symbol?)])

(define (parse sexp)
(cond
[(number? sexp) (num sexp)]
[(symbol? sexp) (id sexp)]
[(list? sexp)
(case (first sexp)
[(+) (add (parse (second sexp))
(parse (third sexp)))]
[(-) (sub (parse (second sexp))
(parse (third sexp)))]
[(with) (with (first (second sexp))
(parse (second (second sexp)))
(parse (third sexp)))])]))

(define (subst expr sub-id val)
(type-case WAE expr
[num (n) expr]
[add (l r) (add (subst l sub-id val)
(subst r sub-id val))]
[sub (l r) (sub (subst l sub-id val)
(subst r sub-id val))]
[with (bound-id named-expr bound-body)
(if (symbol=? bound-id sub-id)
expr
(with bound-id
named-expr
(subst bound-body sub-id val)))]
[id (v) (if (symbol=? v sub-id) val expr)]))

(define (calc expr)
(type-case WAE expr
[num (n) n]
[add (l r) (+ (calc l) (calc r))]
[sub (l r) (- (calc l) (calc r))]
[with (bound-id named-expr bound-body)
(calc (subst bound-body
bound-id
(num (calc named-expr))))]
[id (v) (error 'calc "free identifier")]))



cya! And Thanks to all flibers!

sábado, 27 de junio de 2009

jkjkhlkj

Me la suda,
no me la suda.
Me la suda,
no me la suda.

¿Qué tipo de flor es esta?
Una que no sabes ni que preguntarle.
Una que no sabes ni si empezar a quitarle pétalos,
porque tal y como está, es perfecta.
Pero quieres llegar hasta el final.

Me lo imagino,
no me lo imagino.
Me lo imagino,
no me lo imagino.

Sentirse vivos.
¿Desde cuando?, ¿hasta cuando?
Sea como sea, mola,
y mola más vivirlo juntos.
Más juntos.

lunes, 22 de junio de 2009

...


La corriente se vuelve a sentir.

Hace tiempo que lo notaba, pero no estaba seguro,
ahora ya me acuerdo de la sensación.

Una luz blanca al final del túnel, un túnel amplio,
un tunel con respiraderos, un tunel agradable,
un túnel en el que estas en paz. Circular, quieto, perfecto.

De repente, una turbina, en un extremo empieza a girar poco a poco. Me intenta llevar a la salida, pero por ahora es solo una leve corriente, que solo consigue que aún esté mejor.
Realmente estoy bien. Relajado, con el justo movimiento de aire que necesito, aunque algo aburrido, si me preguntas.

click.

El ventilador gira algo mas veloz. El pelo se me enreda un poco, y los respiraderos se cierran. Creo que van a venir más turbulencias. Ya me ha pasado otras veces. Algunas las he pasado bastante bien. De otras he salido magullado, pero nunca me he dejado vencer. Si dejas que el tunel te gane, mueres. Siempre. Hay quien dice que puedes salvarte, y me habian contado que quien se salva de ésta, vive para siempre. ¿Quien hay al otro lado? ¿Dios? Yo intento no descubrirlo. Me da demasiado miedo la muerte.

click, click, click.

En muy poco rato, la hélice esta soltando un vendaval. Me encaro a la turbulencia. Tengo que hacer algo de fuerza con las piernas (suerte que puedo estar de pie). El pelo se me mete en la boca, y tengo que quitarmelo con la mano. A ver si amaina, y para todo esto... Ya hecho de menos mi tranquilidad. Nunca, en tan poco tiempo ha habido tantos cambios seguidos. Me hace pensar. ¿Será este diferente?. ¿ Será esta la vez que tendrás que dejarte llevar por la corriente, y morir o salvarte ? . Me da miedo, y espero que no sea ésta... aunque sé que algo ha escapado ya de mi control.

click. click.

Resbalo, y me agarro a una rejilla que hay en el lateral. Se empieza a hacer dificil mantenerme donde estoy, y miro tumbado hacia la corriente, como desafiándola. Los cabellos me golpean la cara, como latigazos, los brazos me comunican que no podran aguantar toda la vida. La corriente nunca se cansa -me dicen-, y quizás llevo en el túnel demasiado tiempo.

Afuera es verano, y quizás vale la pena dejarte llevar por la corriente.

Click.

El ruido es ensordecedor. Me dejo ir, no quiero seguir dentro de este túnel. Espero no morir. Espero encontrar una buena compañía fuera, que me guíe, y me abrace. Y me diga qué esta bien y qué esta mal. Llevo tanto tiempo aquí dentro, que ya ni me acuerdo.

jueves, 11 de junio de 2009

Why I love vectorlinux. Bigger repositories every 2 hours.

Vectorlinux, you know, this little fast distro.

Yesterday, a new VL user came to the forums and asked for a package (code::blocks) . Well, in less than 2 hours, rbistolfi had packaged it, and it's now waiting to be uploaded to the repos.

Isn't it great? Theese things make a little and modest distro into a total WIN.

Vectorlinux is one of the fastest linux distros around, and community seems to be one of the fastest too.

UPDATE:
8 hours later, toothandnail has already uploaded codeblocks package to our repo.

You gotta love this community :D

viernes, 22 de mayo de 2009

Last week on 'Perl Programming'

Hey guys (and TIOBE :),

I'm going to paste a template for my new perl scripts I'm using lately. Well, I know I always should code as if it had to make into CPAN, but well... Sometimes you just don't need all the boilerplate.


#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper::Perltidy;
use Getopt::Long;
use Pod::Usage;

sub man {#{{{
pod2usage(
-exitval => 1,
-verbose => 2
);
}#}}}

# main
GetOptions (
'man' => \&man,
);

__END__#{{{

=head1 NAME


=head1 SEE ALSO


=head1 SYNOPSIS


=head1 DESCRIPTION

=head1 AUTHOR

Raimon Grau Cuscó

=head1 Credits

=cut

# vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ###}}}




It's not anything awesome, but it just does the job. I saved it in ~/.vim/perl.template , and entered a map in vim like this
iab nperl :r ~/.vim/perl.template
However, if I have to write something longer than 100 lines, it goes through the proces of module starter or h2xs (the former is recommended now)

module-starter --module=Unix::RatFinder::IO --author="Raimon Grau" --email="raimonster@gmail.com" --builder=Module::Install
Some random things.

  • Rakudo now passes the 68% of the perl6 specs. yay!
  • I'll go to YAPC::EU::2009! YAY! (thx C.)
  • I'm working on a better Padre::Plugin::Vi a plugin for Padre or at least extending it with new commands. for the moment I've got a commit bit and implemented a couple commands. Yay!
  • Learning lots of things on ironman blogging contest

Cya!

jueves, 14 de mayo de 2009

Explore Io's internals

I haven't touched Io in some time, but about a month ago, I came with this piece of Io code, to explore the Io written methods in default Io installation.

For example, to explore Number blocks (all are written in Io, CFunctions aren't), you just have to type this in Io REPL.

Number slotNames foreach(i,
if(Number getSlot(i) type == "Block" ,
(i .. " -> " .. Number getSlot(i) code) println))

lunes, 11 de mayo de 2009

Farewell sir +f


A wise man, the greatest reverser and one (or two?) of the men who made a lot of reversing knowledge public, to us.

Back in late '90s, some of us started our intenet adventure, and we felt that all that information we had available wasn't enough. We scratched the surface and dug until we found a forest. Yeah, the old Searchlores Castle.

There were some of the smartest people around the techworld, publishing essays and documents about fishing. They not only told us how to get a fish, but made us want to know where fishes came from, and go there. Nevermind the obstacles. Everything is bit .

+HCU gave lots of reversing knowledge to us, poor crackers.

Then we understood the meaning of reversing and started to feel the code. We were starting to use the Zen way of approaching things. Not only reversing code, but reversing the code of life.

When internet was getting too much messy. He started a new project, related to the old forest and philosophy but in a more abstract way. It was about knowing you can get the knowledge. It's meta-knowledge. And this was impossible to cover it all. The field is not enormous (as in reversing) but infinite.

We've spent too many hours reading your smart texts (and probably missunderstanding most of your winks.

Unfortunately, you couldn't make it to 2032, and passed away last May 3rd, but there's plenty of people that will take your word to 2032 and more, and for sure, you can be satisfyed of having given the 'critical thinking' to many of us.

Happy reversing, wherever you are Mr. +fravia.