News for hackers. Stuff that matters.
Re:Lisp evangelists that miss the point about syntax by fexl on Thursday February 04, 2010 @05:06PM (#1101761)
Oh gosh how could I neglect a mention of type_app, the type which represents function application itself?

  #include "node.h"
  #include "type_app.h"

  static struct node *reduce(struct node *parent)
      {
      struct node *curr = parent->LEFT;

      while (curr->type == parent->type)
          {
          struct node *self = curr->LEFT;
          struct node *next = self->type->reduce(curr);

          if (next != curr)
              {
              hold(next);
              drop(curr);
              curr = next;
              }
          }

      parent->LEFT = curr;

      return curr->type->reduce(parent);
      }

  static struct type type = { reduce, clear_pair };

  struct node *make_app(struct node *f, struct node *x)
      {
      return make_pair(&type, f, x);
      }
That "while" loop you see there is essentially the only loop in the entire core of Fexl. (Obviously "plug-ins" can do their own loops.)

That loop keeps reducing the parent node as long as it's still of type_app. Then the loop ends and it reduces whatever the parent node has become as a result of the evaluation loop.

There are no comments on this comment yet.