Re: How to add Guile support to a package

2015-01-05 Thread Hans Aberg
> On 5 Jan 2015, at 10:19, Antonio Ceballos wrote: > GNU Chess has not been using the garbage collector so far. There is an issue when using C++ global objects having initializers doing allocations, on platforms (as on OS X) where the GC initializer must run first.

Re: How to add Guile support to a package

2015-01-05 Thread Hans Aberg
> On 5 Jan 2015, at 14:18, Chris Vine wrote: > > On Mon, 5 Jan 2015 11:05:31 +0100 > Hans Aberg wrote: >> There is an issue when using C++ global objects having initializers >> doing allocations, on platforms (as on OS X) where the GC initializer >> must run

Re: How to add Guile support to a package

2015-01-05 Thread Hans Aberg
> On 5 Jan 2015, at 17:27, Chris Vine wrote: > > On Mon, 5 Jan 2015 15:44:16 +0100 > Hans Aberg wrote: >> Guile is written entirely in C, so there is no problem. > > You referred to using C++ global objects with gc on Darwin, which is the > subject I am interested

Re: How to add Guile support to a package

2015-01-06 Thread Hans Aberg
> On 5 Jan 2015, at 18:34, Antonio Ceballos wrote: > This is only a rough plan, but one of the things that I have in mind is > to allow users provide their own evaluation function as an Scheme > expression. That would be possible when GNU Chess is run in a > especial new mode whereby the Guile e

Re: concerns when integrating C++ code into guile?

2015-01-07 Thread Hans Aberg
> On 7 Jan 2015, at 03:32, Matt Wette wrote: > > What are the concerns when integrating C++ code into guile? > > I'm guessing interleaved C++ exception handling, but are there others. > > Assuming the C++ code calls no guile code, should all C++ exceptions be > caught at the interface? In th

Re: concerns when integrating C++ code into guile?

2015-01-07 Thread Hans Aberg
> On 7 Jan 2015, at 14:52, Matt Wette wrote: > > Python is written in C yet Qt has been integrated in to produce PyQt. I > wonder how that is done. I will take a look. If Python can be compiled as C++, that might be one way. For proper C, the example below compiles with: gcc -lstdc++ mai

Re: concerns when integrating C++ code into guile?

2015-01-07 Thread Hans Aberg
> On 7 Jan 2015, at 03:32, Matt Wette wrote: > > What are the concerns when integrating C++ code into guile? There is a FAQ about mixing C and C++ here: https://isocpp.org/wiki/faq/mixing-c-and-cpp

Re: concerns when integrating C++ code into guile?

2015-01-07 Thread Hans Aberg
> On 7 Jan 2015, at 21:24, Ludovic Courtès wrote: > > If Scheme code calls C++ code that throws an exception, then the stack > will be unwound by libstdc++ and Guile’s ‘dynamic-wind’ handlers and > such will not run. If one tries to pass a C++ exception through Guile code, it will not catch i

Re: concerns when integrating C++ code into guile?

2015-01-08 Thread Hans Aberg
> On 8 Jan 2015, at 01:18, Chris Vine wrote: > > On Wed, 7 Jan 2015 23:15:07 +0100 > Hans Aberg wrote: >> >>> On 7 Jan 2015, at 21:24, Ludovic Courtès wrote: >>> >>> If Scheme code calls C++ code that throws an exception, then the >>> s

Re: concerns when integrating C++ code into guile?

2015-01-08 Thread Hans Aberg
> On 8 Jan 2015, at 02:00, Matt Wette wrote: > > > On Jan 7, 2015, at 6:45 AM, Hans Aberg wrote: > >> >>> On 7 Jan 2015, at 14:52, Matt Wette wrote: >>> >>> Python is written in C yet Qt has been integrated in to produce PyQt. I

Re: concerns when integrating C++ code into guile?

2015-01-09 Thread Hans Aberg
> On 9 Jan 2015, at 03:30, Matt Wette wrote: > > > On Jan 7, 2015, at 5:00 PM, Matt Wette wrote: >> PyQt does not recompile Python in C++ so there must be some way to do it w/o >> recompiling python (=> guile). > > I looked into PyQt a bit. Only recent versions of Qt have exceptions. The

Catching

2010-02-22 Thread Hans Aberg
I seem to not get the catch handler called, when using guile interactively. Might you provide a small example? Something like: (catch 'FOO (throw 'FOO "Test") (lambda (x . xt) (display x) (display " . ") (display xt))) (catch #t (throw 'FOO "Test") (lambda (x . xt) (display x) (display " . ")

Re: Catching

2010-02-22 Thread Hans Aberg
On 22 Feb 2010, at 14:22, Ludovic Courtès wrote: I seem to not get the catch handler called, when using guile interactively. Might you provide a small example? Something like: (catch 'FOO (throw 'FOO "Test") (lambda (x . xt) (display x) (display " . ") (display xt))) The second argument of ‘ca

C++ wrap

2010-02-22 Thread Hans Aberg
I have written a bit on a C++ wrap - has this been done? I use templates to get a static typed style similar to that of Haskell, which can be overridden at need. Some example code below. Hans #include "src/guile.hh" #include #include #include int inner_main(std::pair* argp) {

Re: C++ wrap

2010-02-22 Thread Hans Aberg
On 22 Feb 2010, at 20:06, Andy Wingo wrote: I have written a bit on a C++ wrap - has this been done? I use templates to get a static typed style similar to that of Haskell, which can be overridden at need. Some example code below. Looks like fun! You should throw your code up somewhere for

Re: C++ wrap

2010-02-23 Thread Hans Aberg
I have experimented with adding C++ exception handling to the wrap. It seems, using gcc, that it works fine, as long as one does not try to pass a C++ exception through a C function call - then it calls the terminate handler. So add an exception type to Guile which can hold the thrown data,

Binding symbols in stages

2010-03-06 Thread Hans Aberg
In order to do currying via C++ functions*), I might use something like an evaluator that evaluates an unbound symbol to itself. Is that possible? Translated into Scheme code, it corresponds to defining say (define add (lambda (x) (lambda (y) (+ x y by (define add1 (lambda (y) (+ x y)

Re: Binding symbols in stages

2010-03-06 Thread Hans Aberg
On 6 Mar 2010, at 12:13, Andy Wingo wrote: (define add1 (lambda (y) (+ x y))) and then (define add (lambda (x) ...)) Thus in two separate steps, where the unbound symbol x in the first expression is bound only in the second. If I understand you correctly, this is not possible in normal Schem

Re: Binding symbols in stages

2010-03-06 Thread Hans Aberg
Typos, it should have been for the curried function type: symbol x("x"), y("y"); function1 > add = x >>= y >>= x + y; // Binds to the right. Hans

Re: Guile and C++

2010-05-14 Thread Hans Aberg
On 14 May 2010, at 22:05, Noah Lavine wrote: How would this work if I wanted to not run Guile embedded in a C++ program, but instead load the C++ code at runtime from a regular Guile interpreter? (This could use either the libffi binding or the regular Guile ones.) Since Guile is written in C,

Re: Plotting in Guile

2010-07-28 Thread Hans Aberg
On 28 Jul 2010, at 17:21, Joel James Adamson wrote: I am using Guile to iterate equations and produce trajectories from those iterations. My current strategy is to redirect the stdout to a file and then use GNUPLOT to plot the trajectories as parametric plots. However, I would like to contain

Re: Plotting in Guile

2010-07-28 Thread Hans Aberg
On 28 Jul 2010, at 19:54, Joel James Adamson wrote: GNUPLOT seems to require pipes, if not using a file. The question from the IPC newbie (myself): is there something wrong with pipes? I've read a basic tutorial and they seem to do what I would need, but the author seemed to think they wer

Re: Plotting in Guile

2010-07-28 Thread Hans Aberg
On 28 Jul 2010, at 20:50, Joel James Adamson wrote: Guile has both scm_pipe() to use in a C program, and pipe to use in Scheme code. So you might try calling it directly. If you turn GNUPLOT into a library, you can link it directly to Guile. There was such a library a few years back, but it

Re: Guile, C++, and Mac OS X 10.4 (powerpc)

2010-07-28 Thread Hans Aberg
On 28 Jul 2010, at 21:49, Mike Solomon wrote: Hey guile users, Trying to compile the simple example bessel.c from Writing-Guile-Extensions.html (renamed bessel.cc because I'm using g+ +), I encountered the following error: bessel.cc: In function 'void init_bessel()': bessel.cc:13: error: i

Re: Guile, C++, and Mac OS X 10.4 (powerpc)

2010-08-18 Thread Hans Aberg
On 18 Aug 2010, at 15:49, Ludovic Courtès wrote: Hey guile users, Trying to compile the simple example bessel.c from Writing-Guile-Extensions.html (renamed bessel.cc because I'm using g+ +), I encountered the following error: bessel.cc: In function 'void init_bessel()': bessel.cc:13: error: i

Re: [darwin] building shared libraries (.so) instead of dynamic libraries.

2010-10-03 Thread Hans Aberg
On 3 Oct 2010, at 12:29, Andy Wingo wrote: The version is 1.8.7 and the i've installed it into /usr/local/gnu/lib. Is /usr/local/gnu/lib in your equivalent of $LD_LIBRARY_PATH? I know that darwin has something different, but I don't know what it is. Mac OS X 10.5.8: /usr/local/lib/libguile

List functions

2010-12-01 Thread Hans Aberg
I am writing on a parser that translates normal function syntax in to Guile code. It seems natural to translate (f, g) x into ((f g) x), and () x into (() x), but I'm not sure if the lists (f g) and () can be made acting as functions this way. So what would be natural here? (Constants might

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 18:35, Joel James Adamson wrote: It seems natural to translate (f, g) x into ((f g) x), and () x into (() x), but I'm not sure if the lists (f g) and () can be made acting as functions this way. (f g) would evaluate as a composition as long as f takes a procedure as an arg

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:20, Keith Wright wrote: ... in standard syntax would be natural to let (f, g)(x) evaluate to (f(x), g(x)), producing a list of two elements. In Guile, that would be something involving "map". If I try in Haskell, I can let (sin, cos)(2) be the same as map (g 2) [sin, cos]

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:51, Andy Wingo wrote: () x into (() x) What is the meaning of this? Did you mean () x into (map (lambda (f) (f x)) '()) ? I am trying to eliminate the "\" of the Haskell binding syntax \ ... - > f, by making the parser grammar rule for ... the same as evaluation

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:50, Hans Aberg wrote: ... in standard syntax would be natural to let (f, g)(x) evaluate to (f(x), g(x)), producing a list of two elements. In Guile, that would be something involving "map". If I try in Haskell, I can let (sin, cos)(2) be the same as map (g 2)

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: On the other hand |list| is an ordinary variable so, (list sin cos) is evaluated by evaluating the three subexpressions, giving a function that makes lists and two numeric functions of a numeric vaiable, and then applying the first function, i.e. list

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: I was trying variations like (let () (define (g x)(lambda (f)(f x))) (map (g 2) '(sin cos))) Which gives an error: In expression (f x): Wrong type to apply: sin Somebody should patch that so that it mentions the wrong type. it

Re: List functions

2010-12-02 Thread Hans Aberg
On 2 Dec 2010, at 10:57, Marco Maggi wrote: I am writing on a parser that translates normal function syntax in to Guile code. I do not know which scenario you are working with, ... I have a Bison/Flex parser/lexer combination that writes Guile code directly by calling Guile C-functions,

Re: List functions

2010-12-02 Thread Hans Aberg
Another problem: passing a list of length two to a function that takes two non-arguments. For example, (define h (lambda (x y) (display x) (display y))) and passing (list 1 2) to it. It is in the same context as before: I want to build functions like in Haskell f((1, 2), 3) where f = \((

Re: List functions

2010-12-03 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: One can set the constants to functions that evaluate to themselves. One use would be expressions like (1 + f)(x). The () just shows up in the context above. I didn't really follow that, but in seems that you want to be able to apply a list of funct

C++ exceptions

2010-12-06 Thread Hans Aberg
There is an option gcc -fexceptions that the manual says generates exception frames for all functions. As Guile is a library that may open C++ files (and of other languages that may throw exceptions), should it not have it in available at least in some form? (Guile depends on some other lib

Backquote simplification

2010-12-09 Thread Hans Aberg
Is it possible to simplify the backquote construct `(,x_1 ... ,x_k) (always unquote on all arguments) somehow, so that the unquote does not need to appear multiple times (depending on k)? (I construct these in the C-interface, and it would simplify not having to remove a sequence of them.)

Re: Backquote simplification

2010-12-10 Thread Hans Aberg
[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) ...)) Then (lambda (x1 ... xk . y) (f x1 ... xk y)) should just return at least k arguments as a list. I'm not

Re: Backquote simplification

2010-12-10 Thread Hans Aberg
On 11 Dec 2010, at 00:12, Neil Jerram wrote: [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

Re: Backquote simplification

2010-12-11 Thread Hans Aberg
On 11 Dec 2010, at 01:25, Neil Jerram wrote: 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)) (

Re: Backquote simplification

2010-12-11 Thread Hans Aberg
On 11 Dec 2010, at 11:01, Neil Jerram wrote: To reply quickly to one point in your email... (I'll ponder the rest later.) Whenever you so want. 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 understa

Functional language syntax

2010-12-22 Thread Hans Aberg
I have put up the source code of the standard functional language syntax program on top of Guile mentioned in earlier posts. One can see that Guile already has a combined imperative/functional syntax, but to go further, it would need to be extended. Take down the file guile++.tar.bz2 inside

Re: Functional language syntax

2010-12-22 Thread Hans Aberg
On 22 Dec 2010, at 22:12, Linas Vepstas wrote: I have put up the source code of the standard functional language syntax program on top of Guile mentioned in earlier posts. One can see that Guile already has a combined imperative/functional syntax, but to go further, it would need to be ext

Re: Functional language syntax

2011-01-04 Thread Hans Aberg
On 4 Jan 2011, at 17:51, Ludovic Courtès wrote: Off-topic -- but -- are there any scheme extensions to add CAML-like type system & type inference, etc. to the language? There’s Typed Racket: . Bigloo understands optional type annotations but uses them mo

Re: Problem with define-macro from compiled file (Guile 1.9)

2011-01-07 Thread Hans Aberg
On 6 Jan 2011, at 19:18, Patrick Bernaud wrote: I have a case where a macro is defined in a file that is then loaded by another which makes use of the macro. And it produces a 'wrong type to apply' error from the VM. (Works fine with GUILE_AUTO_COMPILE=0 and compiled files removed). For exampl

Re: Problem with define-macro from compiled file (Guile 1.9)

2011-01-08 Thread Hans Aberg
On 8 Jan 2011, at 00:22, Andreas Rottmann wrote: If you are writing your own macro, I find 'define-syntax' easier: It's not only easier, it also not inherently broken (as `define-macro' is). See for a discussion of the hygiene issue. This is

Predicate of define-syntax

2011-01-08 Thread Hans Aberg
On 8 Jan 2011, at 00:22, Andreas Rottmann wrote: If you are writing your own macro, I find 'define-syntax' easier: It's not only easier, it also not inherently broken (as `define-macro' is). See for a discussion of the hygiene issue. It seems

Re: when to use strings, when to use symbols

2011-01-09 Thread Hans Aberg
On 9 Jan 2011, at 03:25, Andy Wingo wrote: Let's say you have an association list. It could be (("foo" . "bar")) or ((foo . "bar")) or ((foo bar)), or even (("foo" . bar)). If you're parsing this data from over the network, in textual form, which do you use? The answer is this: * Use symb

Macro expansion

2011-01-11 Thread Hans Aberg
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

Re: Macro expansion

2011-01-15 Thread Hans Aberg
On 15 Jan 2011, at 21:39, Neil Jerram wrote: With my current Guile, scheme@(guile-user)> (version) $4 = "1.9.14.17-44f43" the third case behaves as you would expect: That is right, I used the stable versions 1.8.x, x = 7, 8. Unfortunately, when I try to install guile-1.9.14, I get the err

Re: Macro expansion

2011-01-16 Thread Hans Aberg
On 15 Jan 2011, at 21:39, Neil Jerram wrote: With my current Guile, scheme@(guile-user)> (version) $4 = "1.9.14.17-44f43" the third case behaves as you would expect: When I upgrade, then it too works. So it was a bug that has been fixed, then. scheme@(guile-user)> (version) $1 = "1.9.14.

Re: reminder: read NEWS

2011-01-30 Thread Hans Aberg
On 30 Jan 2011, at 13:20, Andy Wingo wrote: I have noticed a number of questions coming across the list that almost seem to indicate that folks have not read the NEWS. I know this cannot be the case! ;) However if you're just jumping on the 2.0 train, take an hour or so out of your hac

Re: Using guile as an extension language for GNU make

2011-09-19 Thread Hans Aberg
On 19 Sep 2011, at 17:14, Paul Smith wrote: > In make, everything is just words: broken up on whitespace. So for > example, maybe someone writes a Guile function that computes a complex > set of prerequisites for a target: > > target: $(guile (...some Guile program...)) > > The list of pr

Re: Using guile as an extension language for GNU make

2011-09-19 Thread Hans Aberg
On 19 Sep 2011, at 23:56, Paul Smith wrote: > The first stage of make is reading in all the makefiles. As part of > this, variables and functions are expanded (one line at a time) and the > result is a string. Its parser is handwritten, and perhaps not easy to tweak, and get 'make' variables an

Re: Using guile as an extension language for GNU make

2011-09-19 Thread Hans Aberg
On 19 Sep 2011, at 23:56, Paul Smith wrote: > Rather, I need to define a translation from any Guile data type I want > to support into a make-appropriate string (char* buffer) so it can be > appended to make's read buffer, then parsed by make. For any Guile data > type I can't or don't want to tr

Re: Using guile as an extension language for GNU make

2011-09-21 Thread Hans Aberg
On 21 Sep 2011, at 04:42, Mark H Weaver wrote: >> And finally, currently I have all unknown types expanding to the empty >> string but now I'm thinking it would be better to start out more >> restrictive and throw errors. This would ensure that people write their >> Guile scripts correctly (givin

Re: Problems compiling guile on OS X, while generating guile-procedures.texi

2011-09-25 Thread Hans Aberg
On 24 Sep 2011, at 19:45, Ludovic Courtès wrote: >> guile: uncaught throw to syntax-error: (memoization ~A ~S. (expected a >> proper list ((quote ()) . #> (filename . "/usr/local/guile-2.0.2/module/ice-9/psyntax-pp.scm"))>)) >> #f) >> Cannot exit gracefully when init is in progress; aborting. > >

Re: Problems compiling guile on OS X, while generating guile-procedures.texi

2011-09-25 Thread Hans Aberg
On 24 Sep 2011, at 07:05, Ian Holmes wrote: > Any suggestions on how to fix this? You might try Guile 2.0.0 - it worked with earlier versions of GC. Hans

Re: A bit further toward the flamewar

2011-10-13 Thread Hans Aberg
On 13 Oct 2011, at 18:30, Linas Vepstas wrote: > On 13 October 2011 10:20, Andy Wingo wrote: >> On Thu 13 Oct 2011 16:26, l...@gnu.org (Ludovic Courtès) writes: >> >> Anyway this second, proof side of types, is the side that Scheme does >> not have. C has a stronger story in that regard. > > L

Re: A bit further toward the flamewar

2011-10-13 Thread Hans Aberg
On 13 Oct 2011, at 23:14, Ludovic Courtès wrote: > Did you know that Coq would only compile a function when it can prove > that it terminates? That’s another kind of compiler-supported proof one > quickly gets used to. Termination is a non-deducable property. They look at a intuitionistic subset

Re: A bit further toward the flamewar

2011-10-14 Thread Hans Aberg
On 14 Oct 2011, at 11:28, Ludovic Courtès wrote: >>> Did you know that Coq would only compile a function when it can prove >>> that it terminates? That’s another kind of compiler-supported proof one >>> quickly gets used to. >> >> Termination is a non-deducable property. They look at a intuition

Re: bdwgc

2011-10-31 Thread Hans Aberg
On 31 Oct 2011, at 22:24, Ariel Rios wrote: > Where do I get bdwgc? Try the latest here, which is gc-7.2alpha6.tar.gz: http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/ Hans

Re: GNU Guile 2.0.6 released

2012-07-07 Thread Hans Aberg
On 7 Jul 2012, at 12:36, Ludovic Courtès wrote: > We are pleased to announce GNU Guile release 2.0.6, the next maintenance > release for the 2.0.x stable series. It compiled on Mac OS X 10.7.4 using clang 3.1, which is the system compiler in later development packages. It is fairly compatible wi

Re: GNU Guile 2.0.6 released

2012-07-07 Thread Hans Aberg
On 7 Jul 2012, at 15:56, Ludovic Courtès wrote: > Hans Aberg skribis: > >> It compiled on Mac OS X 10.7.4 using clang 3.1, > > Nice, thanks for the report! > >> which is the system compiler in later development packages. It is >> fairly compatible with GCC.

Re: scm_apply_1() vs. scm_apply()

2012-11-14 Thread Hans Aberg
On 14 Nov 2012, at 11:31, Alexei Matveev wrote: > I see interface of scm_apply_1() and scm_apply() are the same > and dont get the difference [1]. File libguile/eval.c in the distribution gives: /* Apply a function to a list of arguments. This function is exported to the Scheme level as takin