lunes, 28 de febrero de 2011

Programmer problem solving sequence

2010 developer’s problem solving sequence:

  1. Google
  2. Coworkers
  3. StackOverflow
  4. RTFM
  5. Think

It's funny because it's true.

Via HN -> JCook -> Philippe Leybaert

lunes, 21 de febrero de 2011

run interactive applications inside emacs

While implementing a more decent repl for HAScheme, I stumbled upon a nifty emacs feature: comint.

To run an interactive shell, get history for free, and completion (at least hippie-expand if you teach your emacs to use it), you just have to use make-comint.

(defun run-has ()
(make-comint "has" "/path/to/hascheme/script/" nil "/path/to/hascheme/script/builtins.scm"))

the last parameter is the argv, you can fill it with whatever you want. In my case, the scheme file with some builtins.

On the hascheme side, I've been experimenting with tail call optimitzation, an improved repl with multiline support and with some cool debugging features. You'll know shortly about them if you follow this little blog of mine.

Well, and here's a screenshot of the comint buffer on hascheme. note the completion thing on the minibuffer.

martes, 8 de febrero de 2011

(let ((there be)) lisp)

I keep having lots of fun with hascheme. In the last couple of
days, I implemented quite a few things. Mostly they are syntax
sugar for things you could already do in HAS, or useful procedures
needed for my basic interpreter testing.

  • Perl side

    • (define (fun args) body) is now accepted as an alternative way
      to declare procedures.

    • (let) implemented. These bindings for local vars are just sintactic sugar for
      what you'd write in perl:
      sub { my $a=shift; … }->(initialval)

  • Scheme side
    Reread the 'Why functional programming matters' paper, and implemented:

    • make-counter, foldr

    • append, sum-list, length, map . All are specific cases of the previous

Reading chapter 4 of our MIT beloved book, I saw the next step, making a lazy
interpreter from this Half Assed one.

Ah, the repo

lunes, 7 de febrero de 2011

Put more vim into your emacs

I'm a vim editing model fan, but emacs is slowly crawling into my
life. emacs had viper (vi emulator) for ages, but it falls short if
you're a vim power user. Vi is not Vim.

For some time there's been vimpulse package that tried to narrow the
difference, adding Visual mode, and some other goodies. Recently,
vimpulse got reactivated, and now, we get text objects, and many
other features from our beloved text editor.

You can even use map, imap, vmap and the like;

the first thing I tried was mapping jk to esc, but the tip in the
vimpulse wiki didn't work. I managed to make it work with this line
in my .emacs file.

(vimpulse-imap "jk" 'viper-exit-insert-state)

Now, there's no need to reach the far escape key.

viernes, 4 de febrero de 2011


Little updates to Hascheme, I finally implemented cons, car, cdr,
and list as primitives, After implementing the prove that you can
have datastructures in a language without no more ground than
lambdas, I went for a bit more of efficiency (not that hascheme is
going to be in production ever, but you know…)

Another motivation to implement lists as primitives is that this
way, I can get a kind of homoiconicity. If conses are implemented
in the implemented language (scheme), a list will never be similar
to code, because Perl never sees the datastructure as something it
can deal with.

And what's the ultimate motivation for having all this stuff
working? fun.

I used a very common lisp quine to test that code and data are
implemented internally the same way. That gave a good testbed for
quote too. Unfortunately, using Perl Data::Dump* modules, I can't
tune how lists are printed, and the final nil gets printed too.

Well, here's the proof that Half Assed Scheme can do Half Assed

Next step, testing that closures work. (I'm afraid they don't work quite well)