Mostrando entradas con la etiqueta factor. Mostrar todas las entradas
Mostrando entradas con la etiqueta factor. Mostrar todas las entradas

lunes, 11 de noviembre de 2019

Some Forth Implementations

To finish up one of the geekiest weekends in the last months, I just wanted to point to a few Forth implementations, from where I learned some nice tricks (from both forth and the implementation languages)

- Bashforth/Perlforth
- Rubyforth
- Miniforth
- ItsyForth

I spent a lot of time grasping Bashforth, with its usage of some smart tricks that you don't usually see in bash scripts. Also, the fact that array indices are used as a sort of pointers makes total sense, but it wasn't obvious to me at first (I had to research a bit about "delcare"). Perlforth is done by the same guy, so it uses a similar approach.

Miniforth is Lua, and uses a different kind of implementation, and gets to bootstrap something forthish in 40 lines of lua.  Not bad :)

Rubyforth is the one I touched less, but looks like a variation of miniforth with more Forth compliance.

Now a quick bash quiz: What does it echo? AnswerHere

#!/bin/bash
fun() {
        local var="local value of var"
        echo "$ref";
}
var="global var"
declare -n ref=var
fun 

Well, there are two more canonical forth implementations that is worth mentioning them here, because if you're gonna just look at one implementation, you should take these ones as more "de facto" implementations.
- pforth
- jonesforth

domingo, 16 de abril de 2017

quote a day, some factor code and some bash+pup+jq

For todays hack, I wanted to have some tiny app that would display a quote/sentence/link at random. Basically, the same as the "fortune" unix command.

In principle it should be trivial, it's just picking a random quote from a huge file.

The idea of doing it in factor was, well... to be able to do anything at all in factor, as most of my previous attempts failed to produce anything that even did what I expected. The tiny repo is in github.

viernes, 31 de octubre de 2014

Poetry with factor.

I'm at the moment at the polyconf in Poznan. The average level of
the conference was very nice and High quality deliveries.

One of the activities of the conference was a programming poetry challenge.

Given that lately I've been doing some factor, and the huge
flexibility of it, I decided that this would be a competitive
advantage. And it certainly is.  Basically because it uses no syntax
at all, you can just type a text, and make this text do nothing.

And the trick is to rewrite no-word to a nop.  In the end I didn't
make it into the poetry contest (the price was a jetbrains license anyway).

Here's the code. Lovely.