guile-user
[Top][All Lists]
Advanced

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

Re: PHP to GUILE


From: Neil Jerram
Subject: Re: PHP to GUILE
Date: Mon, 26 Sep 2005 20:37:25 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Vorfeed Canal <address@hidden> writes:

> Unfortunatelly while support for XML in scheme (and guile) is
> excellent this is not the only thing needed for web-programming. I
> found some problems with GUILE core and lack of usefull modules
> (perhaps two problems are related?).

If you mean just that Guile isn't finished yet, then yes.

> Kawa does not support GOOPS-style overloading so may be it's better to
> just remake throw and catch as "primitive with generic", declare
> "try-finally" and "try-catch" as aliases to "catch", "primitive-throw"
> as alias to "throw" and then make default exceptions catchable via
> GOOPS exceptions classes ? This way "normal" catch/throw semantics
> will not be affected but when GOOPS is loaded you'll get
> sane^H^H^H^Hmodern exceptions handling...

Yes, I've been thinking about this approach for some time.  It's just
a matter of time available, and I personally don't have much of that
right now.

> This is part where I do not know how change to core should look in the
> end (one thing is clear: exceptions without hierarchy are not very
> usefull), but with search path it's obvious: it should be something
> like this:

Commenting on the following to make sure I understand ...

> diff -uNr guile-1.7.2.orig/guile-config/guile.m4
> guile-1.7.2/guile-config/guile.m4
> --- guile-1.7.2.orig/guile-config/guile.m4      2003-04-05
> 23:01:16.000000000 +0400
> +++ guile-1.7.2/guile-config/guile.m4   2005-09-18 23:15:30.000000000 +0400
> @@ -110,6 +110,24 @@
>    AC_SUBST(GUILE_SITE)
>   ])
>
> +# GUILE_SITELIB_DIR -- find path to Guile "site" lirbraries directory
> +#
> +# Usage: GUILE_SITELIB_DIR
> +#
> +# This looks for Guile's "site" libraries directory, usually something
> +# like PREFIX/lib/guile/site, and sets var @var{GUILE_SITELIB} to the path.
> +# Note that the var name is different from the macro name.
> +#
> +# The variable is marked for substitution, as by @code{AC_SUBST}.
> +#
> +AC_DEFUN([GUILE_SITELIB_DIR],
> + [AC_REQUIRE([GUILE_PROGS])dnl
> +  AC_MSG_CHECKING(for Guile site libraries directory)
> +  GUILE_SITE=`[$GUILE_CONFIG] info pkglibdir`/site
> +  AC_MSG_RESULT($GUILE_SITEDIR)
> +  AC_SUBST(GUILE_SITEDIR)
> + ])
> +

Presumably (apart from the GUILE_SITE/GUILE_SITEDIR typo) this is for
Guile packages, so they can install .sos to GUILE_SITEDIR.

>  # GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
>  #
>  # Usage: GUILE_CHECK_RETVAL(var,check)
> diff -uNr guile-1.7.2.orig/libguile/dynl.c guile-1.7.2/libguile/dynl.c
> --- guile-1.7.2.orig/libguile/dynl.c    2005-03-04 01:12:31.000000000 +0300
> +++ guile-1.7.2/libguile/dynl.c 2005-09-18 23:51:56.000000000 +0400
> @@ -52,9 +52,37 @@
>  #include "libguile/lang.h"
>  #include "libguile/validate.h"
>  #include "libguile/dynwind.h"
> +#include "libguile/srfi-13.h"
> +#include "libguile/load.h"
> +#include "libguile/libpath.h"
>
>  #include <ltdl.h>
>
> +/* List of names of directories we search for files to load.  */
> +static SCM *scm_loc_load_path;

scm_loc_load_libpath would be better.

> +
> +/* Initialize the global variable %load-libpath, given the value of the
> +   SCM_SITELIB_DIR and SCM_LIB_DIR preprocessor symbols and the
> +   GUILE_LOAD_LIBPATH environment variable.  */
> +static void
> +scm_init_load_libpath ()
> +{
> +  char *env;
> +  SCM path = SCM_EOL;
> +
> +#ifdef SCM_LIB_DIR
> +  path = scm_list_3 (scm_from_locale_string (SCM_SITELIB_DIR),
> +                     scm_from_locale_string (SCM_LIB_DIR),
> +                     scm_from_locale_string (SCM_PKGLIB_DIR));
> +#endif /* SCM_LIB_DIR */
> +
> +  env = getenv ("GUILE_LOAD_LIBPATH");
> +  if (env)
> +    path = scm_parse_path (scm_from_locale_string (env), path);
> +
> +  *scm_loc_load_path = path;
> +}
> +
>  /*
>    From the libtool manual: "Note that libltdl is not threadsafe,
>    i.e. a multithreaded application has to use a mutex for libltdl.".
> @@ -68,8 +95,16 @@
>  static void *
>  sysdep_dynl_link (const char *fname, const char *subr)
>  {
> -  lt_dlhandle handle;
> -  handle = lt_dlopenext (fname);
> +  lt_dlhandle handle = NULL;
> +  SCM scm_search_path = scm_string_join (*scm_loc_load_path,
> +                                        scm_from_locale_string (":"),
> +                                        SCM_UNDEFINED/*scm_sym_infix*/);
> +  char * search_path = scm_to_locale_string (scm_search_path);
> +  scm_frame_free (search_path);
> +  if (!lt_dlsetsearchpath (search_path))
> +    {
> +      handle = lt_dlopenext (fname);
> +    }

Will this still allow loading from the usual places as well?

>    if (NULL == handle)
>      {
>        SCM fn;
> @@ -314,6 +349,8 @@
>    scm_tc16_dynamic_obj = scm_make_smob_type ("dynamic-object", 0);
>    scm_set_smob_mark (scm_tc16_dynamic_obj, dynl_obj_mark);
>    scm_set_smob_print (scm_tc16_dynamic_obj, dynl_obj_print);
> +  scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define
> ("%load-libpath", SCM_EOL));
> +  scm_init_load_libpath ();
>    sysdep_dynl_init ();
>  #include "libguile/dynl.x"
>  }
> diff -uNr guile-1.7.2.orig/libguile/Makefile.am 
> guile-1.7.2/libguile/Makefile.am
> --- guile-1.7.2.orig/libguile/Makefile.am       2005-03-08
> 02:03:23.000000000 +0300
> +++ guile-1.7.2/libguile/Makefile.am    2005-09-18 23:23:44.000000000 +0400
> @@ -234,6 +234,9 @@
>         @echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp
>         @echo '#define SCM_LIBRARY_DIR
> "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
>         @echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
> +       @echo '#define SCM_PKGLIB_DIR "$(pkglibdir)"' >> libpath.tmp
> +       @echo '#define SCM_LIB_DIR
> "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
> +       @echo '#define SCM_SITELIB_DIR "$(pkglibdir)/site"' >> libpath.tmp
>         @echo '#define SCM_BUILD_INFO { \' >> libpath.tmp
>         @echo ' { "srcdir", "'"`cd @srcdir@; pwd`"'" }, \' >> libpath.tmp
>         @echo ' { "top_srcdir",    "@top_srcdir_absolute@" }, \' >> 
> libpath.tmp
> diff -uNr guile-1.7.2.orig/libguile/Makefile.in 
> guile-1.7.2/libguile/Makefile.in
> --- guile-1.7.2.orig/libguile/Makefile.in       2005-03-08
> 03:42:07.000000000 +0300
> +++ guile-1.7.2/libguile/Makefile.in    2005-09-18 23:23:50.000000000 +0400
> @@ -1898,6 +1898,9 @@
>         @echo '#define SCM_PKGDATA_DIR "$(pkgdatadir)"' >> libpath.tmp
>         @echo '#define SCM_LIBRARY_DIR
> "$(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
>         @echo '#define SCM_SITE_DIR "$(pkgdatadir)/site"' >> libpath.tmp
> +       @echo '#define SCM_PKGLIB_DIR "$(pkglibdir)"' >> libpath.tmp
> +       @echo '#define SCM_LIB_DIR
> "$(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)"'>>libpath.tmp
> +       @echo '#define SCM_SITELIB_DIR "$(pkglibdir)/site"' >> libpath.tmp
>         @echo '#define SCM_BUILD_INFO { \' >> libpath.tmp
>         @echo ' { "srcdir", "'"`cd @srcdir@; pwd`"'" }, \' >> libpath.tmp
>         @echo ' { "top_srcdir",    "@top_srcdir_absolute@" }, \' >> 
> libpath.tmp

Conclusion: this looks OK to me, but I'm not an expert on this
subject.  I recall previous threads on why it is (or is not) desirable
for all Guile libraries to go into /usr/local/lib or /usr/lib, but I
can't remember what the arguments were.

      Neil





reply via email to

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