martes, 25 de enero de 2011

(cadr has)

I've been hacking on HAS a bit more, to push forward its functionality.
Mostly what's been achieved by now:

  • Perl side

    • (repl) primitive implemented. it acts as a debugger in some way,
      because it gives you the environment in the state of the moment
      when you executed it. I couldn't implement it in scheme itself
      because I have no eval available from scheme.

    • Read plain files. As I started implementing some functionality
      in scheme, A scheme file must be loaded at start. just enter the
      file name as a parameter. Last sexp should be (repl) to have
      your repl available.

    • Comments. ';' is the comment marker

    • = operator

    • nil. transformed to 0.

    • list. yeah. As HAScheme can't understand variable length
      arguments, I implemented it to make it more confortable to build
      lists. It's built on an ugly hack. More on that later.

  • Scheme side

    • cons, car, cdr. Implemented basic structures. Implemented as
      lambdas. as in SICP, somewhere in chapter 2 IIRC. Simple though
      impressive IMHO (and inefficient, but…)

    • print_list. conses down a list and prints each element in a

I run it using builtins.scm as the first parameter, and then, repl is
yours, with lists and conses available for you.

Now the not-so-beautiful parts

If I want lists, I just have to nest conses, but who doesn't want a
litte luxury?.

To implement list, I've thought 3 possible solutions (haven't read

about how to implement them correctly, just brainstorming):

  • Variable actual arguments. If I could implement the dot (.) syntax
    for variable number of arguments, I could implement list as a
    simple scheme function. Problem is that I need lists to stash
    the resting parameters (hascheme lists, not Perl ), and I haven't thought how to bootstrap.

  • Write a new primitive (on the perl side) that builds the correct
    cons structures, on the perl side. Mind you, that list is VERY
    coupled to cons implementation. And quite fuzzy on the perl side

  • Substitute list for the appropiate number of conses (as a string),
    and let the already written parser do the job. That's the one I implemented.

Probably, I'll start from the scratch building another scheme interpreter, following BillHails book. Or at least, I'll go as far as my motivation and brain allow me.

That's all for now. Here's my other post about Hascheme, and the github repo.


domingo, 23 de enero de 2011

I can has HAS (Half Assed Scheme)

If you've been reading along these bloglines, you already know I'm on
my way to learn lisp, and given that a typical exercise on the lispers
path is writing a scheme interpreter, I decided to try to impement a
scheme interpreter in perl. I had a great guidance of Peter Norvig's lispy tutorial, and more thoughtful explanations from Bill Hails' book.

I can't say I wrote it as quick as I thought I would, and it could
definately be clearer (OOP in such small projects is clearly
overengineering), but in the end, it works, and given the fact that I
hadn't been programming perl at work for 2 months, it's been a good exercice.

The relevant code is in 4 files,

  • script/ (REPL and primitives),

  • lib/hascheme/ (Parsing)

  • lib/hascheme/ (environment, a tree structure built on hashes)

  • lib/hascheme/ (special operators are treated here, and overall evaluation)

Anyway, here you are, the code is in a github repo. For now, It's
called half assed scheme, or hascheme, or HAS.

Related article: next post on HAS

Now, you can has HAS too.

jueves, 6 de enero de 2011

generate Moose classes from CLI

It seems I've been a bit out of Perl lately (last 2 or 3 weeks), but that's not completely true.

I have a couple of projects in mind (one bigger than the other, but both interesting nonetheless), but I have not been in my best moods to program... difficulties to focus. At work, I do exactly 0% perl :(, so I have to push myself to use it...

In one of my projects I'm using OOP intensively (maybe overengineering?, we'll see), and I always tend to forget how to correctly set up a bare Moose class.

So here's what I've written:

Just a simple script that generates scaffolds for Moose classes and gives a couple of hints on attributes' properties. A good friend of the script template I did some time ago

I've tried to make it work the most DWIM-Y way, so you call it like " lib/My/App/Entity" , and generates My::App::Entity class in the appropiate path and with appropiate namespace.

SeeYapp! ;p

martes, 4 de enero de 2011

If you want a thing done well ....

...and continuously, and consistent way, let the computer do it for you.

gem install ZenTest
gem install autotest-rails
gem install redgreen

If you're on MAC:

gem install autotest-fsevent
echo "require 'autotest/fsevent'\nrequire 'redgreen'" >> ~/.autotest

If you're on GNU/Linux

gem install autotest-inotify
echo "require 'autotest/inotiny'\nrequire 'redgreen'" >> ~/.autotest

just run 'autotest' from your project root directory, and it will run the relevant tests on your modified files.

domingo, 2 de enero de 2011

git, now it's your time!

At work, we're using git as our VCS. I am still on the process of fully understanding it.

Well, digging a bit on git workflows, I found a couple of posts that helped me to understand git a bit more.

Git hack and ship scripts

nvie git branching model

And now, pit a project I recently saw on github, that integrates git commits with task and ticketing systems. Everything, in Text Driven Development, you know :)

The best 'The best X of 2010' of 2010

Here you have a bunch of rankings about best * (whatever) of 2010.

fogus' best things of 2010 best-technology-writing-of-2010/

review comparing most successful oodb of 2010

Top ten algorithm preprints of 2010

great papers from 2010, and before :)

14 R posts, with statistics and datamining stuff inside

Bye, and see you in next posts.