Re: The progress of hacking guile and prolog
Hi Noah, On Wed 24 Nov 2010 02:54, Noah Lavine noah.b.lav...@gmail.com writes: What I'm thinking of is like racket contracts, but with the idea of trusted modules, which might involve static checking. Yeah, definitely. Like the interface between typed and untyped code in racket, also. I don't know very much about the relationship between types and contracts, though. I'm curious in general though whether it would be possible and worthwhile to statically check programmer-defined ideas, as long as the interface is easy enough to use. For instance, what if you could ask Guile to check that your tree structure always remained a binary tree? Or better, what if you wrote a GUI program and checked that the callbacks you passed to the GUI library would always return? (I know it's not possible in general, but I think it will work for a subset of procedures that will include some interesting ones.) It's certainly interesting! As I understand things (which is not very far), Racket allows for this via other languages. Guile could do that too. We might need some more generic support for this kind of thing in the compiler infrastructure or in tree-il or whatever, but I would like to make it possible to experiment with these linguistic ideas, with the kind of isolation provided by modules. Cheers, Andy -- http://wingolog.org/
Re: The progress of hacking guile and prolog
Hello, Though I’d recommend working on JIT for Guile before you get stuck in a meta-circular Curry-Howardish enlightenment period. :-) I agree. :-) Noah
[PATCH] SRFI 26 without defmacro
* module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'. The new implementation is mostly just a transcription of the old code; the reference implementation which relies only on `syntax-rules' may (or may not) be considered more elegant :-). From: Andreas Rottmann a.rottm...@gmx.at Subject: Get rid of `define-macro' in the SRFI 26 implementation * module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'. The new implementation is mostly just a transcription of the old code; the reference implementation which relies only on `syntax-rules' may (or may not) be considered more elegant :-). --- module/srfi/srfi-26.scm | 69 +- 1 files changed, 43 insertions(+), 26 deletions(-) diff --git a/module/srfi/srfi-26.scm b/module/srfi/srfi-26.scm index 324a5dc..4a9f441 100644 --- a/module/srfi/srfi-26.scm +++ b/module/srfi/srfi-26.scm @@ -1,6 +1,6 @@ ;;; srfi-26.scm --- specializing parameters without currying. -;; Copyright (C) 2002, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2002, 2006, 2010 Free Software Foundation, Inc. ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -21,29 +21,46 @@ (cond-expand-provide (current-module) '(srfi-26)) -(define-macro (cut slot . slots) - (let loop ((slots (cons slot slots)) - (params '()) - (args '())) -(if (null? slots) - `(lambda ,(reverse! params) ,(reverse! args)) - (let ((s (car slots)) - (rest (cdr slots))) - (case s - (() - (let ((var (gensym))) - (loop rest (cons var params) (cons var args - ((...) - (if (pair? rest) - (error ... not on the end of cut expression)) - (let ((var (gensym))) - `(lambda ,(append! (reverse! params) var) - (apply ,@(reverse! (cons var args)) - (else - (loop rest params (cons s args +(define-syntax cut + (lambda (stx) +(syntax-case stx () + ((cut slot0 slot1+ ...) + (let loop ((slots #'(slot0 slot1+ ...)) + (params '()) + (args '())) + (if (null? slots) + #`(lambda #,(reverse params) #,(reverse args)) + (let ((s (car slots)) + (rest (cdr slots))) + (with-syntax (((var) (generate-temporaries '(var + (syntax-case s ( ...) + ( +(loop rest (cons #'var params) (cons #'var args))) + (... +(if (pair? rest) +(error ... not on the end of cut expression)) +#`(lambda #,(append (reverse params) #'var) +(apply #,@(reverse (cons #'var args) + (else +(loop rest params (cons s args -(define-macro (cute . slots) - (let ((temp (map (lambda (s) (and (not (memq s '( ...))) (gensym))) - slots))) -`(let ,(delq! #f (map (lambda (t s) (and t (list t s))) temp slots)) - (cut ,@(map (lambda (t s) (or t s)) temp slots) +(define-syntax cute + (lambda (stx) +(syntax-case stx () + ((cute slots ...) + (let loop ((slots #'(slots ...)) + (bindings '()) + (arguments '())) + (define (process-hole) + (loop (cdr slots) bindings (cons (car slots) arguments))) + (if (null? slots) + #`(let #,bindings + (cut #,@(reverse arguments))) + (syntax-case (car slots) ( ...) + ( (process-hole)) + (... (process-hole)) + (expr +(with-syntax (((t) (generate-temporaries '(t + (loop (cdr slots) +(cons #'(t expr) bindings) +(cons #'t arguments))) -- tg: (c0f6c16..) t/srfi-26-hygienic (depends on: master) Regards, Rotty -- Andreas Rottmann -- http://rotty.yi.org/
Re: piper schemigan
On Thursday, November 25, 2010 10:17:44 pm Ludovic Courtès wrote: +1 for reviving Guile-SCSH! Ludo’. yay, Well all this stems from me littering development code with printf or pk's or pretty-pk's and then add tags to it. Then I usually work in bash and mongle the output at my will. So now I have this is guile and are so pleased that I can do (use-modules (scsh syntax)) and then write (run (| (begin (the-schem-fun)) '(grep abc) '(tee debug.log))) Oh well, actually, I would probably make a macro and/or mod the reader and add the autoquoting as in the original scsh, to be able to do (the-schem-fun) | (grep abc) (tee debug.log) So from my personal view I'm sort of very close to the goal. But all of scsh have not been imported (yet) the reason is that I want to get a core that is stable. you can easilly with a little misstake make guile and actually the whole shell session go down. So, the core has to be worked on for some time. I've just made it work I do not understand the codebase and tests has to be made. I do not, personally, like the idea to incorporate all of scsh in one go. I would divede the package into a base where the basic functionality is in and that sit's closer to the guile core. Then as time goes we can add the SRE regexps, and so on. to another package, further away. Maybe I need to put in some more packages I don't now, but my sense tells me that it it wise to startup small and solid in stead of fat and ugly :-). Anyhow, I just checked in the current scsh in module/scsh in http://gitorious.org/guile-unify if there is a package you would like thean give me a hint. A note, you need to quote a lot of things explicitly and there are bugs and debug outputs - e.g. a bit premature, but I would like you to have a possibility to express ideas, ok if none, great if some. Actually I noticed that the codebase seem to be needing to include all packages into the namespace before e.g. using defmacro's and then need to have the symbols generated by the macro in the namespace. As small as it sounds, the imporvemnet on this is soo great, I can now just ask for the run macro from the (scsh syntax) package and it should work. This is far better then all of scsh working in my book. Your milage may vary, keep up the good work and a happy weekend to you. /stefan
Re: R6RS exception printing at the REPL
Andy Wingo wi...@pobox.com writes: Heya Andreas, On Sat 20 Nov 2010 19:18, Andreas Rottmann a.rottm...@gmx.at writes: Andy Wingo wi...@pobox.com writes: set-exception-printer! : exception-printer - nothing Did you mean the following? set-exception-printer! : key exception-printer - nothing Of course, yes. It seems I distilled the interface down past its essentials! ;) :-) Did you mean that `print-exception' should go into `(system repl error-handling)'? This, that print-exception could go into (system repl error-handling). The reason for this would be to allow the default exception printer, embedded in print-exception, to use other modules, like match or pmatch or the like. I think? That sounds like a good idea. I just sat down to implement this, and noticed that, to not lose current functionality, `print-exception' and exception printer procedures would need a `frame' argument as well, right? What do you think? Besides the above questions, I wonder where I should install the exception printer for R6RS exceptions (since the code will depend on quite a bit of R6RS, so we maybe want to have it loaded on demand, like in the last patch. Good question. For r6rs exceptions, I think either (rnrs conditions) or (rnrs exceptions). Ideally I'd like to put it into its own module. The exception printer should be able to freely use all of R6RS, and I'd like to avoid making the already complicated relationships between the modules implementing R6RS even more so by introducing additional imports or `@'-references into either of these modules. I'm aware, however, that the separate-module approach will not work with the proposed exception printer registry unless the module registering the handler is actually loaded; perhaps registering a printer in `(rnrs exceptions)' that lazy-loads the module actually implementing the printer would work, but maybe that would be too hairy? [ It's off-topic in this thread, but I think the circular dependencies introduced by using `@' and `@@' in the R6RS modules should at one point be eliminated; they work almost all the time, but can fail in surprising ways -- see the commit comment of c0f6c163... ] For srfi-35 conditions, either we make another registry for printers of srfi-34 [sic] exceptions, or just assume that people using srfi-34 probably want srfi-35 as well, and have srfi-35 define the printer for srfi-34 exceptions. Hmm, that's a kind of a tricky question, since `raise' and the condition system (for both the SRFI and R6RS varieties) are orthogonal, even if they are most often used together. A possible solution might be to allow an exception printer to decline to handle a specific raised object, and fall back on the default behavior. If we do that, it might even make sense to allow multiple printers per throw key. So the API would change just a small bit: exception-printer := port args - boolean Regards, Rotty -- Andreas Rottmann -- http://rotty.yi.org/