Re: Shell commands with output to string
On Tue, 22 Feb 2022 at 10:23, Alex Sassmannshausen wrote: > > Hi Zelphir, > > I think you want to be using the popen / pipe procedures for this. See > https://www.gnu.org/software/guile/docs/docs-2.2/guile-ref/Pipes.html > for the chapter in the manual. Another example, for reading transactions out of a Ledger file: (use-modules (ice-9 popen)) (define (ledger-transactions filename account payee commodity year) (let* ((cmd (string-append "ledger -f " filename)) (cmd-add! (lambda strings (set! cmd (apply string-append cmd " " strings) (if payee (cmd-add! "-l 'payee=~/" payee "/'")) (if year (cmd-add! "--begin " (number->string year) " --end " (number->string (1+ year (cmd-add! "reg") (if account (cmd-add! account)) (cmd-add! "-F '(\"%(format_date(date, \"%Y-%m-%d\"))\" \"%P\" \"%(t)\")\n'") (let ((p (open-input-pipe cmd))) (let loop ((txs '())) (let ((tx (read p))) (if (eof-object? tx) (reverse! txs) (begin (if commodity (set-car! (cddr tx) (string-replace-substring (caddr tx) commodity ""))) (loop (cons tx txs)
Re: Proposal: Deep Dive into the Guile Docs & Makeover Proposal
On Thu, 17 Feb 2022 at 16:59, Blake Shaw wrote: > > https://tube.nocturlab.fr/videos/watch/2b55ca09-f0fd-4899-9cb0-9632cd90b3d1 Wow, what a great reminder of things past! I mean "past" in the sense that I used to be very strongly focused on this, but have not been for some years. The material is, happily, still very relevant in the present, so well worth addressing how it can be improved. I'm only about half way through the video so far, but already wanted to mention a couple of points. Firstly, about the Guile Recipes... I had entirely forgotten about that, but yes, it indicates that we were having the same kind of conversation about a cookbook several years ago as we are now. Undeniably the guidelines / contribution structure then did not work! Let's hope someone can devise a better structure this time around. Secondly, what I think is the overall reason the docs are such a mess... Guile has always has a central tension between Scheme-centric and C-centric usage. - Scheme-centric usage is: Write your main program and most of its code in Scheme. When you need to use something from a C library, use the FFI to do that, or dynamically load a shared object that exposes function as Scheme objects and procedures. - C-centric usage is: You already have a big main program written in C, and you only want to allow Scheme to get involved, at certain points, as part of a config/customization-language-on-steroids model. You expose some of your function as Scheme objects and procedures, and call out to a user-configured Scheme file (which can use those objects and procedures) at the relevant points in the C processing. Personally, I am now a big fan of Scheme-centric + FFI, as it means always writing Scheme and never having to hack C code. If everyone agreed on that, we could discard all the C-centric parts of the manual, and focus the rest on a clearer use case. But I very much doubt that there is clear agreement on that. In particular, the C-centric usage is really Guile's original reason for existing: to act as a universal extension language for lots of GNU programs that already exist. I think expressing that dichotomy, and arranging the docs as clearly as possible while still allowing for both sides, is still our number 1 problem. Best wishes, Neil
Re: Proposal: Deep Dive into the Guile Docs & Makeover Proposal
Hi Blake, On Tue, 8 Feb 2022 at 08:55, Blake Shaw wrote: > [...] > > Serving at once as a referrence manual & API specification, the large size > may in part be attributed to what simultaneously makes Guile an appealing > project to contribute to, while also rendering the documentation process > somewhat delicate: Guile is a massive collective project featuring the > contributions of many authors over the course of three decades, contributions > which Guilers would hate to trivialize or treat as insignificant or edit away > on a whim. Additionally, Guile comes from a long set of traditions within > Scheme hacking which itself is deep with sage wisdom spanning many > pedagogical philosophies and one of the greatest literature traditions of > hacker culture. Is it possible to perform a makeover of the Guile > Documentation while respecting these historical threads, at once rendering it > more approachable for new users while not forsaking the deep nuggets of > wisdom that lie therein? > > Since mid-December I have been mulling over these questions as newcomer, both > studying & analyzing the docs, and trying to come to grips with it's > strengths and shortcomings. For this talk, I will present my research to the > Guix community, culminating with a plan for a full makeover of the existing > docs which would respect the above concerns. I will use the 5 minute > presentation to focus on the plan of action, with hopes that during the Q > we can come to consensus on what is to be done. The decisions made by the > group will form the basis of a proposal to be made to the Guile community, > and once everyone is in agreement with plans for how to move forward I will > undertake the effort to implement the makeover proposal. Speaking as one of the past authors of the manual, I look forward to hearing your thoughts. It is genuinely challenging to present this amount of material and explain its complexity, and there is no reason at all to consider any current arrangement as cast in stone. Thanks for thinking about this. Best wishes, Neil
Re: Question about data structures
On Sun, 22 Nov 2020 at 18:49, Zelphir Kaltstahl wrote: > Hello Guile Users! > > I have a question about data structures. > > Recently I read a file and the lines in the file would become a list in > my Guile program. The file was not super big or anything. However, I > usually try to avoid having to use `append` or `reverse`, whenever > possible, considering, that they are O(n) operations and in principle I > do not want to write code, that uses lists in inefficient ways, when > there is a more efficient way. That said, I hit a little snag: > > When I am reading a file and do not know how many lines there are in the > file, I can use a normal list and construct it using recursive calls > like `(cons line (iter ...))` where `iter` is the recursive call and. > Could also be called `process-next-line` or simply `next`. Since I am > building a recursive data structure, it is OK to have a non-tail > position recursive call. Then I would return that list and work with it. > However, what if I ever need to add a list entry and the order of list > entry matters? I would either have to use `append`, to add it to the > end, which would be O(n), or I would have to initially construct the > list of lines in reversed order from initially, so that I can add by > simply using `(cons new-entry lines)`. However, when I use the list in > reverse and ever need to output the lines in the list in their original > order, I would first need to `reverse` the list again. > > OK the whole reversing would not be a problem, if I used a vector to > store the lines. However, then I would need to know the number of lines > in the file ahead of time or look at the file once for counting the > lines, then create the vector of that length and then store the lines in > it. This seems inelegant again, because I look at the lines of the file > twice. I could read it in as a list and then use `list->vector`, but > that will also be an additional O(n) for converting every entry to > vector element. > > If I now think about Python, then I have Python lists (actually arrays?) > and those can be easily appended to in O(1) and random access is also > O(1) according to https://wiki.python.org/moin/TimeComplexity. This > means I do not need to think much about how I will use the lines of a > file, when reading in the file. A Python list will be appropriate. > > So in Guile I sometimes feel some mental overhead of thinking about the > choice of data structure, which I do not feel in Python. Generally I > like Guile a lot more, so I would like to know how others deal with > this. Here are some ideas for it: > > 1. I could create some abstraction layer for the "sequence of read > lines", which I use inside the procedure, which reads in the lines and > all other code, that works with the lines, so that I can rather easily > later exchange the data structure. A data abstraction. However, that > might only hide the complexities of some operations behind the > abstraction and not reduce them. > > 2. Perhaps I want Guile's arrays? (Can they be expanded in O(1)? I do > seem to remember reading, that Guile vectors are only a special case of > Guile arrays, so that would mean they are not expandable in O(1).) > > 3. Just convert list to vector after reading in the file until I hit a > problem, where that additional O(n) really becomes a problem. (In my > current project it is not realistically a problem.) But this does not > satisfy me. I should learn how to solve the problem in general and use > the best way to do things. > > 4. Perhaps I need to write another data structure, that creates a new > vector, when the previous one is full, managing the expansion myself. > > How do you approach this problem? Is it a problem at all? My standard pattern: (let loop ((input input) (output '())) (if (null? input) (reverse output) (loop (cdr input) (cons (process (car input)) output
Re: Questions about (open-input-output-pipe
I guess it's because "wg pubkey" has not yet seen EOF on its input, i.e. it doesn't know that the input is complete. If that's right, I'm afraid I don't know how to fix it. Presumably you need a call that closes half of the port, but still allows reading the "wg pubkey" output from it. Alternatively, it might be buffering, i.e. the private key hasn't yet reached "wg pubkey". In that case (force-output port) might help. Best wishes, Neil On Tue, 10 Nov 2020 at 08:51, luhux wrote: > Hello everyone > > I am a newbie to guile and I am learning to use guile to write scripts > > I want to implement this shell command: > > > wg pubkey < private > public > > > > This is a command to generate a key, > It inputs private key and EOF from stdin, then it outputs the public key > and exits. > > I implemented it using the following code in guile: > > > > (use-modules (ice-9 popen) > (ice-9 rdelim)) > > (define (wg-gen-private-key) > (let* ((port (open-input-pipe "wg genkey")) > (result (read-line port))) > (close-pipe port) > result)) > > (define (wg-gen-public-key private-key) > (let ((port (open-input-output-pipe "wg pubkey"))) > (display private-key port) > (let ((result (read-line port))) > (close-port port) > result))) > > > Then I executed the code to get the public key > > > > > scheme@(guile-user)> (wg-gen-public-key (wg-gen-private-key)) > > > > > but the code got stuck in this place: > > > > > (let ((result (read-line port))) > > > > > How should I do? > > There are too few Guile information on the Internet. Sorry for asking such > a basic question. > > luhux > >
Re: Need help starting a project in Guile - distributed DE / GUI toolkit using Wayland
On Mon, 23 Mar 2020 at 01:36, Jan wrote: > Hello, > > I would like to make my project in Guile, but I'm not really an > advanced programmer yet - I made some hello worlds in C++, simple 2D > and 3D games in JS using WebGL and I've read basics of Guile from the > manual and Scheme generally from SICP (few chapters) and other sources, > made some really simple programs in Guile and packages for Guix. > > The problem is I don't know where to start and which parts of the > language and features of GNU/Linux I have to understand well in order > to at least make a prototype. > > The project idea is a distributed and extensible DE and GUI toolkit > treating its elements as objects (something like the UNIX philosophy). > I would like to use Wayland, or if possible wlroots, but there are no > Guile bindings available. > > So for the project I need: > - a wayland client written in Guile, wlroots (foreign function > interface?) I need to talk to the wayland server somehow > - a good interprocess communication - I want different components of my > DE / GUI toolkit to be separated processes talking to each other > (POSIX socets?) > > Sorry for my vague understanding of the subject, I'm not studying CS. > I would like to know what should I read/know to make this real. > Where can I read about programming for an UNIX-like OS? > Can I avoid learning C/C++ deeply? I know basics of C syntax, but > I would like to do everything in Scheme, you know, it's much cooler :) > > > Thanks for reading this > > Jan Wielkiewicz > Hi Jan, You don't need specially coded Wayland bindings for Guile. You can use Guile's generic Foreign Function Interface [1]. For an example, see [2], although that particular code might be outdated as I haven't run it for a while. [1] https://www.gnu.org/software/guile/manual/html_node/Foreign-Function-Interface.html#Foreign-Function-Interface [2] http://git.savannah.nongnu.org/cgit/ossaulib.git/tree/glib/dbus.scm Best wishes, Neil
Re: Weird Guile Scheme Behaviour
Correct usage of append! usually requires (set! x (append! x )), despite what you might think from the !. I haven't read the rest of your email carefully, but I wonder if that will make a difference? Best wishes, Neil On Fri, 13 Sep 2019 at 13:39, Philip K. wrote: > > Hi, > > I was reading a thread on an imageboard[0] the other day, then I came > across a most peculiar "bug", if it even is one. Since the original > example was a bit dense (it tried to solve a problem someone else had > posted, that's not relevant here), I tried to construct a minimal > working example to discuss here. > > Compare > > (define (reverse-iota-1 max) > (let ((numbers '(start))) > (let loop ((val 0)) > (append! numbers >(if (< max val) >'() >(begin > (loop (1+ val)) > (list val) > numbers)) > > and > > (define (reverse-iota-2 max) > (let ((numbers '(start))) > (let loop ((val 0)) > (append! numbers >(if (< max val) >'() >(begin > (loop (1+ val)) > (list val) > (cdr numbers))) > > (I know, the style is horrible, but that's not the point. Also, both > have an internal state, so you have to re-eval the function every time > before starting the function itself.) > > The only difference is in the last line. The first function returns the > entire list (with the start symbol), and the second tries to chop it > off. > > But what happens is that (reverse-iota-1 4) evals to '(start 3 2 1 0) > while (reverse-iota-2 4) just returns '()! > > This seems weird, since my intuition, and that of the poster above, was > that all that should change in reverse-iota-2 is that the "start" symbol > should fall away. > > It's obvious that this has something to do with the destructive > "append!", but I'm not quite sure what leads to this unexpected result. > Is it maybe a optimisation error? Any opinions? > > [0]: https://lainchan.org/%CE%BB/res/12185.html#15066 (SFW) > > -- > With kind regards, > Philip K. >
Re: shell script to start guile w/ repl
On Wed, 6 Mar 2019 at 01:22, Matt Wette wrote: > > Hi All, > > I'm trying to generate a shell script that sets up environment for guile and > then executes a guile repl. I can do that. It is here: > >#!/bin/sh > >LD_LIBRARY_PATH=/path/to/my/lib >export LD_LIBRARY_PATH > >exec guile -ds $0 $@ >!# > >;; ... stuff ... > >(use-modules (ice-9 top-repl)) >(top-repl) > > > Now I would like to have the top-repl use an alternate language. > How do I do that? I tried > >(*current-language* (lookup-language 'nx-tcl)) >(top-repl) > > But this fails. Any hints? Just guessing, but perhaps: (fluid-set! *current-language* 'nx-tcl) or (fluid-set! *current-language* (lookup-language 'nx-tcl)) ? Neil
Re: [ANN] Guile Hall Release (v0.2)
On Fri, 15 Feb 2019 at 16:33, Alex Sassmannshausen wrote: > [...] > Otherwise you can get the code from > https://gitlab.com/a-sassmannshausen/guile-hall/, and build (hopefully) Hi Alex, It's a bit of a side point, but I noticed that your org-mode README is not properly formatted on the Gitlab site, and it looks like it would be if you named it README.org. Is that something you're already aware of? Thanks, Neil
Re: how to use gsl with the guile ffi
tantalum writes: > so far i couldnt find the cause with strace. Well I think I'm just stating the obvious here, but clearly libgslcblas.so is OK - > openat(AT_FDCWD, "/usr/lib/libgslcblas.so", O_RDONLY|O_CLOEXEC) > = 7 - and also libgsl.so - > openat(AT_FDCWD, "/usr/lib/libgsl.so", O_RDONLY|O_CLOEXEC) > = 7 - but apparently the system also needs libgsl.la, and that isn't found at the expected place: > openat(AT_FDCWD, "/usr/lib/guile/2.2/extensions/libgsl.la", O_RDONLY) > = -1 ENOENT (No such file or directory) I'm afraid I don't know any more, e.g. about whether libgsl.la _should_ be needed here. Neil
Re: how to use gsl with the guile ffi
tantalum writes: > im getting the error "In procedure dynamic-link: file: "libgsl", > message: "file not found"" with the following code: > > (import (system foreign)) > (define gsl (dynamic-link "libgsl")) > > * gsl (optionally?) depends on libgslcblas, which itself links without > error, but loading it with (dynamic-link) beforehand did not help > * some libraries work, for example libmagic. libm for example gives the > same error message > * the file /usr/lib/libgsl.so exists and is a symlink to the regular > file libgsl.so.23.1.0 whose content begins with ELF> > * similar problem on the mailing list > https://lists.gnu.org/archive/html/guile-user/2016-05/msg00010.html > * ive tried to set LD_LIBRARY_PATH with export to /usr/lib with no > apparent effect > * i was going from this manual entry > https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html > * guile (GNU Guile) 2.2.4 > > the issue can actually be reproduced with a c program: > > #include > #include > > int main () { >void* a = dlopen("libgsl.so", RTLD_NOW); >printf("got %p\n", a); >if (a) printf("ok\n"); else printf("error: %s\n", dlerror()); > } > > gcc t.c -ldl && ./a.out > > the program only works without error when compiled with -lgslcblas. > so, it could be a more basic issue, but i dont know how to proceed. You could run under strace to confirm which files are being looked for, and which of those are not found. Regards, Neil
Re: Guile equivalent to JS promises?
swedebu...@riseup.net writes: > Hi > > I'm trying to understand JS promises. > > Are promises relevant in Guile? > > According to https://www.promisejs.org/ they seem to be a tool to > read/write JSON in a nonblocking way. > > Is this related to threading where the JS dev want multiple threads to > read stuff asynchroniusly at the same time? > > -- > Cheers > Swedebugia I don't know JS promises, but have you seen https://www.gnu.org/software/guile/manual/html_node/Delayed-Evaluation.html? Regards, Neil
Re: Beginner questions
Catonano writes: > Neil, > > Il giorno lun 19 nov 2018 alle ore 10:02 Neil Jerram < > n...@ossau.homelinux.net> ha scritto: > >> >> >> On 18 November 2018 19:33:31 GMT, Catonano wrote: >> >Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia >> > >> >ha scritto: >> > >> >> Hi >> >> >> >> I would like to learn more scheme and I would like to make a small >> >CLI >> >> program that runs in the terminal and prompts the user for input and >> >> evaluates it. >> >> >> >> Is that possible with guile? In the REPL? >> >> >> >> Can someone point me in the right direction for succeding with that? >> >> >> >> >> >> >> > >> > Hi >> > >> >I am curious: did you manage to put together a prototype of this thing >> >prompting a user in the terminal ? >> >> In case it's of interest, I wrote this kind of thing a few years ago: a >> command loop for Guile where you can register possible commands, and each >> command has a spec like the Emacs 'interactive' form that says what the >> args are and how to prompt for them. >> >> The command loop entry point is at >> http://git.savannah.nongnu.org/cgit/ossaulib.git/tree/ossau/command-loop.scm >> and the dependency modules are all included in that git repo. >> >> Best wishes, >> Neil >> > > thank you > > But I'm a bit overwhelmed by so much code Thanks for taking a look. It is a _lot_ of code, so I can understand it being overwhelming. > a tiny example of reading a short string that a user could type at a prompt > would be more useful to a beginner, I think > > I came up with this short example > > (use-modules (ice-9 rdelim)) > > (let ((str (read-line (current-input-port > (display (string-append str "\n"))) > > it's extremely essential but it demonstrates the usage of the current input > port in association with delimited text reading > > This is a very basic use case, intended as an example, a step 0 for further > developments I started with that (or something very like it), but then gradually added more structure for the specific applications that I had in mind... and surprisingly quickly we can end up with the amount of code that I have in ossaulib. Best wishes, Neil
Re: How to pass the address of an pointer object to c?
Fis Trivialwrites: > Hi, all. > I'am trying a wrap a math library written in c with guile scheme. Here > is an example declaration of c type and function in that math library: > > typedef void* array; > typedef int err; > > err randu(array* result, int ndims, long long *dims, dtype type); > > > > The problem is I want to create a void* (aka array), and pass its > address (aka array*) to the underlying c function for modification. Here > the /array/ type acts as a handle. > > I tried the following scheme code: > > (let* ([val (make-pointer 0)] ; void* val = 0 >[ (make-pointer (object-address val))] ; a pointer points to val? >[randu (pointer->procedure int >; a function generating random matrix. > (dynamic-func "randu" backend) >; result, ndims, dims, type > (list '* uint32 '* int))] >; dims is an byte-vector representing c array, 0 represents an >; enum value in c. >(randu 4 dims 0))) > > > But when I use gdb to watch the values in c code of randu with: > print *result > > and gdb displayed: 0x1f, > while it should be 0 as defined in scheme code. > > Is there anything I did wrong? Or there are other ways around? I want to > do it in scheme, otherwise I have to wrap every c functions. > > Thanks. :) Would it work for you to use `%null-pointer' ? >From `(guile) Foreign Variables': -- Scheme Variable: %null-pointer A foreign pointer whose value is 0. Best wishes, Neil
Re: Signals / Messages / Events / ...?
On 03/01/18 15:11, Christopher Howard wrote: On Wed, 2018-01-03 at 11:53 +, Neil Jerram wrote: Well, one Lispy mechanism in that area is hooks. For example, from some of my old code: ;; Changes to modem registration state are indicated by calling this ;; hook with args STATE and PROPERTIES. STATE can be 'none, meaning ;; that there is currently no modem; 'unregistered, meaning that there ;; is a modem but it isn't registered with the network; or ;; 'registered, meaning that the modem is registered with the network. ;; If STATE is 'registered, PROPERTIES is an alist of registration ;; properties; otherwise PROPERTIES is #f. (define registration-hook (make-hook 2)) (define (add-registration-hook proc) (add-hook! registration-hook proc)) (define (notify-registration state properties) (run-hook registration-hook state properties)) Does that serve your purpose at all? Best wishes - Neil I think that should work. Only part I'm not sure about is if you can have a "one-off" procedure added to a hook... but you could just have the procedure call remove-hook! to remove itself...? Yes, I think so, and you could encapsulate that with something like this: (define (add-hook-once-only! hook proc) (letrec ((proc-once-only (lambda args (remove-hook! hook proc-once-only) (apply proc args (add-hook! hook proc-once-only))) Best wishes - Neil
Re: Signals / Messages / Events / ...?
On 03/01/18 05:09, Christopher Howard wrote: Hi list, forgive me if this is a somewhat vague question... but is there some kind of framework/system/approach for Guile where you could have different parts of your code register callback functions to react to a certain signal or message raised by any other part of the code? I'm thinking like dbus where I guess you can sort of send off a message but not really care who receives it. In chickadee you can register callbacks for the various input events, and i think that basic idea could be extended so long as (1) you could have any kind of event/signal you wanted; (2) call backs added could be specified as either persistent or one-time call-backs. It seems like it wouldn't be too hard to code something like that with just lists of callback functions tied to names/data in a tree. But maybe somebody has already thought of that or would suggest a better approach. Just running into this challenge in development where a function like "new-game" has to do 8 different things to 6 different data structures, but why not instead just have the code dealing with the 6 different objects register callbacks to receive the 'new-game signal? I think message passing is the wrong term because in message passing you specify the message connections between the different objects, right? Signal bus maybe? Well, one Lispy mechanism in that area is hooks. For example, from some of my old code: ;; Changes to modem registration state are indicated by calling this ;; hook with args STATE and PROPERTIES. STATE can be 'none, meaning ;; that there is currently no modem; 'unregistered, meaning that there ;; is a modem but it isn't registered with the network; or ;; 'registered, meaning that the modem is registered with the network. ;; If STATE is 'registered, PROPERTIES is an alist of registration ;; properties; otherwise PROPERTIES is #f. (define registration-hook (make-hook 2)) (define (add-registration-hook proc) (add-hook! registration-hook proc)) (define (notify-registration state properties) (run-hook registration-hook state properties)) Does that serve your purpose at all? Best wishes - Neil
Re: Mes 0.8 released
Hi Jan, Thanks for your answer. I'm afraid I have no better ideas than the ones that you have listed - and in fact I wouldn’t have known about those ones either. I was just curious about what the next step would be. It certainly seems to me like an interesting and worthwhile project. Best wishes - Neil Original Message From: Jan Nieuwenhuizen Sent: Monday, 26 June 2017 11:22 To: Neil Jerram Cc: guile-user@gnu.org; guix-de...@gnu.org; epsilon-de...@gnu.org Subject: Re: Mes 0.8 released Neil Jerram writes: Hi Neil! > In your bootstrap path, what is the step after Mes? I guess it would > be using mescc to compile some C program - but if that is right, which > program? Indeed. Short answer: I don't know. Do you have something in mind? We haven't decided yet and are still exploring possibilities. We are looking for the target that requires the least amount of work to get us close the bootstrap path to gcc. The most obvious candidate to compile with mescc is tinycc. rain1 has worked with the tinycc and succeeded in compiling GCC 4.7.0 using tinycc[0]. However, tinycc uses C constructs that mescc does not support [yet] and libc functions that mescc's libc does not have. So we are also considering other candidates such as 8cc, pcc, the ack, cc500, gcc-2.95 (what about earlier gcc's?). Another possible first target for Mescc could be libguile/eval.c ;-) and develop a fork/sister of mescc as guilecc. Greetings, janneke [0] https://lists.gnu.org/archive/html/tinycc-devel/2017-05/msg00103.html -- Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Re: Mes 0.8 released
Hi Jan, In your bootstrap path, what is the step after Mes? I guess it would be using mescc to compile some C program - but if that is right, which program? Regards - Neil Original Message From: Jan Nieuwenhuizen Sent: Sunday, 25 June 2017 17:40 To: guile-user@gnu.org Cc: guix-de...@gnu.org; epsilon-de...@gnu.org Subject: Mes 0.8 released I am pleased to announce the release of Mes 0.8, representing 34 commits over 3 weeks. Mescc now produces object files in the hex2 ascii output format compatible with the stage0 linker. Special thanks to Jeremiah Orians for support with MESCC_Tools and hex2, more goodness to follow soon! * About Mes aims to create full source bootstrapping for GuixSD: an entirely source-based bootstrap path. The target is to [have GuixSD] boostrap from a minimal, easily inspectable binary --that should be readable as source-- into something close to R6RS Scheme. It currently consists of a mutual self-hosting [close to Guile-] Scheme interpreter prototype in C and a Nyacc-based C compiler in [Guile] Scheme. The Scheme interpreter prototype (mes.c) has a Garbage Collector, a library of loadable Scheme modules-- notably Dominique Boucher's LALR[1], Pre-R6RS portable syntax-case[2] with R7RS ellipsis, Matt Wette's Nyacc[3] Guile's PEG[4] --and test suite just barely enough to support a simple REPL (repl.mes) and simple C-compiler (mescc.mes) that can produce the second initial ELF binary from binary from mes.c, in only about 2h30'. Mes was inspired by The Maxwell Equations of Software: LISP-1.5[5] -- John McCarthy page 13, GNU Guix's[6] source/binary packaging transparency and Jeremiah Orians's stage0[7] bootstrap project. * Download git clone https://gitlab.com/janneke/mes wget https://gitlab.com/janneke/mes/repository/archive.tar.gz?ref=v0.8 -O mes-0.8.tar.gz Mes runs from the source tree and can also be built, packaged and installed in Guix[SD] by the usual guix package -f guix.scm * Changes in 0.8 since 0.7 ** Mescc *** Mescc now depends on the hex2 linker from MESCC_Tools[9]. Direct ELF output support has been removed. ELF symbol and string table creation has been removed. *** Mescc now has experimental annotation support for hex2. *** Mescc has experimental annotation support for hex2. *** Mescc has been simplified by leveraging use labels in hex2 output. *** Mescc now supports continue in loops. *** Mescc now compiles to hex2 object files. ** Language *** 1 new function list-index. Greetings, janneke [1] https://github.com/schemeway/lalr-scm [2] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html [3] https://www.nongnu.org/nyacc/ [4] https://www.gnu.org/software/guile/docs/master/guile.html/PEG-Parsing.html [5] http://www.softwarepreservation.org/projects/LISP/book/LISP%25201.5%2520Programmers%2520Manual.pdf [6] https://www.gnu.org/software/guix/ [7] https://github.com/oriansj/stage0 [8] https://gitlab.com/janneke/tinycc [9] https://github.com/oriansj/MESCC_Tools -- Jan Nieuwenhuizen| GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Re: Multiple values passed as single argument to procedure
On 12/06/17 09:55, Neil Jerram wrote: On 12/06/17 09:19, Chris Marusich wrote: I think I'm missing something here. In (list (f)), the call to f certainly looks like it's happening at a position that one might intuitively call a "tail" position. So, in this case, what disqualifies f from being in tail position? Can you give me an example of a call to f that would be in tail position, so I can understand the difference? Sorry if you've already provided such an example; I appreciate your explanations, and I'm just trying to make sure I fully understand. Mark will probably have a more precise answer for you, but let me offer my understanding too. In general, in ( ... arbitrary code around ... (f) ... ) the (f) call is in a tail position if _nothing_ else needs to be done, to the return value(s) of (f), before returning from that block as a whole. So, common examples of tail position are (begin ... (f)) and (if (f)) The case you mentioned, (list (f)), is probably the simplest example of a non-tail position, because something very clearly does need to be done to the return value of (f): it needs to be inserted into a newly allocated list. Regards - Neil Oh, following David's reply, I see that my reply here may have missed your point - sorry if so! (Yes, it is undeniable that '(f)' is in tail position in the expression '(f)' :-). ) Neil
Re: Multiple values passed as single argument to procedure
On 12/06/17 09:19, Chris Marusich wrote: I think I'm missing something here. In (list (f)), the call to f certainly looks like it's happening at a position that one might intuitively call a "tail" position. So, in this case, what disqualifies f from being in tail position? Can you give me an example of a call to f that would be in tail position, so I can understand the difference? Sorry if you've already provided such an example; I appreciate your explanations, and I'm just trying to make sure I fully understand. Mark will probably have a more precise answer for you, but let me offer my understanding too. In general, in ( ... arbitrary code around ... (f) ... ) the (f) call is in a tail position if _nothing_ else needs to be done, to the return value(s) of (f), before returning from that block as a whole. So, common examples of tail position are (begin ... (f)) and (if (f)) The case you mentioned, (list (f)), is probably the simplest example of a non-tail position, because something very clearly does need to be done to the return value of (f): it needs to be inserted into a newly allocated list. Regards - Neil
Re: Two variables that are linked together by an heuristic (constraint programming?)
Perhaps by making 'cursor' relative to 'view'? Then you could always declare / assert that (>= cursor-x 0) (< cursor-x (screen-width)) ; and similarly for cursor-y Neil Original Message From: Amirouche Boubekki Sent: Tuesday, 25 April 2017 10:40 To: Guile User Subject: Two variables that are linked together by an heuristic (constraint programming?) Héllo! In the editor I am working on, two variables are linked together. That is the value of one depends on the value of the other. There is a `view` position a cons of integers x and y which denotes the top left position of the editor window in the buffer. Basically, it defines the top left position of the rectangle of the visible part of the buffer. The visible part of the buffer is called the viewport. There is the `cursor` position which is also a cons of integers x and y. The cursor defines the position of the cursor inside the text buffer. cursor and view are linked by the property that cursor must always be inside the viewport, that is the visible part of the buffer. Otherwise said, if the cursor is at the bottom of the view port, and I hit 'down arrow' the viewport must scroll hence view's y must be incremented. Similarly if I am at the top of the viewport and I hit 'up arrow' the viewport must scroll. I see that the cursor position is constrainted by the view (and the buffer). How can I express that in a nice and clean way? -- Amirouche ~ amz3 ~ http://www.hyperdev.fr
Re: ?-suffix for booleans... good-idea? or bad-idea?
I'm also not sure. In the past I've written code with an 'xxx?' variable, and then added a procedure to set it, giving 'set-xxx?!' - which is not exactly elegant. Also I'm not sure it's best practice to have many variables/attributes/parameters with boolean values, as this can lead to code that has too many opaque uses of #t and #f. (I.e. it's often unclear, at the point of use, what each #t or #f means.) It might be better to refactor to something with non-boolean values, e.g. from (set! red? #t) (set! narrow?#t) to (set! properties '(red narrow)) And in that case the question about '?' would disappear. Regards, Neil On 25/04/17 04:43, Alex Vong wrote: Good question! I can't decide as well. I want to know how people think about it. In a lazy language, a variable is a 0-ary thunk, while a predicate is a 1-ary thunk. Since they are really just special case of a general thing, it make sense to use foo? for both cases. But we all know guile is not lazy, so I really don't know what to do. Christopher Allan Webberwrites: Hello everyone! Here's a little bikeshed for us to paint. I've noticed that it's common in Guile modules to use "foo?" for variable names involving booleans. It's tempting, because this looks an awful lot like you're asking a question... and it's also common for this even to be keyword arguments to procedures, etc. But is it a good idea? I thought "foo?" was supposed to be for predicates, as a nicer version of the "foo-p" predicate convention in other non-scheme lisps. I can't imagine other lisps doing "foo-p" for just variables with boolean values. On the other hand, once you start adding ? to the end of boolean'y things, it *does* become tempting to put them at the end of boolean variables and arguments. It looks pretty nice. What do people think? I'm struggling with deciding what's the right thing for my own code, but leaning towards "we shouldn't use the ? suffix for just boolean values". - Chris
Re: Getting started with tekuti
The attached seems to help. With that, the stdout no longer shows errors, and I see a sensible-looking web UI at http://localhost:8080 and http://localhost:8080/admin. On 06/04/17 22:52, Neil Jerram wrote: Hey Andy, I'm just trying to get started with tekuti, but am hitting problems which look like they're associated with having no content yet. I've appended a transcript below - can you see what's wrong? Thanks - Neil neil@neil-laptop:~/SW/tekuti$ ./env src/tekuti ;;; note: source file /home/neil/SW/tekuti/tekuti/git.scm ;;; newer than compiled /home/neil/SW/tekuti/tekuti/git.go ;;; found fresh local cache at /home/neil/.cache/guile/ccache/2.2-LE-8-3.9/home/neil/SW/tekuti/tekuti/git.scm.go ;;; note: source file /home/neil/SW/tekuti/tekuti/util.scm ;;; newer than compiled /home/neil/SW/tekuti/tekuti/util.go ;;; found fresh local cache at /home/neil/.cache/guile/ccache/2.2-LE-8-3.9/home/neil/SW/tekuti/tekuti/util.scm.go ;;; note: source file /home/neil/SW/tekuti/tekuti/web.scm ;;; newer than compiled /home/neil/SW/tekuti/tekuti/web.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/neil/SW/tekuti/tekuti/web.scm ;;; note: source file /home/neil/SW/tekuti/tekuti/post.scm ;;; newer than compiled /home/neil/SW/tekuti/tekuti/post.go ;;; found fresh local cache at /home/neil/.cache/guile/ccache/2.2-LE-8-3.9/home/neil/SW/tekuti/tekuti/post.scm.go ;;; compiled /home/neil/.cache/guile/ccache/2.2-LE-8-3.9/home/neil/SW/tekuti/tekuti/web.scm.go ;;; (reading-index) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "rev-parse" "refs/heads/index")) fatal: ambiguous argument 'refs/heads/index': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' ;;; (start-clock) ;;; (start-clock) ;;; (posts) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "ls-tree" "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd" ".")) ;;; (stop-clock 0.005752) ;;; (start-clock) ;;; (posts-by-date) ;;; (stop-clock 4.4996e-5) ;;; (start-clock) ;;; (tags) ;;; (latest-posts ((posts-by-date) (posts . #0/31>) (master . "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd"))) ;;; (filter-mapn ()) ;;; (stop-clock 1.75e-4) ;;; (start-clock) ;;; (legit-comments) ;;; (computing-legit) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "ls-tree" "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd" ".")) ;;; (done #) ;;; (stop-clock 0.0056544) ;;; (start-clock) ;;; (bogus-comments) ;;; (computing-bogus) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "cat-file" "commit" "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd")) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "rev-parse" #f)) In tekuti/index.scm: 113:28 10 (_) In tekuti/util.scm: 187:5 9 (with-time-debugging* #tekuti/index.s…>) In srfi/srfi-1.scm: 466:18 8 (fold #(spec i…> …) In tekuti/index.scm: 58:25 7 (_ _ ((legit-comments . #) (. #) …)) In tekuti/util.scm: 187:5 6 (with-time-debugging* #tekuti/index.s…>) In tekuti/comment.scm: 206:2 5 (compute-bogus-comments _ _) In tekuti/git.scm: 339:16 4 (fold-commits #tekuti/comment.scm:20…> …) 174:24 3 (git-rev-parse #f) 92:15 2 (run _ _ _) In ice-9/popen.scm: 64:22 1 (open-pipe* "r" _ . _) In unknown file: 0 (open-process "r" "git" "--bare" "rev-parse" #f) ERROR: Wrong type (expecting string): #f ;;; (stop-clock 0.057827999) ;;; (stop-clock 0.069815999) ;;; (handler ()) ;;; (start-clock) ;;; (start-clock) ;;; (posts) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "ls-tree" "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd" ".")) ;;; (stop-clock 0.026757) ;;; (start-clock) ;;; (posts-by-date) ;;; (stop-clock 3.6e-5) ;;; (start-clock) ;;; (tags) ;;; (latest-posts ((posts-by-date) (posts . #0/31>) (master . "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd"))) ;;; (filter-mapn ()) ;;; (stop-clock 3.59e-4) ;;; (start-clock) ;;; (legit-comments) ;;; (computing-legit) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare" "ls-tree" "7e5d0ddb26c73c0602e8fdf24c1fd90eb9e35efd" ".")) ;;; (done #) ;;; (stop-clock 0.006625) ;;; (start-clock) ;;; (bogus-comments) ;;; (computing-bogus) ;;; (pwd "/home/neil/blog.git") ;;; (run (() #f "git" "--bare"
Re: [ANN] guile-sdl2 0.2.0 released
> Home page: https://dthompson.us/pages/software/guile-sdl2.html I get 404 for that URL, and also if I add 'www.'.
Re: Missing (ice-9 debugging) files in guile 2.1.4?
On 11/10/16 17:41, Cecil McGregor wrote: I am running guile 2.1.4 and have noticed the missing ice-9/debugging dirs. I will copy the files from 1.8 and hope they work well enough. Is this intentional, or just delayed? Hi Cecil, It's intentional; in the transition from 1.8 to 2.x, the innards of Guile changed so much as to invalidate the (ice-9 debugging) stuff. I'm out of the loop now, so not sure how best to do the things that (ice-9 debugging) used to do; but at least one of the ingredients is the excellent geiser.el mode for Emacs. Neil
Re: Presentation of traversi framework via graph recommendations
I got lost at the point of looking up the genres for Toy Story; why does that involve graph traversal? Probably it would help to add a bit into the blog to explain how the movie information is mapped into a graph. Original Message From: Amirouche Boubekki Sent: Friday, 9 September 2016 07:32 To: Guile User Subject: Presentation of traversi framework via graph recommendations Héllo, I published an article on my blog about how to use `grf3` the graph database library built on top of wiredtiger [0]. [0] http://hyperdev.fr/notes/a-graph-based-movie-recommender-engine-using-guile-scheme.html This introduce traversi framework to do graph traversal. traversi is inspired from Tinkerpop's Gremlin. Traversi is a custom stream library which is faster than srfi-41 and support backtracking. I think that building traversi on top of streams make graph traversal much more approachable. This article is inspired from a *graph-based recommender engine* [1] [1] https://markorodriguez.com/2011/09/22/a-graph-based-movie-recommender-engine/ Have fun!
Re: Presentation of traversi framework via graph recommendations
Your blog includes: Mind the fact that -ref procedures have no ! at the end which means they return a new record. I think that should be -set instead of -ref Neil Original Message From: Amirouche Boubekki Sent: Friday, 9 September 2016 07:32 To: Guile User Subject: Presentation of traversi framework via graph recommendations Héllo, I published an article on my blog about how to use `grf3` the graph database library built on top of wiredtiger [0]. [0] http://hyperdev.fr/notes/a-graph-based-movie-recommender-engine-using-guile-scheme.html This introduce traversi framework to do graph traversal. traversi is inspired from Tinkerpop's Gremlin. Traversi is a custom stream library which is faster than srfi-41 and support backtracking. I think that building traversi on top of streams make graph traversal much more approachable. This article is inspired from a *graph-based recommender engine* [1] [1] https://markorodriguez.com/2011/09/22/a-graph-based-movie-recommender-engine/ Have fun!
Re: Using . in module names
On 03/06/16 08:57, Christopher Baines wrote: From reading the documentation, I would expect this to work, as . is valid in symbols? But from trying this out, it does not seem to (the module cannot be loaded). Does anyone have information about this? I think you should provide the complete example of what isn't working. It's not clear to me if you mean (define-module (.) ...) or (define-module (.something) ...) or (define-module (something . else) ...) etc. Regards, Neil
Re: Using libnotify from Guile
On 05/01/16 09:40, Ludovic Courtès wrote: Neil Jerram <neil.jer...@metaswitch.com> skribis: I noticed you asked about libnotify on IRC Also note that glibc built for the Linux kernel provides wrappers for a bunch of inotify syscalls in : --8<---cut here---start->8--- $ objdump -T .guix-profile/lib/libc.so.6 | grep inotify 000e9cc0 gDF .text 0021 GLIBC_2.9 inotify_init1 000e9cf0 gDF .text 0021 GLIBC_2.4 inotify_rm_watch 000e9c90 gDF .text 0021 GLIBC_2.4 inotify_init 000e9c60 gDF .text 0021 GLIBC_2.4 inotify_add_watch --8<---cut here---end--->8--- So you could avoid libnotify altogether with things like: (dynamic-func "inotify_init" (dynamic-link)) Ludo’. But isn't inotify (a Linux kernel subsystem for noticing changes to the filesystem) unrelated to libnotify (a thing for popping up a notification message on the desktop)?
Using libnotify from Guile
Hi Luis, I noticed you asked about libnotify on IRC; unfortunately I wasn't quick enough before you left the channel, but I had a quick play and found that it was quite easy to generate a notification using the FFI: (use-modules (system foreign)) (define libnotify (dynamic-link "libnotify")) (define notify-init (pointer->procedure int (dynamic-func "notify_init" libnotify) (list '*))) (notify-init (string->pointer "notify.scm")) (define notify-notification-new (pointer->procedure '* (dynamic-func "notify_notification_new" libnotify) (list '* ; summary '* ; body '* ; icon ))) (define notify-notification-show (pointer->procedure int (dynamic-func "notify_notification_show" libnotify) (list '* ; notification '* ; ))) (notify-notification-show (notify-notification-new (string->pointer "Hello!") (string->pointer "Pleased to meet you") %null-pointer) %null-pointer) I thought you might like that; note that you'll also need "aptitude install libnotify-dev", or your system's equivalent. Regards, Neil
Re: FOSDEM call for Guile related talks
Hi Ludo, On 19/11/15 14:25, Ludovic Courtès wrote: "Neil Jerram" <n...@ossau.homelinux.net> skribis: Pjotr, I've made my submission now - please could you check if it looks correctly done? (I've never done a FOSDEM submission before...) I can confirm it’s in penta.fosdem.org, but I think you need to fill out the “Abstract” and “Description” boxes to placate it. Could you look into it? Thanks for checking. For now I've just done a straight copy of what I've already written, into the "Abstract" and "Full Description" boxes. Will that do for now? I will improve this as we get closer to the event, but would rather not spend more cycles on it right at the moment. Regards, Neil
RE: FOSDEM call for Guile related talks
Thanks, Alex and Ludo! Pjotr, I've made my submission now - please could you check if it looks correctly done? (I've never done a FOSDEM submission before...) Thanks, Neil -Original Message- From: guile-user-bounces+neil=ossau.homelinux@gnu.org [mailto:guile-user-bounces+neil=ossau.homelinux@gnu.org] On Behalf Of Ludovic "Courtès" Sent: 06 November 2015 18:11 To: guile-user@gnu.org Subject: Re: FOSDEM call for Guile related talks Alex Sassmannshausenskribis: > From my perspective I think that sounds super interesting — I would > say if you can confirm that you're going to be there, then you should > definitely submit a proposal; the worst that would happen is that we > have too many proposals — and that would really be more of a luxury > problem :-) Seconded. And it would be great to meet there, Neil! :-) Ludo’.
Re: How to create hygienic environments?
Michael Tiedtke michele.ti...@o2online.de writes: Just to quote myself: The (null-environment 5) gives me an empty environment but how should I insert the editor commands? Just think of these editor commands as regular Scheme definitions. I think you're looking for 'module-define!': scheme@(guile-user) (define n (null-environment 5)) scheme@(guile-user) (eval 'car n) ERROR: In procedure memoize-variable-access!: ERROR: Unbound variable: car Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(#{ g3900}#) [1] ,q scheme@(guile-user) (eval 'car (current-module)) $2 = #procedure car (_) scheme@(guile-user) (module-define! n 'car car) scheme@(guile-user) (eval 'car n) $3 = #procedure car (_) Hope that helps! Neil
Re: Imagemagick and Guile
On 2015-01-11 09:09, A0 wrote: I need to generate an image from raw byte data in my code and ImageMagick seems like an obvious choice to do this. But, looking at http://www.imagemagick.org/script/api.php , I see no Guile API listed. Before I get my hands dirty, I'd like to check if someone already built a functional API for Guile, or, at least, the chunk of it containing the PixelIterator functionality. I am also interested in hearing about other Guile-enabled libs that can do the same thing, namely, creating an image in some of the popular formats. In addition to the other suggestions that people have made, note that you could also use the Guile FFI to access ImageMagick's C API from Guile. Personally, I find using the FFI much more fun than writing a 'proper' Guile binding. Regards, Neil
Re: guile-2.0.11 installation on system with 2.0.5
On 2014-09-15 02:16, m...@netris.org wrote: Federico Beffa be...@ieee.org writes: Neil Jerram n...@ossau.homelinux.net writes: This is just a guess, but what happens if you do this: $ LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/guile Regards, Neil With this it works! I notice that there is an /etc/ld.so.cache file. Do I somehow need to update it? Yes, you update it by running ldconfig as root. This needs to be done when installing libraries outside of your package manager, not only for Guile, but for essentially all packages containing libraries. I agree that this will allow /usr/local/bin/guile to load /usr/local/lib/libguile*. However, won't it also cause /usr/bin/guile (2.0.5) to load /usr/local/lib/libguile* (2.0.11) ? If not, what is the mechanism that tells /usr/bin/guile (2.0.5) to load /usr/lib/libguile* (2.0.5) instead of /usr/local/lib/libguile* (2.0.11) ? Thanks, Neil
Re: A couple of questions about goops method parameters
Taylan Ulrich Bayirli/Kammer taylanbayi...@gmail.com writes: Panicz Maciej Godek godek.mac...@gmail.com writes: [...] it's hard for me to see the advantage of FRP over OOP in practical systems (e.g. windowed applications with buttons and so on). [...] An off-topic remark: I don't know about *functional* reactive programming but from my experience so far as an iOS developer, I've been *longing* for a reactive programming system that automates state changes even if not fully hiding them. It would be invaluable being able to say button2.leftEdge = button1.rightEdge + 20px and have this equation be held automatically on changes to the layout of button1 (which might happen because it itself reacts to other layout changes), or to be able to say button.disabled = condition1 or condition2 and have the disabled status of button update automatically as the truthiness of the conditions changes. (The former use-case is actually covered by layout constraints, but that's strictly limited to layouting.) IIRC, Metafont does that; but obviously it isn't intended as a general language. Are there more general languages that solve equations like this? Regards, Neil
Re: cannot compile: srfi-10 define-reader-ctor 'hash '#,(
On 2014-08-14 11:27, Taylan Ulrich Bayirli/Kammer wrote: Neil Jerram n...@ossau.homelinux.net writes: I wonder about possibly having some magic that would automatically match certain top-level forms and evaluate them at compile time. The case for this for 'define-reader-ctor' feels quite strong. For the load path case, it feels too hacky to try to recognize patterns like (set! %load-path (append %load-path ...))', but perhaps OK if we defined an 'add-to-load-path' procedure and applied the magic to that. We already have an 'add-to-load-path' syntax. That way it doesn't need any special magic since it can just expand to an `eval-when' usage Ah, good, thanks for pointing that out. but apparently for some reason it doesn't do that at the moment (2.0.11): scheme@(guile-user) ,expand (add-to-load-path foo) (set! (@@ (guile) %load-path) ((@@ (guile) cons) foo (@@ (guile) %load-path))) Taylan I'm not sure what that demonstrates. add-to-load-path _does_ appear to work for me as hoped (and documented) when used in a situation like that of the recent ossaulib thread - i.e. where a top level script wants to extend the load path and then load modules from there: ---ctest.scm (define-module (ctest) #:export (square)) (define (square x) (* x x)) ---ctest.scm ---ctst.scm (add-to-load-path /home/neil) (use-modules (ctest)) (display (square 5)) (newline) ---ctst.scm neil@nj-debian-7:~$ guile -s ctst.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/neil/ctst.scm ;;; compiling /home/neil/ctest.scm ;;; compiled /home/neil/.cache/guile/ccache/2.0-LE-8-2.0/home/neil/ctest.scm.go ;;; compiled /home/neil/.cache/guile/ccache/2.0-LE-8-2.0/home/neil/ctst.scm.go 25 Regards, Neil
Re: cannot compile: srfi-10 define-reader-ctor 'hash '#,(
On 2014-07-30 23:27, Jan Nieuwenhuizen wrote: Ludovic Courtès writes: Hi, In this example, you want the reader extension to be available at compile time, and not necessarily at run time. However, by writing the code as is, the reader extension is available only at run time, hence the error. Alright, that makes sense when you think about it... To require evaluation of the ‘define-reader-ctor’ form at compile time, change the code to (info (guile) Eval When): Wow, many thanks! This works for me; would it be nice to have some of this more explicitly in the srfi-10 manual? This same problem just came up in another thread, too (look for ossaulib). In that case the thing that needed to be enclosed in an 'eval-when' form was adding a directory to the load path. I wonder about possibly having some magic that would automatically match certain top-level forms and evaluate them at compile time. The case for this for 'define-reader-ctor' feels quite strong. For the load path case, it feels too hacky to try to recognize patterns like '(set! %load-path (append %load-path ...))', but perhaps OK if we defined an 'add-to-load-path' procedure and applied the magic to that. What do you think? Would that be too magical? Regards, Neil
Re: ossaulib dbus error
On 2014-07-24 15:33, Max wrote: When I set GUILE_WARN_DEPRECATED to detailed I got warning that Eval closures are deprecated. Is this related to eval-when workaround? If so - what would be relevant solution? No, I don't think this is related to eval-when. I believe an eval closure is what guile-gnome uses to lazily bind Scheme procedure names to the relevant underlying C code. Perhaps David Pirotte might comment more on that, as he is working a lot with guile-gnome now. Regards, Neil
Re: ossaulib dbus error
On 2014-07-22 19:46, Max wrote: 22.07.2014 19:05, Neil Jerram пишет: On 2014-07-22 17:39, Max wrote: OK, sorry to take your time on that attempt. What if you do guile --debug test.scm where test.scm has just the load-path appending and (use-modules (glib dbus)) ? If that still doesn't work, then clearly this is nothing to do with guile-gnome. Sure thing - this is my test file: (set! %load-path (append %load-path '(/home/lol/source/lisp/ossaulib/))) (use-modules (neil dbus)) Here is the compilation results: guile-gnome-2 --debug dbus-test.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/lol/source/lisp/dbus-test.scm ;;; WARNING: compilation of /home/lol/source/lisp/dbus-test.scm failed: ;;; ERROR: no code for module (neil dbus) Changing neil to glib only changes the name in the error message above. I'd appreciate any hints with debugging. Do you have some small test application I can use? Just remembered / worked this out. The problem is that %load-path isn't extended when dbus-test.scm is being compiled, and the solution for that is to use 'eval-when'. Here's my test script, showing the use of eval-when: (eval-when (expand load eval) (set! %load-path (append %load-path '(/home/neil/ossaulib (use-modules (glib dbus)) Regards, Neil
Re: ossaulib dbus error
On 2014-07-22 17:00, Max wrote: Hi. I'm trying to use dbus from ossaulib (as far as I recall it's the only dbus library for guile which is still alive) but got errors from the very beginning: _ (set! %load-path (append %load-path '(/home/lol/source/ossaulib/))) (use-modules (oop goops) (gnome gobject) (gnome glib) (gnome gtk) (glib dbus) (os process) (gnome gobject utils)) _ guile-gnome-2 dbus-test.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/god/source/lisp/dbus-test.scm ;;; WARNING: compilation of /home/god/source/lisp/dbus-test.scm failed: ;;; ERROR: no code for module (glib dbus) Any ideas why guile does not see it? I've checked ossaulib/ and glib/dbus.scm is right there. You're clearly also using guile-gnome. I wonder if there's also a (glib ...) hierarchy provided by guile-gnome, and if that might be conflicting with the (glib ...) modules in ossaulib? You could try renaming the glib directory in ossaulib to something else, and correspondingly replacing (glib ...) throughout the ossaulib source. If there is a conflict with guile-gnome, that should avoid it. Regards, Neil
Re: ossaulib dbus error
On 2014-07-22 17:39, Max wrote: I've copied glib/ to neil/, replaced all the instances of glib with neil (except for libglib of course :) and tried to use (neil dbus) but the result is exactly the same - ERROR: no code for module (neil dbus) OK, sorry to take your time on that attempt. What if you do guile --debug test.scm where test.scm has just the load-path appending and (use-modules (glib dbus)) ? If that still doesn't work, then clearly this is nothing to do with guile-gnome. Could it be that one or more of the calls like (dynamic-link libgio-2.0) are failing? These are executed during module loading, and I think could cause the no code error if they throw an exception. To allow these calls to succeed, you need to have installed the -dev or -devel package that provides name.so; e.g. the libglib2.0-dev package (on Debian) for libgio-2.0.so. Can you try it on your machine alongside with guile-gnome? I can try that later this evening. Right now I'm afraid I'm not at the right computer for that. Regards, Neil
Re: Learning Guile web. Stuck on returning an image.
Martyn Smith martyn.develo...@googlemail.com writes: Getting to the point of the email -- I am a bit confused how I would return a jpg image. For example: - img src=/load-image?id=1234 / The 1234 tells me which file to load and return. Being primarily a .NET developer, I am struggling to understand how to achieve such goal in guile. I have tried things like (read-file /location/to/ image.jpg r) but no luck. Also tried to understand converting to bytes in the documentation but again... no luck. Always getting a 500 error. Yes, I have included (content-type . (image/jpg)) etc. Can anyone give me a heads up on how to do such thing? How would I open the jpg file? How would it be returned? I recently had the same problem, and eventually decided that it would be better to use Guile only for my dynamic content, with a standard web server for the static content. For the latter I chose lighttpd, and I can provide more details of my setup if that would be helpful. But what specifically was the problem? My handler for an image file (and other static content) looked like this: (lambda (request request-body uri) (let* ((fn (apply string-append static-root (map (lambda (name) (string-append / name)) uri))) (content (with-input-from-file fn read-string)) (content-type (cond ((string-match \\.svg fn) '(image/svg+xml)) ((string-match \\.html? fn) '(text/html)) ((string-match \\.jpe?g fn) '(image/jpeg)) ((string-match \\.png fn) '(image/png)) ((string-match \\.css fn) '(text/css)) ((string-match \\.js fn) '(application/javascript)) (else '(text/plain) (trc 'content-type content-type 'length (string-length content)) (values `((content-type . ,content-type)) content))) The problem here that 'content' contains binary data that can't be returned as is in an HTTP response. It needs to be encoded in one of the HTTP-supported encodings, and a corresponding Content-Encoding header added to the response. I think I investigated a little whether Guile's (web ...) modules could do this, or could easily be enhanced, but decided instead on the solution described above. Regards, Neil
Re: dbus introspection
Max maxim.sur...@campus.tu-berlin.de writes: Hi all. Are there some dbus bindings available for guile? I have some FFI-based client-side bindings in my library at http://git.savannah.gnu.org/cgit/ossaulib.git/. The (glib dbus) module exports procedures for - making a synchronous or asynchronous dbus call - registering a Scheme procedure to be called when a dbus signal occurs. (ofono modem) is a library module that uses those dbus- procedures, and I hope is simple enough to make the usage clear. Tried to search but found some ancient code only :( What was that? I know that guile-gnome used to have a dbus module, and possibly still does. Also is there some tool similar to vala-dbus-binding-tool which could connect to a given dbus service and using introspection generate guile stub code for functions/signals available for interaction with this service? Not that I know of. Should be quite easy to build on top of my client-side bindings, though. (Or on top of any set of client-side bindings.) Regards, Neil
Re: #:getter procedure returns unexpected value in GOOPS
Diogo F. S. Ramos d...@riseup.net writes: When using GOOPS, if a class has a second slot, the #:getter procedure of the first slot returns the value of the second slot when applied to an instance of a subclass. (use-modules (oop goops)) (define-class foo () (a #:init-form 'foo #:getter foo-a) (b #:init-form 42)) (define-class bar (foo) (a #:init-form 'bar)) (foo-a (make foo)) = foo (foo-a (make bar)) = 42 I expected: (foo-a (make bar)) = bar I'm not too familiar with GOOPS, so I'm not sure this is the right behavior. Do you see this if you use #:init-value instead of #:init-form ? It sounds to me like #:init-value is what you really want, and I suspect you're seeing undefined behaviour that arises from giving an unparenthesized form ('42') to #:init-form. Neil
WebSockets
Hi there, I'm interested in adding support for WebSockets (http://tools.ietf.org/html/rfc6455) to Guile's web modules. Is anyone else interested in - or possibly already working on - that? Thanks, Neil
Re: WebSockets
[Now guile-user only, since that seems appropriate] On 2014-04-02 11:08, Nala Ginrut wrote: On Wed, 2014-04-02 at 10:29 +0100, Neil Jerram wrote: Hi there, I'm interested in adding support for WebSockets (http://tools.ietf.org/html/rfc6455) to Guile's web modules. Is anyone else interested in - or possibly already working on - that? I was planing to implement websocket in Artanis web-framework and there's half-baked code. Then I realized it's better to integrate with the server, but Artanis hasn't written its own server. So it's appreciated if anyone can do the job. ;-) Wow, Artanis looks quite sophisticated and I'm wondering now if I should use it for my work instead of (web ...) directly. I need to take a closer look. One immediate thing that I noticed: some of its API is different from (web ...) but not obviously better or at a different conceptual level. For example, your route context seems conceptually equivalent to (web request). Is this just because you first wrote Artanis before (web ...) was available? Regards, Neil
'or' and multiple values
Hi there! In the following, is the last result a bug? GNU Guile 2.0.9-deb+1-1 Copyright (C) 1995-2013 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user) (values 'a 'b) $1 = a $2 = b scheme@(guile-user) (or (values 'a 'b)) $3 = a $4 = b scheme@(guile-user) (or #f (values 'a 'b)) $5 = a $6 = b scheme@(guile-user) (or (values 'a 'b) (values 'c 'd)) $7 = a In other words it seems 'or' doesn't propagate multiple values in a non-tail position. Is that expected? The manual section 'Returning and Accepting Multiple Values' does mention tail position, but only in passing, and it isn't obvious to me why that restriction should exist. Thanks, Neil
Re: ‘with-exception-handler’ rationale
On 2014-03-07 13:34, Nikita Karetnikov wrote: I’ve expected ‘with-exception-handler’ to behave like ‘catch’, but it doesn’t. scheme@(guile-user) ,use (srfi srfi-34) scheme@(guile-user) (with-exception-handler (const got it) (lambda () (raise boom!))) ice-9/boot-9.scm:106:20: In procedure #procedure 94b0e40 at ice-9/boot-9.scm:97:6 (thrown-k . args): ice-9/boot-9.scm:106:20: Throw to key `srfi-34' with args `(boom!)'. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1] scheme@(guile-user) (catch 'misc-error (lambda () (error boom!)) (const got it)) $1 = got it Is there an explanation that doesn’t involve diving into the land of continuations and dynamic wind? Yes: the HANDLER that you specify in '(catch TAG THUNK HANDLER)' is implicitly extended, by Guile, by a non-local jump to the continuation of the '(catch ...)'. The HANDLER that you specify in '(with-exception-handler HANDLER THUNK)' isn't. So, to get catch-like behaviour you'd need to write something like this: (call/cc (lambda (k) (with-exception-handler (lambda (e) (k got it)) (lambda () (raise boom!) i.e. explicitly call the escape continuation in your handler code. Why? I think, simply because: - the catch behaviour is traditional for catch/throw in Lisp and Scheme - the with-exception-handler is what SRFI-34 specifies. Alternatively you can use SRFI-34's 'guard' form, which encapsulates a pattern like that. Hope that helps, Neil
Re: Guile, Emacs, and smartphones
Mike Gran spk...@yahoo.com writes: Hi- So, it is time for me to buy a new phone. Has anyone run Emacs or Guile on their phone? I've run Emacs and Guile 1.8 on my Freerunner. No success with Guile 2.0 yet. (Although I've hardly devoted much time yet to that; I hope to do so soonish.) (Somehow I doubt there is a phone keyboard that'll let me type Shift+Alt). The Freerunner SHR terminal (on-screen) keyboard does; also matchbox-keyboard. It isn't exactly easy, though, given how small the keys are, and close to the bevel that surrounds the screen. Regards, Neil
Re: Serving files with guile web server
ro...@lavabit.com writes: So far I have been able to serve text files and images, it should work with any mime-type now, but I have not test it yet. Here is the piece of code that handles files for the curious: (let ((file-path (public-file-path path))) (if (file-exists? file-path) (let* ((mime-type (mime-type-ref file-path)) (mime-type-symbol (mime-type-symbol mime-type))) (if (text-mime-type? mime-type) (values `((content-type . (,mime-type-symbol))) (lambda (out-port) (call-with-input-file file-path (lambda (in-port) (display (read-delimited in-port) out-port) (values `((content-type . (,mime-type-symbol))) (call-with-input-file file-path (lambda (in-port) (get-bytevector-all in-port)) (not-found request))) I hope it's readable :-) Certainly, it looks good. Where does mime-type-ref come from, though? Perhaps that could be wrapped up as `static-file-response' (or a better name if you can think of one) and added to (web server). Regards, Neil
Re: Serving files with guile web server
ro...@lavabit.com writes: I gave a second read to the manual and found: The handler should return two values: the response, as a response record from (web response), and the response body as a string, bytevector, or #f if not present. If this is correct then I guess I should check the file type first and then read the file to either create a string or a bytevector from it. Any recommendation will be highly appreciated. Well, I suppose I'd recommend considering not using the Guile server to serve static files. Using Guile makes more sense when you want to generate dynamic content, because then you're really using the capabilities of the language. In my web server experiments so far I've used Apache, modlisp and Guile together, and this combination seems to work well. Then Apache can handle all the static content (I guess using the efficient sendfile) without bothering modlisp or Guile, but dynamic stuff can be routed via modlisp to Guile. Regards, Neil
Re: regex-split for Guile
William James w_a_x_...@yahoo.com writes: (define (regex-split regexp str . options) Thanks for posting that! For fun/interest, here's an alternative implementation that occurred to me. Neil (use-modules (ice-9 regex) (ice-9 string-fun)) (define (regex-split regex str . opts) (let* ((unique-char #\@) (unique-char-string (string unique-char))) (let ((splits (separate-fields-discarding-char unique-char (regexp-substitute/global #f regex str 'pre unique-char-string 0 unique-char-string 'post) list))) (cond ((memq 'keep opts) splits) (else (let ((non-matches (map (lambda (i) (list-ref splits (* i 2))) (iota (floor (/ (1+ (length splits)) 2)) (if (memq 'trim opts) (filter (lambda (s) (not (zero? (string-length s non-matches) non-matches)))
Re: Is there any approach to define private vars in GOOPS?
nalaginrut nalagin...@gmail.com writes: hi all! I got a question. Is there any approach to define a private vars/methods in the GOOPS? Or it's impossible? I didn't find any private info in the GOOPS manual. Hi there! In Guile, the visibility of identifiers - including any functions you've defined to get and set GOOPS slots - is controlled by the module system, and is completely orthogonal to anything specific to GOOPS. However, the module system can't prevent any code from doing (slot-ref obj 'some-slot-that-should-be-private) once it has OBJ, and knows that OBJ has a slot named some-slot-that-should-be-private. (In effect because slot names live in a different namespace from that of identifiers, and which isn't connected to the module system.) If you can determine at runtime whether or not any given slot access is allowed - perhaps based on (current-module) - it should be possible to enforce this by defining a new kind of slot #:allocation and putting that runtime check in the #:slot-ref function. Regards, Neil
Re: GNU Guile 1.9.15 released — last call before 2.0!
l...@gnu.org (Ludovic Courtès) writes: We are pleased to announce GNU Guile release 1.9.15. This is the last pre-release before the 2.0 release, due on Feb. 16th! Wow, excellent job, and exciting times. Well done to everyone involved! Neil
Re: Modules
Andy Wingo wi...@pobox.com writes: I would also mention the approach from the skeleton package, which you can fetch from http://wingolog.org/git/skeleton.git. `autoreconf -vif', `./configure', and `make'. It has a toplevel `env' script, similar to other environment scripts needed for other languages that tweak LD_LIBRARY_PATH. Thanks. It seems a shame, and less portable, for us to rely on shell script wrappers. But given that we're talking about uninstalled stuff, and that it seems extremely unlikely for a development machine not to have a decent shell, I guess that's actually OK. Neil
Re: Modules
Marek Kubica ma...@xivilization.net writes: What about the same directory that the file is in? The point is, when writing scripts that become larger than one file, splitting them into modules becomes immensely painful because the modules cannot find each other. I agree that this is a bit awkward. My current solution is (load setup-load-path.scm) at the start of each top-level script - which relies on the fact that `load' will look in the same directory as the script file - with setup-load-path.scm containing: (cond-expand (guile-2 (eval-when (load compile) (let* ((bindir (dirname (car (command-line (absdir (cond ((string=? bindir .) (getcwd)) ((string-match ^/ bindir) bindir) (else (in-vicinity (getcwd) bindir) (set! %load-path (cons (in-vicinity absdir ..) %load-path) (else (let* ((bindir (dirname (car (command-line (absdir (cond ((string=? bindir .) (getcwd)) ((string-match ^/ bindir) bindir) (else (in-vicinity (getcwd) bindir) (set! %load-path (cons (in-vicinity absdir ..) %load-path) This has the effect of adding the parent of the script-containing directory to the load path. Part of the complexity is supporting both 1.8 and 1.9/2.0. For 1.9/2.0 support only, I believe it could be simplified by changing `load' to `include', and retaining only the body of the `eval-when'. Regards, Neil
Re: Modules
Neil Jerram n...@ossau.uklinux.net writes: Marek Kubica ma...@xivilization.net writes: What about the same directory that the file is in? The point is, when writing scripts that become larger than one file, splitting them into modules becomes immensely painful because the modules cannot find each other. I agree that this is a bit awkward. My current solution is (load setup-load-path.scm) at the start of each top-level script - which relies on the fact that `load' will look in the same directory as the script file - with setup-load-path.scm containing: (cond-expand (guile-2 (eval-when (load compile) It's amazing how writing an email sets you thinking about whether something is really correct... In fact I think the top level probably needs to be (cond-expand (guile-2 (include setup-load-path.scm)) (else (load setup-load-path.scm))) so that the path is set up for 1.9/2.0 compilation time. I wonder if it works to write that as ((cond-expand (guile-2 include) (else load)) setup-load-path.scm) And then setup-load-path.scm can be just (let* ((bindir (dirname (car (command-line (absdir (cond ((string=? bindir .) (getcwd)) ((string-match ^/ bindir) bindir) (else (in-vicinity (getcwd) bindir) (set! %load-path (cons (in-vicinity absdir ..) %load-path))) Which isn't so bad.
Re: Modules
Andy Wingo wi...@pobox.com writes: Hi Marek, On Sat 29 Jan 2011 13:13, Marek Kubica ma...@xivilization.net writes: What about the same directory that the file is in? The point is, when writing scripts that become larger than one file, splitting them into modules becomes immensely painful because the modules cannot find each other. For what purpose? If you are using modules, they are already in one global namespace, the various roots of which are in the %load-path and/or %load-compiled-path. (resolve-module '(foo bar)) should work regardless of what file calls it. If the modules are installed, that's true. What if they are not? Even if all of the non-installed modules are in a single tree, things are a bit fiddly. For work from a REPL or from Geiser, you can put (set! %load-path (cons whatever %load-path)) in ~/.guile, and (load (in-vicinity (getenv HOME) .guile)) in ~/.guile-geiser, but this doesn't do the job for scripts that want to use those modules. (Because scripts do not load ~/.guile.) For scripts that use uninstalled modules, then, some kind of solution is needed; ideally one that works for both 1.8 and 1.9/2.0, allows the code needed to live in a single common file, rather than duplicated at the top of each script; and continues to work if the script+module tree as a whole is moved to a different place in the filesystem. Also I think it's preferable if the solution is a Guile one, as opposed to based on the #! line, or needing a shell script wrapper. Perhaps you are interested in `load', which is problematic regarding compiled files; for example when loading from a compiled file, how will `load' know what is the current directory? Note that .go files are installed to e.g. /usr/lib64/guile, while source is in /usr/share/guile. Good point, thanks for the reminder about that. But (for 1.9/2.0) `include' will always be well-defined and reliably relative to the containing file's name, won't it? Regards, Neil
Re: Macro expansion
Hans Aberg haber...@telia.com writes: In the code below the 'loop' and 'begin' examples will execute the while' loop, but if put into the body of a function, 'while' will not run. So why, and how to fix it? Just copy and paste the examples below into guile. For the two first, I get 0123456789 0123456789done!3 but for the third, the thunk, only done!3 With my current Guile, scheme@(guile-user) (version) $4 = 1.9.14.17-44f43 the third case behaves as you would expect: scheme@(guile-user) ((lambda () (begin (loop ((define i 0)) ( i 10) ((set! i (+ i 1))) ((display i))) (display done!) (+ 1 2) ) )) 0123456789done!$5 = 3 Regards, Neil
Re: inconsistency between let and lambda
Joo ChurlSoo init...@gmail.com writes: The following behavior of `let' seems to be wrong. guile (version) 1.8.8 guile (let ((go #f) (alist '())) (let ((a 1) (b (call-with-current-continuation (lambda (x) (set! go x) 2 (set! alist (cons (cons a b) alist)) (set! a 100) (set! alist (cons (cons a b) alist)) (if ( (length alist) 3) (go 2) (reverse alist ((1 . 2) (100 . 2) (100 . 2) (100 . 2)) guile;; inconsistency between let and lambda (let ((go #f) (alist '())) ((lambda (a b) (set! alist (cons (cons a b) alist)) (set! a 100) (set! alist (cons (cons a b) alist)) (if ( (length alist) 3) (go 2) (reverse alist))) 1 (call-with-current-continuation (lambda (x) (set! go x) 2 ((1 . 2) (100 . 2) (1 . 2) (100 . 2)) guile For what it's worth, my current Guile, from Git post 1.9.14, gives ((1 . 2) (100 . 2) (1 . 2) (100 . 2)) for both cases. Neil
Re: How to change prompt and value-history in guile 1.9.14 init file ~/.guile
Fu gangqiang lis...@163.com writes: Hi, all guile 1.9.14 default prompt is 'scheme @(guile-user)' and value-history is #t, I can change them using commands ' ,o prompt guile' and ',o value-history #f' but how to change them in ~/.guile file According to the `Value History' section in the manual: -- Scheme Procedure: disable-value-history! Turn off value history, if it was on. And, not documented (and not tested by me), but found by a bit of code grepping: from (system repl common): (define (repl-default-prompt-set! prompt) (repl-default-option-set! 'prompt prompt)) Regards, Neil
Re: FW: ERROR: file: libguilereadline-v-17, message: The specified module could not be found
Whitlock, Bradley D bradley.d.whitl...@lmco.com writes: I built readline-6.1 and gmp-4.3.2 under MinGW on XP and I have guile up and running but I cannot get readline module to load: ERROR: In procedure dynamic-link: ERROR: file: libguilereadline-v-17, message: The specified module could not be found. Is there a configuration knob that needs to be tweaked to tell guile where to find this file? On Linux I think you'd need either export LD_LIBRARY_PATH=/usr/local/lib, or to run sudo ldconfig after installing Guile. I'm afraid I don't know what that equates to on MinGW. Neil
Re: Backquote simplification
Hi Hans, To reply quickly to one point in your email... (I'll ponder the rest later.) Hans Aberg haber...@telia.com writes: On 11 Dec 2010, at 01:25, Neil Jerram wrote: In the hope that these questions might be useful to at least one of us... I do not know what that means. I meant that I'm sure I don't understand yet what you're doing, and hence that the answers might help me; and that there was a possibility that you might not be understanding some things, and that in that case the discussion might help you too. Regards, Neil
Re: Backquote simplification
Hans Aberg haber...@telia.com writes: [Your reply does not seem to be on the list, so I cc it.] Thanks. I might try an iterated cons, that is a function f such such that (f x1 ... xk y) -- (cons x1 ... (cons xk y) ...)) Isn't that just `list'? More generally: I've been reading your emails, but I'm afraid I have no idea what you are trying to do. Perhaps you could step back and explain that overall, before continuing with details. Neil
Re: Backquote simplification
Hans Aberg haber...@telia.com writes: The reply I got was helpful, but I decided to settle for a macro implementation: (use-syntax (ice-9 syncase)) (define-syntax tuple (syntax-rules () ((tuple xs ...) `(tuple ,xs ...)) ((tuple x1 x2 . y) (append `(tuple ,x1 ,x2) y)) ((tuple x1 . y) (append `(tuple ,x1) y)) )) OK, I roughly see that this solves your problem of wanting to unquote an arbitrary number of list elements. (Although I don't understand why you need to do that.) It behaves as I want in my context, a functional language on top of Guile. Scheme is already a functional language, isn't it? I decided to implement the construct (lambda (x_1 ... x_k . y) f) What syntax is that expression in? In Scheme syntax, it's a lambda that returns a value that is apparently unrelated to any of the arguments, and so could equally well be written as (lambda ignored-args f). using an improper list (x_1 ... x_k . y); when it is a proper list, one just gets the fixed number of arguments construct. Then the object (x_1 ... x_k . y) also become available, so it is possible to form (define f (lambda (x_1 ... x_k . y) (x_1 ... x_k . y))) How is this different from (define f (lambda args args)) ? Then one would expect f(a_1, ..., a_n), for n = k, to be (a_1, ..., a_n) - this a form of the identity. So to get this effect, I need a function g that can call improper lists (g x_1, ..., x_k . y), where y is a list. As Dan pointed out, that is not an improper list. It's a proper list. In the hope that these questions might be useful to at least one of us... Neil
Re: new sqlite binding
On 7 December 2010 04:46, Linas Vepstas linasveps...@gmail.com wrote: Would g-wrap work? I remember g-wrap was written about 10 years ago, back when swig didn't work so well, and certainly didn't work well with guile. But I had the impression that g-wrap went defunct. Not sure. (what do I know? for all I know, maybe g-wrap morphed into ffi). As far as I know, g-wrap is still active, and part of the dev chain for guile-gnome. Neil
Re: Trouble building Guile 1.9.13
Peter TB Brett pe...@peter-b.co.uk writes: ERROR: In procedure skip_block_comment: ERROR: /home/peter/src/guile/guile-tools:1:2: unterminated `#! ... !#' comment guile: uncaught throw to wrong-type-arg: (#f Wrong type (expecting ~A): ~S (exact integer (#t #catch-closure a8f5200 #catch-closure a8f51f0 #catch-closure a8f51e0)) ((#t #catch-closure a8f5200 #catch-closure a8f51f0 #catch-closure a8f51e0))) make[3]: *** [guile-procedures.texi] Error 1 Am I missing something? In my tree, guile-tools is in the meta subdirectory, and I don't see where a path of .../guile/guile-tools could come from. Did you git clone into a new directory? Neil
Re: GOOPS:Can I just overload slot-set! under #:virtual and let alone slot-ref ?
Nala Ginrut nalagin...@gmail.com writes: yeah~you hit it precisely! But I'm not sure if I modified the slot-seting call I'm not clear what you mean by that. ,the result is all slot-set! procedure would be effected? No, that's not the case for either of my suggestions. If you invented something like `#:allocation #:custom-setter', it would only apply to slots that had `#:allocation #:custom-setter' in their slot definition. Regards, Neil
Re: new sqlite binding
Andy Wingo wi...@pobox.com writes: But I would like to mention the downside of the dynamic FFI approach: with the static FFI you get typechecking by the C compiler, but with the dynamic FFI you're on your own. Interesting point, thanks. I suppose you could also use the C compiler to at least check that the function type you declared is correct; if you want to do, at runtime, (pointer-procedure int (dynamic-func foo (dynamic-link)) (list int32)) you could at least make a compile-time check that typedef int (*foo_type) (int32 bar); int main (...) { foo_type bar = foo; return 0; } doesn't produce any warnings with -Wall, or something. Hmm, that's almost as annoying as just writing the C code anyway. I guess what we want is to validate Scheme FFI code against the relevant C header file(s). Hopefully something like SWIG or GCC modularisation might give us that in the future. Neil
Re: GOOPS:Can I just overload slot-set! under #:virtual and let alone slot-ref ?
On 2 December 2010 07:06, Nala Ginrut nalagin...@gmail.com wrote: Hi, everybody! I got a question while I'm trying GOOPS, here is some example code pieces: ;;guile code (define-class test () (cache #:init-form 0) (tt #:init-form 1 #:allocation #:virtual #:slot-set! (lambda (o v) (slot-set! o 'cache (cons v (slot-ref o 'cache))) );;end lambda #:slot-ref (lambda (o) #f) ;; ***FIXME: can I use generic slot-ref without re-define here?? .. ;;guile code end --- Please notice the line with ***FIXME .I know that the slot-set! and slot-ref must be re-defined under #:allocation #:virtual, but can I find some approach that just re-define one of them? Maybe I'll need a modified(with overload) slot-set!, but I need a generic slot-ref in some circumstance. I don't know how to do. If I called slot-ref in the re-defination of slot-ref, that would be recursively infinite. How can I deal with this? Any help will be appreciated, thanks! I'm not sure this is what you mean... but yes, your #:slot-ref lambda can do a slot-ref on normal slots, such as cache, e.g.: #:slot-ref (lambda (o) (car (slot-ref o 'cache))) Neil
Re: GOOPS:Can I just overload slot-set! under #:virtual and let alone slot-ref ?
On 3 December 2010 00:52, Nala Ginrut nalagin...@gmail.com wrote: thanks, but my question is something like this: ... (cache ... #:slot-ref (lambda (o) (slot-ref o 'cache)) ...) ;; ERROR ... (sunday ... #:slot-ref (lambda (o) (slot-ref o 'cache)) ...) ;; That's OK I could call (slot-ref o 'cache) in other slot except cache, but what should I do if I need to use (slot-ref o 'cache) in the cache definition? I used it directly and got stack overflow. I think it may cause infinite recursive. Actually my question can be described more explicitly: Can I just re-define slot-ref or slot-set! any one of them but NOT both? Sometimes I may need a re-defined slot-set! but I expect to let alone slot-ref. Anybody catch my mind? Yes, I think so. The thing about #:allocation #:virtual is that there then isn't any storage for that slot name, at all, in instances of the relevant class. So clearly a normal slot-ref can't work. But I think I understand what you want: you don't actually want #:allocation #:virtual, but you do want some kind of customised processing when setting a slot's value; and you don't need to do anything special when reading the value. Is that right? If so, the simplest solution is to define your slot-setting call as something other than plain slot-set!, but which uses slot-set! internally after it has done the custom processing. You could also define a new kind of #:allocation to implement the behaviour you're looking for, and a metaclass for classes that can contain that kind of slots, and write a compute-get-n-set method for that metaclass ... but that's quite a bit more complex. Regards, Neil
Re: Help needed debugging segfault with Guile 1.8.7
Hi Peter, Thanks for providing such a clear explanation of the problem. Here are a few comments. Peter Brett pe...@peter-b.co.uk writes: Sure. libgeda uses direct management of memory, and the structures used in its document object model need to be explicitly deleted when finished with. I decided to use a Guile smob to represent these structures for access from Scheme code, with the pointer to the actual structure in SCM_SMOB_DATA and with the low nibble of SCM_SMOB_FLAGS indicating which type of DOM structure the smob references. This would have been sufficient if Scheme code had only been working with libgeda DOMs created and managed entirely via Scheme code. [...] I think your design is similar to what is outlined in the `Extending Dia' node of the Guile manual. Were you aware of that doc before working out your design? If not, I guess we need to make it more prominent. If yes, I'd appreciate any suggestions you have for how it may be improved. So, where was the bug? When a smob is GC'd, and if the pointer it contains hasn't already been cleared, [...] Now that you've successfully debugged this, is there any general advice that you would offer for how to investigate a free list corruption? I would guess not, as corruption is fundamentally a general thing and has infinite possible causes - but perhaps I'm missing something. I hope that explained things reasonably precisely! Thank you, it certainly did. To conclude, I'll just note that in the Guile 2.0 future we won't have such difficult problems, because of using libgc - which will automatically find active references anywhere in the whole application. (And of course I understand that your code still needs to work with Guile 1.8.x now.) Regards, Neil
Re: libexif binding
Andy Wingo wi...@pobox.com writes: Hey all, I wrote a quick binding to libexif, and threw it up on the tubes. It's here: http://gitorious.org/guile-exif I'm rewriting my web photo gallery from being in python to guile, hence the sqlite and exif hacking. Really cool to see these quick new bindings using the 1.9/2.0 FFI! Neil
Re: new sqlite binding
Linas Vepstas linasveps...@gmail.com writes: Hi, On 25 November 2010 08:12, Andy Wingo wi...@pobox.com wrote: I just hacked up a new binding to sqlite. It works with sqlite3 and Guile 1.9/2.0. Check it out at: http://gitorious.org/guile-sqlite3 I'd like to horn in on Andy's glory by advertising guile-dbi http://home.gna.org/guile-dbi/ which provides a consistent set of bindings to three different systems: Postgres, MySQL and SQLite3 Like Andy, I solicit patches/fixes/extensions. At the moment, I assume guile-dbi involves building C glue code? I like the backend-independence of the DBI interface, and I also like Scheme code that I can just drop in and use without needing to compile any C. So, personally, I'd generally favour merging these two bindings, and evolving the other DBD implementations to use the new FFI. Although probably also keeping the existing glue code implementation, as an alternative to support older Guiles. Regards, Neil
A few patches for guile-www
Hi thi, I've got back to some modlisp hacking, and as part of that have rebased to guile-www-2.28. To get things working, in particular the modlisp support, I had to make a few small changes, so I attach those for your consideration. I think they're all self-evident, but of course please ask if not. (For an example modlisp server and web page script that work with this, see http://git.savannah.gnu.org/cgit/ossaulib.git/tree/scripts/modlisp-server and http://git.savannah.gnu.org/cgit/ossaulib.git/tree/scripts/modlisp-example.) Neil From 35906ccf32c502eb34190960542679ca96c6104a Mon Sep 17 00:00:00 2001 From: Neil Jerram n...@ossau.uklinux.net Date: Thu, 25 Nov 2010 20:11:29 + Subject: [PATCH 1/4] Allow big-dishing-loop to set modlisp-ish reply style --- source/server-utils/big-dishing-loop.scm |5 +++-- source/server-utils/modlisp.scm |9 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/server-utils/big-dishing-loop.scm b/source/server-utils/big-dishing-loop.scm index ee5d4ab..ade4078 100644 --- a/source/server-utils/big-dishing-loop.scm +++ b/source/server-utils/big-dishing-loop.scm @@ -111,7 +111,8 @@ (define http-hgrok (vector read-first-line read-headers - skip-headers)) + skip-headers + #f)) ;; Return a proc @var{dish} that loops serving http requests from a socket. ;; @var{dish} takes one arg @var{ear}, which may be a pre-configured socket, @@ -284,7 +285,7 @@ ;; status box (b (and (number? status-box-size) (make-list status-box-size #f))) - (M (mouthpiece p b)) + (M (mouthpiece p b (vector-ref style 3))) (res (cond ((assq-ref method-handlers method) = (lambda (mh) (call-with-current-continuation diff --git a/source/server-utils/modlisp.scm b/source/server-utils/modlisp.scm index 5bd60fe..9f0ffb0 100644 --- a/source/server-utils/modlisp.scm +++ b/source/server-utils/modlisp.scm @@ -52,14 +52,15 @@ (set-car! rv (string-symbol (car rv))) rv)) -(define modlisp-hgrok (vector read-first-line - read-headers - read-headers)) - (define LF \n) (define modlisp-ish (vector Status\n~A ~A\n LF LF end\n)) +(define modlisp-hgrok (vector read-first-line + read-headers + read-headers + modlisp-ish)) + ;;; modlisp.scm ends here -- 1.7.2.3 From c4ceb9c7ea8d272c2c6e280bca4c07553ee50d5c Mon Sep 17 00:00:00 2001 From: Neil Jerram n...@ossau.uklinux.net Date: Fri, 26 Nov 2010 00:14:00 + Subject: [PATCH 2/4] When running under Guile 1.9/2.0, use (ice-9 curried-definitions) --- source/server-utils/answer.scm |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/source/server-utils/answer.scm b/source/server-utils/answer.scm index 75af9e7..4f1f152 100644 --- a/source/server-utils/answer.scm +++ b/source/server-utils/answer.scm @@ -28,6 +28,8 @@ #:use-module (ice-9 optargs) #:use-module ((ice-9 rw) #:select (write-string/partial))) +(cond-expand (guile-2 (use-modules (ice-9 curried-definitions + (define-macro (+! v n) `(set! ,v (+ ,v ,n))) -- 1.7.2.3 From b5d5e809ad7b245da90920f0186e98f2fdbf1e0a Mon Sep 17 00:00:00 2001 From: Neil Jerram n...@ossau.uklinux.net Date: Fri, 26 Nov 2010 00:14:32 + Subject: [PATCH 3/4] Fix tree-flat-length! so that it returns a value --- source/server-utils/answer.scm |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/source/server-utils/answer.scm b/source/server-utils/answer.scm index 4f1f152..60861fd 100644 --- a/source/server-utils/answer.scm +++ b/source/server-utils/answer.scm @@ -63,7 +63,8 @@ ((flat-length tree)) (else (set! (flat-length tree) (+ (tree-flat-length! (car tree)) - (tree-flat-length! (cdr tree))) + (tree-flat-length! (cdr tree + (flat-length tree ;; Return a new string made from flattening @var{tree}. ;; Set the @code{flat-length} (using @code{tree-flat-length!}) -- 1.7.2.3 From b2de97dbe50c89cc78b8a74a8b2c886e71c94c16 Mon Sep 17 00:00:00 2001 From: Neil Jerram n...@ossau.uklinux.net Date: Fri, 26 Nov 2010 00:15:18 + Subject: [PATCH 4/4] Fix read-headers so that it returns the read headers --- source/server-utils/modlisp.scm |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/server-utils/modlisp.scm b/source/server-utils/modlisp.scm index 9f0ffb0..af30316 100644 --- a/source/server-utils/modlisp.scm +++ b/source/server-utils/modlisp.scm @@ -38,9 +38,10 @@ (let loop ((acc '())) (let ((k (read-line port))) (if (string=? end k
Re: ERROR: Bad define placement
barry stevensson brrstvns...@googlemail.com writes: Can anyone help me please ... i need your help badly. It's always a good idea to CC the list, so that more people can potentially help you. I've added guile-user on CC here. Or at least guide where should i have a look to figure out the mistake... I've attached what I think your code should be, with the defines in the correct place. Can you review (for safety) and then try out my version, to see if it works any better than yours? If it does, you can then look at where our versions are different. FYI, I did a couple of things to get your code into a more conventional form: 1. I replaced several strange characters (ASCII code 160) with spaces. It's possible that these characters were the cause of the problem. If you aren't already, please try using a proper programming editor (such as emacs or vi) to write your code - that should help to avoid introducing such characters. 2. I used emacs's indent-region function to indent the code conventionally. This has no effect on the operation of the code, but makes it easier for me and others to read. Fingers crossed... Neil barry.scm Description: Binary data
Re: ERROR: Bad define placement
barry stevensson brrstvns...@googlemail.com writes: ERROR: In procedure memoization: ERROR: Bad define placement (define (kxmax zvalue2) (- 1 zvalue2)). Just move the `(define (kxmax zvalue2) (- 1 zvalue2))' line so that it comes directly after `(define (kyluw xx zz) (- 1.5 (+ xx zz)))'. Scheme doesn't allow that define where you currently have it - see R5RS section 5.2. (At least, it's 5.2 in the copy of R5RS that comes with Guile; I haven't checked other versions.) Neil
Re: pipe buffering
Aidan Gauland aidal...@no8wireless.co.nz writes: Then I have a sexp for debugging, which shows that `expect' is getting one character at a time from the telnet subprocess, since it only prints out Tmatch, instead of Trying [IP address]... Well, as the manual says: -- Macro: expect clause ... [...] The procedures are called in turn after each character is read from the port, [...] The test is successful if the procedure returns a non-false value. Your lambda returns *unspecified*, which counts as a non-false value. So the whole (expect ...) invocation completes after reading just one character. Neil
Re: Plotting in Guile
Joel James Adamson adams...@email.unc.edu writes: So would I write a C program to handle the IPC between guile and GNUPLOT, and then control it with Scheme? There's no need to use C here. You can generate the data, and pass it to Gnuplot, all in Scheme. For example, see: http://ossau.homelinux.net:8000/~neil/graph-benchmark-results http://ossau.homelinux.net:8000/~neil/ossau/gnuplot.scm (which is the code that generates the performance tracking graphs at http://ossau.homelinux.net:8000/~neil). Regards, Neil
Re: mod_lisp support for guile-www
Thien-Thi Nguyen t...@gnuvola.org writes: () Neil Jerram n...@ossau.uklinux.net () Sun, 07 Mar 2010 23:00:13 + I'm working on a project that needs a web data server, and I'd like to use Apache + mod_lisp + Guile for that. [extending Guile-WWW: background, rationale, etc] [patch] I'd like to add this support to Guile-WWW. Has there been any further development on this patch, or should i run with what you posted? Hi Thien-Thi, Sorry that this reply is so late ... but no, there hasn't been anything since what I posted. And I see that you've since released a new Guile-WWW with this included - thanks for doing that. When I'm working in this area again, I'll of course rebase to the new release and offer any further changes that emerge. Regards, Neil
Re: Thread and guile environment
ri...@happyleptic.org writes: Suppose I have a multithreaded C program. Isn't the guile environment supposed to be shared amongst all threads ? That's what I understood from reading the docs anyway. Yet this simple exemple shows the opposite (see the 3 attached files). So am I supposed to source my global scheme definitions in all threads ? Hm. I think I recall a bug to do with different threads starting in different modules. Does it work if you add (define-module (guile-user)) at the start of your bug.scm ? Neil
Re: Best way to call a user defined hook (written in guile) from C when the hook need plenty parameters
ri...@happyleptic.org writes: (define (hook-helper %s) (lambda () #\t)) where %s is the long list of parameters (foo bar baz...) that's inserted by the C program. And : (define (hook . args) (local-eval (cons print-user-fields user-fields) (procedure-environment (apply hook-helper args Using local-eval and procedure-environment like this won't work in Guile 1.9/2.0, I believe. But you could get a similar effect - which I think will still work in 1.9/2.0 - by creating a module, defining values in it, and then evaluating in that module. (In Guile, module == top level environment.) (Note that the bindings in a module are conceptually similar to an alist, so this is actually not so different from what Thien-Thi suggested.) To create a module, in Scheme: (define-module (xxx)) Then your C code would access that using SCM module = scm_c_resolve_module (xxx); and define each value in it using scm_c_module_define (module, name, value); and finally evaluate in that module using scm_c_eval_string_in_module (expression, module); It would also seem (at least to me) a bit less magical to define the user-fields as a procedure, e.g.: (define (calc-user-fields) (list foo bar (+ baz foo) (if ( foo bar) 1 2))) and then the expression above would be (calc-user-fields). All completely untested, of course! :-) Regards, Neil
Re: Jumping back to REPL prompt on ^C
Taylor Venable tay...@metasyntax.net writes: Hi there, I'm writing a piece of code with a web server component, and part of that being that I want to jump back to the REPL when one hits ^C. So it would go something like this: scheme@(guile-user) (start-server) ;;; handling requests ^C scheme@(guile-user) What I tried doing was essentially this: (call/cc (lambda (k) (sigaction SIGINT (lambda (_) (k))) (start-server))) Just a couple of notes here. First, continuations usually take an argument: the value which will be the return value of the (call/cc ...) expression. So '(k)' may be wrong. Second, I wonder if you meant (lambda _ ...) instead of (lambda (_) ...). I often use the former when I want a lambda that accepts any number of arguments. Except *sometimes* when I hit ^C I ended up with an error that stops the guile program completely, seemingly due to the readline library that I've enabled in the REPL. When I simplify my test I'm able to get the same fatal error all the time. [..] In unknown file: ?: 0 [catch-closure misc-error %readline readline is not reentrant () #f] This suggests to me that the code was already inside readline when you hit ^C. Does (start-server) ever return naturally? If it does, there's a window where it's just returned and the REPL is calling readline to read the next line of input, but the terminal may not have shown the prompt yet. So if you type ^C in that window, the error above would be expected. Alternatively, does the code inside (start-server) ever use readline? Perhaps by mistake it is using '(readline)' instead of '(read-line)' from (ice-9 rdelim)? In this case there'd obviously be loads more chances of seeing the above error. Regards, Neil
Re: Resigning from Guile maintainership
Thien-Thi Nguyen t...@gnuvola.org writes: Are there any pointers you'd like to leave us so that we can understand and continue the Neil Jerram, Guile-Hacker style? Unfortunately it's been a while since I had a really good protracted hack - I think that's another reflection of changing life... The three that occur to me now were all fantastic and absorbing uses of Guile... - The first development of debugging infrastructure and GDS, which I did on a lovely week off in Brighton, pre-child. - The 1.8 elisp translator. Can't remember exactly when that was, but it was fun. - Integrating Guile with my work's software - which is unfortunately not free, and so I can't provide much detail about it... But (in my view at least) the Guile layer added so much capability, and allowed me to play with lots of things quickly like web interfaces and a GOOPS representation of the concepts in that software. That was post-child, after I noticed that babies sometimes do lots of sleeping :-) In summary, I think the main thing, at least for me, is having a nice big wodge of spare time to devote! Best wishes, Neil
Resigning from Guile maintainership
Hi Everyone! I feel the time has come for me to step down from the Guile maintainership. Andy and Ludo are doing an amazing job as the other maintainers, and I have no doubt that Guile's future is bright: technically fascinating, and showing new signs of become ubiquitous within the GNU project, as was its original intention. For me personally, the reality is that I've always been more a steady pair of hands for Guile than a creative powerhouse, and I'd now like to spend more of my time on many other things that are calling for it - and without a slight feeling of guilt that I should be keeping that time for Guile. I still plan to hang around, as one of Guile's many users and occasional contributors. In particular I hope to continue making contributions towards getting the manual ready for publication sometime this year. But generally I look forward to sitting back and enjoying the ride! If there are specific things that people believe to be on my list as a maintainer, and so were/are expecting me to get to at some point, please email me (either privately or publicly, as appropriate) so we can decide what to do about those. Best wishes to all, and here's looking forward to Guile 2.0! Neil
Re: Reconsideration of MinGW work
Ken Raeburn raeb...@raeburn.org writes: Yes... you then also need to decide if Guile is exposing GNU/POSIX functionality, whatever the native OS functionality is, or some abstraction... Ideally, yes, I think. In other words, I think it's preferable if Guile provides the same function to applications on all platforms. (Emacs shows how fantastically useful this is.) Having just bought a Lemote Yeelong notebook at LibrePlanet [...] Aside: I was wondering about buying one of those too, but haven't yet because of performance concerns. Can it compile Guile successfully, and if so how long does it take? You *are* reporting these bugs, aren't you? :-) Err... not yet. So thanks for the reminder. But I just checked, and their (i.e. Wine's) bugzilla requires creating an account, so I'm not sure I'll bother. (Is that really irresponsible of me?) I think cross-compilation and cross-testing is a good thing to be able to do. Obviously cross-testing requires some additional setup -- as a trivial example, the test suite code isn't going to know the name or IP address of your Windows or Yeelong machine. I know it's hard to set up, though, and especially hard to maintain if few people actually use it. Perhaps having build farms available with multiple platform types can help there. I agree that this is useful, but it is, as you say, difficult to set up. Personally, to the extent that I continue working on this, I think I'm happy to limit myself to what can be achieved with emulation (i.e. with Wine) on a single Linux box. At least so far as regular builds are concerned; of course I'd also expect occasionally to copy the built DLLs over to Windows and try them there. One nagging concern I've got about my Guile-Emacs project is the seemingly narrow focus of active Guile developers as far as platforms are concerned. I'm one of, what, two or three people testing the development versions on Mac OS X now and then, and most of the rest of the work is on x86 or x86-64 GNU/Linux systems, it seems? Yes, but this isn't intentional, just a matter of limited resources. On the other hand, in the Windows case, it seems there is independent effort being put in to the problem downstream. I wonder why that's downstream - perhaps because we're not good enough at accepting patches when they're offered? On the MacOS side I haven't been closely involved recently, but I think - for all platforms other than the really mainstream ones that you've mentioned above - we need people who are authoritative about what the solution for a given problem is. If I see a patch for MacOS that seems to be done at the right place in the build, and obviously doesn't inappropriately impact other platforms, and the submitter is authoritative about it being the right solution for MacOS, it's easy to say OK, I believe you, and there's no risk, so let's commit it. But in the conversations that I remember there hasn't been that authoritative tone; it's more like I've needed to work out half of the solution myself, which I'm not in a position to do. So then things get left sitting, etc. And similarly for other less mainstream platforms. For a random Scheme implementation, it's okay to pick the set of platforms you want to support, and drop whatever's inconvenient. Which is absolutely not my intention... But if you want to be the official extension language for the GNU project, used by (theoretically) lots of GNU packages, you've got to support all the platforms the developers of those platforms want to support, if you possibly can. I agree. I think that includes both Cygwin and MinGW, This is a key point. My previous email hinted that Cygwin support might be enough, and several people have commented that it isn't. So I'm happy now that that hint was wrong. For me, then, the questions are whether we need any more Cygwin/MinGW support for 1.8.x than what already exists, and how, structurally speaking, we do Cygwin/MinGW support for 1.9/2.0 and future releases. Having said that, I don't feel I understand technically why a MinGW version of Guile, including all necessary emulation code, would run faster or be less bloated than a Cygwin Guile. Can someone explain that? and probably not just supporting whatever subset can be mapped into POSIX functions via Gnulib. I don't think I understand your point here. Gnulib isn't a fixed point. If we can add emulation code into Guile, can't we just as easily add it into Gnulib? Regards, Neil
Re: Reconsideration of MinGW work
Peter Brett pe...@peter-b.co.uk writes: Neil Jerram n...@ossau.uklinux.net writes: I've been making gradual progress on MinGW cross building, but I've reached a point where I'm no longer sure that this is worthwhile. This email explains why, and invites comments from anyone interested in this - especially from anyone who is really trying to use Guile on Windows. We get people coming to the gEDA user mailing list on a regular basis saying, Where can I find a version of gEDA for Windows? and the Windows builds we've put out have been generally well-received. Since Guile is one of our core dependencies, lack of Windows support in Guile would mean that we wouldn't be able to provide a Windows build at all (we already had massive problems at the start of the Guile 1.8.x series with GMP portability, or lack thereof, and this meant that it took almost three years after 1.8 became the supported stable release for us to be able to stop supporting 1.6). Hi Peter, I'm sorry, I didn't mean my email to suggest dropping Windows support. It was more about what more (if anything) is needed for 1.8 releases, and how to handle Windows support in future, and how those points relate to a line of work that I've been spending time on recently. Where are you getting your MinGW guile from at the moment? Is it that MinGW SF page that I mentioned, or somewhere else? Cygwin isn't an option, unfortunately; we think it's totally reasonable for users to want to use the native windowing system, not to mention the fact that Cygwin is *dog slow*. OK, understood. I'd like to understand more about what makes Cygwin slow, though, in order to see why a MinGW Guile wouldn't end up being equally slow. But in the interim I'm happy to accept that MinGW is needed. Regards, Neil
Re: Reconsideration of MinGW work
Linas Vepstas linasveps...@gmail.com writes: My pet peeve with mingw is the lack of ready-to-go regex. This is completely unrelated to guile; I have another project that made the mistake of assuming that regex just worked on windows, and I've been bitched at ever since. Gnulib has a regex library. Getting regex into mingw and having it just work would be excellent. But that won't happen, because that's not part of MinGW's mission. All MinGW is trying to do is provide a free software toolset for building native Windows programs - which at runtime will link to the standard set of DLLs that M$ provides. Those DLLs don't provide regex, so the MinGW header files don't provide regex either. Neil
Re: Need help to understand a macro
Josef Wolf j...@raven.inka.de writes: BTW: While we're at the docs, what I find confusing about guile documentation is that it talks extensively about the C bindings, but has not much to say about the language itself and how guile differs from the standard (extensions, limitations). But maybe I've just not got the big picture yet... I have some changes pending that may help a bit with that. For the standards that Guile follows, I think it's pretty faithful, so there isn't much to say about limitations. So that just leaves saying what those standards are, and extensions. For the former, one of my pending changes for the 2.0 manual has this: === Guile implements Scheme as described in the Report on the Algorithmic Language Scheme (usually known as @acronym{R5RS}), providing clean and general data and control structures. Guile goes beyond the rather austere language presented in @acronym{R5RS}, extending it with a module system, full access to @acronym{POSIX} system calls, networking support, multiple threads, dynamic linking, a foreign function call interface, powerful string processing, and many other features needed for programming in the real world. The Scheme community has recently agreed and published R6RS, the latest installment in the RnRS series. R6RS significantly expands the core Scheme language, and standardises many non-core functions that implementations -- including Guile -- have previously done in different ways. Guile has been updated to incorporate some of the features of R6RS, and to adjust some existing features to conform to the R6RS specification, but it is by no means a complete R6RS implementation. Between R5RS and R6RS, the SRFI process (@url{http://srfi.schemers.org/}) standardised interfaces for many practical needs, such as multithreading programming and multidimensional arrays. Guile supports many SRFIs, as documented in detail in @ref{SRFI Support}. In summary, so far as relationship to the Scheme standards is concerned, Guile is an R5RS implementation with many extensions, some of which conform to SRFIs or to the relevant parts of R6RS. === As far as extensions are concerned, I think it is very likely that the manual isn't always clear about what things are standardized and what are extensions. But I'm not sure what to do about it - do you have a suggestion? Also, how much does it matter in practice? Regards, Neil
Re: Is Guile Useful to a Scheme Noob
Gour g...@gour-nitai.com writes: After starting with it and trying examples in guile, I've quickly found out that e.g. guile-1.8.x does not support some stuff from the book (e.g. using square brackets to delimit bindings of let expr.). True. But you should be able to work around that just by changing [ and ] back to ( and ). (Personally I dislike those square brackets, and it seems to me an unhelpful editorial choice to use them in TSPL. I don't recall my copy having them; perhaps yours is a newer edition.) I'm aware that guile-1.9.x has brought support for it, but gnucash support only guile-1.8 and upcoming gnucash-2.4 won't support guile-2.0 either (no idea how hard it would be to support it), but considering my primary objective is to learn guile for gnucash I wonder if sticking to guile-1.8.x is better option for my learning? For learning the language, and tweaking gnucash, yes, I'd say guile-1.8 is the better option. Another thing, since I use Emacs, I'd appreciate some hing which mode to use for guile code? I see there is Quack and I've just found out about Geiser... For all the options apart from Geiser, see `Using Guile in Emacs' in the manual. For Geiser I guess you don't need help, as you say you've already found out about it. Neil
Reconsideration of MinGW work
I've been making gradual progress on MinGW cross building, but I've reached a point where I'm no longer sure that this is worthwhile. This email explains why, and invites comments from anyone interested in this - especially from anyone who is really trying to use Guile on Windows. First, I've found that completing a successful build (i.e. autogen.sh, configure and make) is not at all the end of the story; it's only the first part of what is really needed - because at runtime some key pieces of function can still be missing, or can behave differently on MinGW/Windows than on Linux/POSIX. Two examples of this are operations on file descriptors - where on MinGW/Windows different functions must be called for sockets than for real files - and regular expressions, which are not supported by the MinGW/Windows C library. Therefore the definition of success also needs to include a successful make check, or some equivalent of that. Using MSYS and MinGW on Windows, I assume that make check can be run just as easily as make. When cross-building with i586-mingw32msvc-* tools on Linux, make check can be run (in principle) if you also have Wine installed, and that's the setup that I've been using recently. Second, though, it turns out that using i586-mingw32msvc-* and Wine on Linux unfortunately does not give the same results as MSYS and MinGW on Windows. For example I've found that system(NULL) throws a SIGSEGV under Wine, but for Carlo Bramix, working on Windows, that wasn't a problem; and instead, for Carlo, there were other problems that I don't see with a Linux cross build. This is hardly surprising. Although Wine aims to emulate the Windows runtime DLLs precisely, of course it is only software and so can have bugs. But it is an extra hassle in practice. Third, I reviewed my own need for Guile on Windows - and in fact I've been perfectly happily using the Cygwin version for some time now. So actually I don't currently need a MinGW version - and maybe that would be true for other Guile on Windows users too. Looking forwards, supporting a Cygwin build of Guile will always be much easier than supporting a MinGW build, because the whole point of Cygwin is to provide an emulation on Windows of the POSIX API, and that's what most of the Guile code assumes. Fourth, I've realized that I significantly misunderstood MinGW's objective. Its true objective is to provide free software tools for building native Windows programs to run with the Win32 runtime DLLs, and the MinGW website is actually very clear about this. That means that it is 100% targeting the API provided by the Win32 DLLs. But somehow or other I had got the idea that it was also a bit Cygwin-ish, in trying to provide pieces of the Linux/POSIX API that aren't provided by those DLLs. That last idea is completely wrong, which means that trying to build a POSIX-assuming project for MinGW is always going to be hard. Fifth, and now thinking more of the future with 1.9/2.0, I wondered if it would be better to address MinGW porting problems within Gnulib, instead of putting lots of #ifdef __MINGW32__ into Guile's own code. And in fact yes, based on a small and completely unscientific sample of Google results, it seems the Gnulib guys do regard MinGW compatibility as part of their remit. So putting #ifdef __MINGW32__ stuff into Guile is probably unhelpful anyway, because it would be better to contribute to Gnulib instead. And it's possible that Gnulib might already have what we need. And finally, I noticed that there already claims to be a MinGW port of Guile 1.8, here: http://sourceforge.net/projects/mingw/files/ http://sourceforge.net/projects/mingw/files/MSYS%20guile/guile-1.8.7-1/guile-1.8.7-1-msys.RELEASE_NOTES/download Therefore I'm inclined to conclude the following. - Overall, it isn't as important as I had been thinking to get a complete MinGW build of Guile. I personally plan to concentrate more now on 1.8 - 1.9/2.0 compatibility, and on the manual. - As far as future development is concerned, including the current master branch, MinGW portability fixes should be directed at Gnulib if possible, instead of done directly in the Guile code. - As far as 1.8.x is concerned, I'm not sure if there's any need out there that isn't already met either by Cygwin or by the MinGW port linked above. Anyone still reading? Congratulations if so - and please let me know what you think! Regards, Neil
Re: Is Guile Useful to a Scheme Noob
Gour g...@gour-nitai.com writes: It seems that it won't be so easy to add support in gnucash considering that 2.0 is big jump in guile's evolution? Ideally we (meaning the core developers) will have time to do more work on 1.8 - 1.9/2.0 compatibility before the 2.0 release, including by working with gnucash, so that we can understand and hopefully fix the problems. Regards, Neil
Re: Is Guile Useful to a Scheme Noob
Mike Gran spk...@yahoo.com writes: From: Neil Jerram n...@ossau.uklinux.net True. But you should be able to work around that just by changing [ and ] back to ( and ). (Personally I dislike those square brackets, and it seems to me an unhelpful editorial choice to use them in TSPL. I don't recall my copy having them; perhaps yours is a newer edition.) Square brackets would be fairly easy to backport to 1.8. Is there an argument against doing so? Well... n...@laruns:~$ guile guile (version) 1.8.7 guile (define [a 2) guile [a 2 But that's hardly a big deal; recognizing [ and ] as ( and ) could be subject to a reader option. (Also at one point we had support for Elisp vector syntax. I'm not sure how that ended up in 1.8.x, but in any case any possible problem is still covered by a reader option.) So if you feel like backporting this, please go ahead! Neil
Re: mod_lisp support for guile-www
l...@gnu.org (Ludovic Courtès) writes: I note that Guile-WWW's license is GPLv3+, whereas the Guile distribution as a whole is LGPLv3+. I'm not sure if that's a problem or not; It’s not a problem. It’s fine to have parts of the standard library under the LGPLv3+ and other parts under GPLv3+ (e.g., Readline support is under GPLv3+), as long as libguile and supporting code remain LGPLv3+. Great; thanks for the quick answer on that. Neil
Re: loading a module
Tomas By to...@basun.net writes: On Sun, February 28, 2010 23:59, Neil Jerram wrote: This is really a stab in the dark - but could you try using a name for the Scheme-level procedure that is different from the module name? Currently they are both mytest. I think there could be some residual nonsense meaning for a binding that has the same name as the module... Thanks for the suggestion. I tried changing the name in the define_gsubr and export statements and it made no difference. But it's ok. Compiling my own binary is fine for what I am doing. I'm not sure why I bother so much about this in the first place. Maybe I should have my head looked at. OK, fine. But please do come and ask us again if you need to, and we'll have another go. Neil
Re: request: libguile to wrap getsid(2)
Thien-Thi Nguyen t...@gnuvola.org writes: As years go by, i have come to venerate old code per se less and less. I think it would be cool to write tools to distill the essence of old code, recasting into new code. That is what compilers do, after all... If the new compiler/translator framework in Guile 1.9.x is capable of handling ECMAScript and elisp, it should certainly (in principle) be able to handle slightly different variants of Guile Scheme. So that might be a good way of handling any recasting at runtime. I believe it also supports writing out recast code - although perhaps at the cost of losing some formatting and comments. Dreaming, i'd like to see compilers that go beyond: compilation source - executable representation to grok-db -+---+ v| compilation | source ---+ executable representation where grok-db contains the analysis results of (this and other) source, both present and past. Can you give an example of what grok-db might say? Also note that grok-db is in a sense already present, in the source code of the compiler. Regards, Neil
Re: why guile is so slow?
Chengqi Song son...@gmail.com writes: thanks but this package does not compile now. scm_tc7_svect undeclared. Yes, I'm sorry, it hasn't been updated for a while. Unfortunately I don't have time to look at this now. I'll try to do that in the next week or two. If you decide to work on it, please let me know. Regards, Neil lars On Sun, 27 Dec 2009, Neil Jerram wrote: Chengqi Song son...@gmail.com writes: Thanks to Neil, Is there any binding to xlib? or easier way to generate a xlib binding? thanks. Yes, guile-xlib. (Written by me, and maintained for a while by Thien-Thi Nguyen.) It is not a complete Xlib binding, it only has some core functions. But I think it would be a good starting point if you are interested in adding support for more Xlib operations. These links should work for guile-xlib-0.4, although I'm not sure because my ISP is ridiculously slow right now. http://www.ossau.uklinux.net/guile/indeterminate/guile-xlib-0.4-README.txt http://www.ossau.uklinux.net/guile/indeterminate/guile-xlib-0.4.tar.gz Regards, Neil
Re: request: libguile to wrap getsid(2)
Thien-Thi Nguyen t...@gnuvola.org writes: I've just about finished porting ratpoison (a CVS snapshot prior to its author's abandoning it in favor of stumpwm) to Guile (1.4.x) scheme. This means no more Xlib (et al)! Cool. (I like ratpoison, and I wasn't aware it had been abandoned. A Guile-enabled ratpoison would be great.) However, the last bit of C glue (outside of ttn-do) it needs is getsid(2). Here is the Guile 1.4.x-flavored wrapping: GH_DEFPROC (rpx_getsid, getsid, 1, 0, 0, (SCM pid), doc: /*** Return the session id associated with @var{pid}. */) { return gh_int2scm (getsid (gh_scm2int (pid))); } I'm sure it would be no trouble to adapt this to other Guile versions. This function will go into Guile 1.4.1.119, so i'm hereby requesting that a future Guile 1.9.x include it, as well. This way, i can release rpx (working name of the port -- kind of like ratpoison exhumed) with only ttn-do as its dependency, and no C bits whatsoever. No problem, I'll add this. Can you point to a specific 1.4.x commit, to help with any extra bits that are needed, e.g. anything in configure.ac? But ttn, why do you care about any Guile other than 1.4.x? Well, why not? Well, indeed. Let's make 2010 the year of repairing our divisions... With Guile 1.9.x/2.0, we have a fantastic new base system that I think will serve us well for some years. With that in place, it would be great to pull together all the Guile apps and extensions that are out there, and showcase them working together and doing interesting things. Plus, as far as possible, I hope we can find ways of making everything work with older versions of Guile too. thi Regards, Neil
Re: typo in guile doc?
Thien-Thi Nguyen t...@gnuvola.org writes: () Chengqi Song son...@gmail.com () Sun, 27 Dec 2009 07:22:50 +0800 By calling this function, the garbage collector learns about all references that your SMOB has to other SCM values. what is has to other SCM values? is it a typo? Perhaps that object contains (points to, references) other sub-objects. The SMOB's mark function must call (back to) Guile's mark function for those sub-objects. In this way the collector learns. If the mark function fails to do that, the collector remains ignorant. We could rewrite this as: By calling this function, the garbage collector learns about the other SCM values (if any) that your SMOB refers to. Would that be clearer? Also please note that this is different in Guile 1.9.x. (In summary, the mark function isn't needed any more.) If you're writing something new, you may want to consider targeting Guile 1.9.x instead of 1.8.x. Regards, Neil