This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: load-from-port



If people think there should be a load-from-port, here's a quick
implementation modelled on eval-string. eval-string and primitve-load
could probably be changed to use this internally, but I leave such
tinkering to wiser heads.

 - Maciej Stachowiak


*** load.c	Sun Sep 21 20:43:47 1997
--- load.c.mod	Fri Oct 24 14:47:59 1997
***************
*** 322,327 ****
--- 322,343 ----
    return scm_eval_x (form);
  }
  
+ SCM_PROC (s_load_from_port, "load-from-port", 1, 0, 0, scm_load_from_port);
+ 
+ SCM
+ scm_load_from_port (port)
+   SCM port;
+ {
+   SCM form;
+   SCM ans = SCM_UNSPECIFIED;
+ 
+   /* Read expressions from that port; ignore the values.  */
+   while (!SCM_EOF_OBJECT_P (form = scm_read (port))) 
+       ans = scm_eval_x (form);
+ 
+   return ans;
+ }
+ 
  
  /* Information about the build environment.  */
  
*** load.h	Mon May 26 18:33:03 1997
--- load.h.mod	Fri Oct 24 14:47:03 1997
***************
*** 52,57 ****
--- 52,58 ----
  extern SCM scm_sys_search_load_path SCM_P ((SCM filename));
  extern SCM scm_primitive_load_path SCM_P ((SCM filename));
  extern SCM scm_read_and_eval_x SCM_P ((SCM port));
+ extern SCM scm_load_from_port ((SCM port));
  extern void scm_init_load SCM_P ((void));
  
  #endif  /* LOADH */