From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vorfeed Canal Newsgroups: gmane.lisp.guile.user Subject: PHP to GUILE Date: Mon, 26 Sep 2005 01:50:37 +0400 Message-ID: <6efab235050925145055ba774c@mail.gmail.com> Reply-To: Vorfeed Canal NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1127685389 6625 80.91.229.2 (25 Sep 2005 21:56:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Sep 2005 21:56:29 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 25 23:56:27 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EJeTJ-000407-IW for guile-user@m.gmane.org; Sun, 25 Sep 2005 23:55:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EJeTI-0002ZM-VQ for guile-user@m.gmane.org; Sun, 25 Sep 2005 17:55:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EJeST-0002Kf-3C for guile-user@gnu.org; Sun, 25 Sep 2005 17:54:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EJeSP-0002Il-8Y for guile-user@gnu.org; Sun, 25 Sep 2005 17:54:50 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EJeSN-0002Di-73 for guile-user@gnu.org; Sun, 25 Sep 2005 17:54:47 -0400 Original-Received: from [72.14.204.197] (helo=qproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EJeON-0007Dh-DQ for guile-user@gnu.org; Sun, 25 Sep 2005 17:50:39 -0400 Original-Received: by qproxy.gmail.com with SMTP id p36so351495qba for ; Sun, 25 Sep 2005 14:50:37 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=QSZz4hzfSLhYrC0ib8fKUqShg3P6lwK3OYJnhCyqLiqAj0DBd4vQ377iddq9Qre47MmFkPf6pPxCcls9KtwXh6r1Q4lqWSujvzyEui03xngHmKm1DHuB6DbAhKPTQagi71Xy3GLytMM065jkD8AZ9l5Q8X5BHn6K5mS3rnTG2pc= Original-Received: by 10.65.112.20 with SMTP id p20mr491180qbm; Sun, 25 Sep 2005 14:50:37 -0700 (PDT) Original-Received: by 10.65.100.16 with HTTP; Sun, 25 Sep 2005 14:50:37 -0700 (PDT) Original-To: guile-user@gnu.org Content-Disposition: inline X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:4767 Archived-At: After latest PHP fiasco (when "maintenance release" PHP 5.0.5 broke most PHP programs) I decided that "enough is enough - I need to change language for future projects". I've checked with few alternatives and found that I like SXML better then other packages (Perl, Python, etc). Thus GUILE - it's "official" implementation of Scheme for GNU system, right. 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?). Problems with GUILE core: 1. All C extension files can only be put in /usr/lib - there are no sane way to change libtool's searchpath and there are no sane default. Very annoying. 2. No way to use standard (for modern languages like C++, PHP or Java) scheme with throw/catch and EXCEPTIONS HIERARCHY. Problems with GUILE extesions: 1. Good MySQL binding: both SimpleSQL and Guile-DBI do not give you access to even basic stuff like mysql_insert_id. Guile-PG looks promising but is not compatible with Guile 1.7.x (and earlier versions do not support SMP)... 2. No GD/ImageMagick bindings (or are there ones?). 3. GuileFCGI is not compatible with GUILE 1.6.x or GUILE 1.7.x. There are mod_lisp (with GUILE module) but it does not support responses without known length (and it's not always feasible to create answer in "one go"). What are advantages of mod_lisp over mod_fastcgi ? While problems with GUILE extensions are not critical (I'll be happy if someone will show me good MySQL or ImageMagick bindings but I can write them myself if there will be no other choice) problems with GUILE core are other story. About first problem: default extensions load path ONLY includes three directories: "/lib", "/usr/lib" and "." (in this order). You can change it from scheme with (setenv "LTDL_LIBRARY_PATH" "/usr/local/blah") but there are no standard place to put extensions while normal script languages have one or two (like Perl's site_perl vs vendor_perl). It can de fixed with simple patch (see below), so real question is "why the hell it was not done five years ago?" ... About second problem. GNU Kawa (if we are talking about GNU GUILE it makes sense to borrow from GNU Kawa, right?) has the following solution to this problem: http://per.bothner.com/tmp/kawa/Exceptions.html primitive-throw exception Throws the exception, which must be an instance of a sub-class of . Syntax: try-finally body handler Evaluate body, and return its result. However, before it returns, evaluate handler. Even if body returns abnormally (by throwing an exception), handler is evaluated. (This is implemented just like Java's try-finally.) Syntax: try-catch body handler ... Evaluate body, in the context of the given handler specifications. Each handler has the form: var type exp ... If an exception is thrown in body, the first handler is selected such that the thrown exception is an instance of the handler's type. If no handler is selected, the exception is propagated through the dynamic execution context until a matching handler is found. (If no matching handler is found, then an error message is printed, and the computation terminated.) Once a handler is selected, the var is bound to the thrown exception, and the exp in the handler are executed. The result of the try-catch is the result of body if no exception is thrown, or the value of the last exp in the selected handler if an exception is thrown. (This is implemented just like Java's try-catch.) 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... 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: 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=3D`[$GUILE_CONFIG] info pkglibdir`/site + AC_MSG_RESULT($GUILE_SITEDIR) + AC_SUBST(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 +/* List of names of directories we search for files to load. */ +static SCM *scm_loc_load_path; + +/* 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 =3D SCM_EOL; + +#ifdef SCM_LIB_DIR + path =3D 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 =3D getenv ("GUILE_LOAD_LIBPATH"); + if (env) + path =3D scm_parse_path (scm_from_locale_string (env), path); + + *scm_loc_load_path =3D 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 =3D lt_dlopenext (fname); + lt_dlhandle handle =3D NULL; + SCM scm_search_path =3D scm_string_join (*scm_loc_load_path, + scm_from_locale_string (":"), + SCM_UNDEFINED/*scm_sym_infix*/); + char * search_path =3D scm_to_locale_string (scm_search_path); + scm_frame_free (search_path); + if (!lt_dlsetsearchpath (search_path)) + { + handle =3D lt_dlopenext (fname); + } if (NULL =3D=3D handle) { SCM fn; @@ -314,6 +349,8 @@ scm_tc16_dynamic_obj =3D 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 =3D 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/Makefi= le.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/Makefi= le.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 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user