#ifndef _lookup_h /* Tools for attribute lookup. */
#define _lookup_h __FILE__
/* $Id: lookup.h,v 1.1 2001-10-17 18:00:20 eddy Exp $ */
#include "tot.h"
/* The exception that means `failed lookup'.  It is a self-matcher. */
extern judge unfound;

/* A tool to package a chain of bind records as a get record: */
extern ask ask_lookup_chain;

/* Delegator: */
extern linkjoin delegate;
typedef struct {
  linkjoin how;		/* == delegate */
  bindlink *next;
  get lieutenant;	/* which could, of course, be an askhead ... */
} lookupchaindelegator;

/* The __getattr__ hook.

   If a lookup chain fails to perform lookup for some key, but does have an
   entry in its chain whose ->how is that of getAt, and does manage a lookup for
   the key getAt, the result should be a get to which to pass the original key.
   If it accepts the key, whatever it returns will be used as the answer to the
   original lookup.

   The chain entry getAt itself has NULL for its ->next and is intended for use
   as the last entry in lookup chains.  Don't mess it about !
   The getAt->how does protect against bad recursion.

   Naturally, some chain entry provided by code which understands strings and
   string comparison can chose to do a lookup with key "__getattr__" when asked
   for key getAt to turn this into the actual python idiom.  It should,
   naturally, protect itself agains dodgy recursion - asking itself to fetch
   __getattr__ as a subordinate of a search for getAt which is, itself, doing a
   search for __getattr__ ... that would be unwise (though getAt->how will catch
   it before it goes two deep on the __getattr__: but __getattr__'s ->how should
   also be putting a `sentinel' status on the stack, recording whose getAt it is
   looking for, so it can give up if hunting for the answer to that involves
   asking for it again). */
extern getlink *getAt;

/*
  $Log: lookup.h,v $
  Revision 1.1  2001-10-17 18:00:20  eddy
  added in all files previously missing from RCS

  Revision 1.2  1999/12/06 19:26:14  eddy
  I seem to have changed stuff and am about to embark on a revolution.

  Initial Revision 1.1  1998/12/30 14:11:37  eddy
*/
#endif /* _lookup_h */

