[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prolog, pure guile scheme cont

From: stefan
Subject: prolog, pure guile scheme cont
Date: Thu, 8 Jul 2010 22:48:20 +0200
User-agent: KMail/1.12.4 (Linux/; KDE/4.3.5; x86_64; ; )


Streamlined the repo/unify-iso further. It is pretty self contained although
a bit hacky because I have an absolute path in umatch that has to be 
Anyway this code clocks at 10x the faster but rude code I have in the master 
branch. I'm pretty sure that We shuold be able to make that 5x. Anyway it's a 
starting point for having a prolog running with guile that are unintrusive.

Did some research about prompting.
I have a fix for the issue I mensioned in previous mail. 
I don't know the generality of the fix. but it works by defining two public 
functions in control.c, e.g.

We send an id instead of the tag to the g-abort! and the usual args, the id
beeing essential the adress of the prompt data
SCM_DEFINE (scm_at_generation_abort, "@g-abort", 2, 0, 0, (SCM id, SCM args),
            "Abort to the nearest prompt with secific id @var{id}.")
#define FUNC_NAME s_scm_at_generation_abort
  SCM *argv;
  size_t i, n;

  argv = alloca (sizeof (SCM)*n);
  for (i = 0; i < n; i++, args = scm_cdr (args))
    argv[i] = scm_car (args);

  scm_c_g_abort (scm_the_vm (), id, n, argv, -1);

  /* Oh, what, you're still here? The abort must have been reinstated. 
     that's quite impossible, given that we're already in C-land here, so...
     abort! */

  abort ();
#undef FUNC_NAME

where the search for the prompt is done by...
 if (SCM_PROMPT_P (elt) 
          && ((((scm_t_bits) SCM_PROMPT_REGISTERS(elt)) | 2) == SCM_UNPACK(id)))
          prompt = elt;
Kind of hacky. from a defined prompt it returns the identity info.
SCM_DEFINE (prompt_generation_id, "@prompt-gid", 1, 0, 0, (SCM tag),
            "Return a generation id for a prompt")
#define FUNC_NAME s_prompt_generation_id
  SCM winds;  
  /* Search the wind list for an appropriate prompt.
     "Waiter, please bring us the wind list." */
  for (winds = scm_i_dynwinds ();
       scm_is_pair (winds);
       winds = SCM_CDR (winds))
      SCM elt = SCM_CAR (winds);
      if (SCM_PROMPT_P (elt) && scm_is_eq (SCM_PROMPT_TAG (elt), tag))
          return  SCM_PACK((((scm_t_bits) SCM_PROMPT_REGISTERS(elt)) | 2));
  printf("did not find prompt!\n");
  return SCM_BOOL_F;
#undef FUNC_NAME


reply via email to

[Prev in Thread] Current Thread [Next in Thread]