Re: Help needed debugging segfault with Guile 1.8.7

2010-12-01 Thread Peter TB Brett
Linas Vepstas  writes:

> Basically, if you are going to let users enter arbitrary scheme into
> your app, they *will* enter malformed, broken expressions, and you
> have to deal with these.  Among other things, you have to give them
> a clue as to what the error was -- some sort of trace, error reporting.
>
> For me, this was implementing a REPL loop look-alike in my app.
> I can't say "work-alike", I think mine *almost* works-alike, but not sure.
>
> It took me a *long* time to figure out I needed the pre-unwind version
> of things, and even then, it took me a fair amount of effort to figure
> out what to put in there.
>
> Having a section showing how to implement a repl-work-alike loop
> in one's app, with reasonable debugging/stack-printing output,
> would be nice to have.  Figuring out how to do this one one's
> own requires a lot of tenacity.

Guile 2.x would be hugely more attractive as an extension language if
there were some higher-level interfaces for application developers.  In
gEDA, we have to use a ridiculous amount of C code just to set things up
so that user-provided Scheme expressions can't leave the user staring at
a command prompt wondering where the last hour's work disappeared to
(and even that's not as reliable as we'd like).

Ideally, there should be:

 - An easily re-usable/embeddable and well-documented REPL, to aid
   developers in implementing a "Scheme Interaction Window" or similar
   in their apps.

 - An high-level API for passing strings for evaluation, that reports
   back the results or error information in a way that's easy to deal
   with from C.

In a perfect world, these would be part of the same API. ;-) I believe
that these would actually be applicable to the majority of use-cases of
libguile.

Cheers,

 Peter

-- 
Peter Brett 
Remote Sensing Research Group
Surrey Space Centre


pgpE4CJ5Jbpgj.pgp
Description: PGP signature


Re: Help needed debugging segfault with Guile 1.8.7

2010-12-01 Thread Peter TB Brett
Neil Jerram  writes:

> [snip]
>
> 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.

I wasn't aware of that document, despite using the Guile Manual every
day!  Could I please suggest that filing it under "Programming Overview"
probably isn't the best place for it?

I think it should be highlighted that adding a Guile-specific field to
dia_shape (or its equivalent) may not always be possible, e.g. if Guile
is just one of several language bindings.

>> 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.

One thing that would have been *AWESOME* is if Guile 1.8.x's GC had used
the macros defined in Valgrind's `memcheck.h' (which is BSD licensed
IIRC).  It would make running programs with libguile under Valgrind so
much more useful, and would have *instantly* highlighted what was going
wrong with my code -- it would probably have saved me a couple of days
of beating my head against what turned out to be a really simple bug.
(There's literally no runtime overhead if a program's not being run
under Valgrind).

>> 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.)

Thanks for the info.  Judging by previous experience, gEDA will need to
support Guile 1.8.x for at least two years after Guile 2.x arrives.
It's probably going to be painful. :-/

   Peter

-- 
Peter Brett 
Remote Sensing Research Group
Surrey Space Centre


pgp9iyL0jBL4D.pgp
Description: PGP signature


fluid-let?

2010-12-01 Thread Marek Kubica
Hi,

Is there a way to get fluid-let for Guile? Or something like
?

I am having a mutable hash object that I don't want to pass as an
argument to every single function that I call, I'd prefer to use a
similar solution to what the ports do, by redefining the default input
port "semi-globally".

I saw this:  but it does not work
with mutating the fluids.

regards,
Marek



Re: fluid-let?

2010-12-01 Thread Ludovic Courtès
Hi,

Marek Kubica  writes:

> Is there a way to get fluid-let for Guile? Or something like
> ?

Guile has fluids and ‘with-fluids’, which is similar to what you want
(info "(guile) Fluids and Dynamic States").  It also has SRFI-39
parameter objects (info "(guile) SRFI-39").

Hope this helps,
Ludo’.




Re: Help needed debugging segfault with Guile 1.8.7

2010-12-01 Thread Ludovic Courtès
Hello,

Peter TB Brett  writes:

> Thanks for the info.  Judging by previous experience, gEDA will need to
> support Guile 1.8.x for at least two years after Guile 2.x arrives.
> It's probably going to be painful. :-/

Out of curiosity, did you try building/running gEDA with Guile 1.9.x,
the pre-releases of 2.x?

If not, we’d be glad if you could test it and report back on any
difficulties you may encounter.  The 1.9 tarballs are available from
alpha.gnu.org.  The ‘NEWS’ file documents some incompatibility issues.

Thanks,
Ludo’.




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 be made evaluating to themselves, for example (5  
x_1 ...) -> 5.)


  Hans





Re: List functions

2010-12-01 Thread Joel James Adamson
Hans Aberg  writes:

> 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 argument and returns a function that takes x as its argument.  No
problems there.  Alternatively you could think of f returning a function
of x when it evaluates g.

Joel

-- 
Joel J. Adamson
Servedio Lab
University of North Carolina at Chapel Hill

FSF Member #8164
http://www.unc.edu/~adamsonj


pgpwXTiSVuFJn.pgp
Description: PGP signature


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 argument and returns a function that takes x as its argument.  No
problems there.  Alternatively you could think of f returning a  
function

of x when it evaluates g.


Yes, but 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] where g x = \f -> f x
   -> [0.909297426825682,-0.416146836547142]
But when I try that similar constructs in Guile, I get problems with  
evaluation.






Re: List functions

2010-12-01 Thread Keith Wright
> From: Hans Aberg 
> Cc: guile-user@gnu.org
> 
> On 1 Dec 2010, at 18:35, Joel James Adamson wrote:
> 

> >> 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),

If "(f, g) x" is (in normal syntax) supposed to mean:

  apply f to g resulting in a function that is applied to x,

then that is "natural", but whether that is normal
syntax, I can not say.  I'm liberal on this.
Normal syntax is whatever you want, but step
one is to get clear on what you want.

Speaking for myself, I have never before seen that
syntax with that meaning, so I would hesitatate
to call it "normal".  But if you define it, you can
call it what you will.

> >> and () x into (() x), but I'm not sure if the
> >> lists (f g) and () can be made acting as functions
> >> this way.

I have not only never seen the "normal syntax" in
use here, but I have no guess what it is supposed
to mean.  In Scheme "(() x)" means nothing at all.
In fact it is so far from meaningful that I can
not guess how to fix it.

> > (f g) would evaluate as a composition as long as
> > f takes a procedure as an argument and returns a
> > function that takes x as its argument.  No problems
> > there.  Alternatively you could think of f
> > returning a function of x when it evaluates g.

This is wrong terminology.
The expression (f g) applies f to g.
The composition of f and g is (lambda (x) (f (g x))).

> Yes, but 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] where g x = \f -> f x
> -> [0.909297426825682,-0.416146836547142]
> But when I try that similar constructs in Guile, I get problems with  
> evaluation.

Works for me

guile> (let ()
 (define (g x)(lambda (f)(f x)))
 (map (g 2) (list sin cos)))

(0.909297426825682 -0.416146836547142)

There are other ways to write it, but that
is the most direct translation of your Haskell 
into Scheme.

  -- Keith



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] where g x = \f -> f x
   -> [0.909297426825682,-0.416146836547142]
But when I try that similar constructs in Guile, I get problems with
evaluation.


Works for me

guile> (let ()
(define (g x)(lambda (f)(f x)))
(map (g 2) (list sin cos)))

(0.909297426825682 -0.416146836547142)

There are other ways to write it, but that
is the most direct translation of your Haskell
into Scheme.


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

I'm not sure when to use quote or list, here. Quote seems to work when  
the list is data, not a list of functions.



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),


If "(f, g) x" is (in normal syntax) supposed to mean:

 apply f to g resulting in a function that is applied to x,

then that is "natural", but whether that is normal
syntax, I can not say.  I'm liberal on this.
Normal syntax is whatever you want, but step
one is to get clear on what you want.

Speaking for myself, I have never before seen that
syntax with that meaning, so I would hesitatate
to call it "normal".  But if you define it, you can
call it what you will.


This normality only has to do with parser grammar implementation. If  
in the evaluation syntax f ..., and the binding syntax corresponding  
in Haskell to \ ... -> f, the two "..." use the same syntax, I can  
eliminate the "\". Then the evaluation syntax

  (f_1, ..., f_k) x
becomes available. I could eliminate it semnatically or set it to what  
is common in math, if not too complicated.



and () x into (() x), but I'm not sure if the
lists (f g) and () can be made acting as functions
this way.


I have not only never seen the "normal syntax" in
use here, but I have no guess what it is supposed
to mean.  In Scheme "(() x)" means nothing at all.
In fact it is so far from meaningful that I can
not guess how to fix it.


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.





Re: List functions

2010-12-01 Thread Andy Wingo
Hi Hans,

On Wed 01 Dec 2010 17:28, Hans Aberg  writes:

> () x into (() x)

What is the meaning of this?

Did you mean

   () x into (map (lambda (f) (f x)) '())

?

Regards,

Andy
-- 
http://wingolog.org/



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  
rule f ...


Then, as one can define \() x -> f for thunks, also () x becomes  
available for evaluation. So the question is to bother giving it  
meaning. One possibility might be as a constant evaluation to itself  
() x = () for any argument.






Re: Help needed debugging segfault with Guile 1.8.7

2010-12-01 Thread Andy Wingo
On Tue 30 Nov 2010 20:56, Peter TB Brett  writes:

>  - An easily re-usable/embeddable and well-documented REPL, to aid
>developers in implementing a "Scheme Interaction Window" or similar
>in their apps.

This is surprisingly difficult to do. A traditional REPL is the bottom
of the main loop of an application (though "application" might be
stretching it); integrating it with other main loops is tricky.

Essentially you need threads. Either pthreads, which bring their own
issues ("what thread is calling my app??? I thought i didn't use
threads?"), coroutines (but since `read' is implemented in C, delimited
continuations that involve the readers are not resumable), or simulated
threads (for example, the gtk repl in guile-gnome that runs recursive
main loops inside soft port readers).

Dunno. Perhaps there are other interfaces that are less repl-like, but
still useful. Suggestions and patches are welcome :-)

>  - An high-level API for passing strings for evaluation, that reports
>back the results or error information in a way that's easy to deal
>with from C.

What would this API look like?

Andy
-- 
http://wingolog.org/



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) [sin, cos] where g x = \f -> f x
  -> [0.909297426825682,-0.416146836547142]
But when I try that similar constructs in Guile, I get problems with
evaluation.


Works for me

guile> (let ()
   (define (g x)(lambda (f)(f x)))
   (map (g 2) (list sin cos)))

(0.909297426825682 -0.416146836547142)

There are other ways to write it, but that
is the most direct translation of your Haskell
into Scheme.


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

I'm not sure when to use quote or list, here. Quote seems to work  
when the list is data, not a list of functions.


I realized the problem here: quote prevents evaluation in the list, so  
one gets symbols, not procedures. Using back-quote and comma works:

(let ()
(define (g x)(lambda (f)(f x)))
(map (g 2) `(,sin ,cos)))

Anyway, thanks, I now know what to fiddle around with.




Re: Generating compiled scm (.go) files as part of LilyPond build

2010-12-01 Thread Ian Hulin
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Andy,
On 29/11/10 21:17, Andy Wingo wrote:
> On Sat 27 Nov 2010 18:42, Ian Hulin  writes:
> 
>> Our long-term aim, when we are able to move to using Guile V2.0 as an
>> infrastructure, is to byte-compile as many of these as possible during
>> the Lily build using something like.
>> $ guile-tool compile 
>>--output-file=<.go file>
> 
> Ralf has promised to add Guile 2.0 support to automake, so this should
> be partly automated.
> 
>> At the moment, during Lily initialization we prefix the guile path
>> %load-path with /scm as this is where we keep all the
>> LilyPond-specific scm files.
> 
> There is also $GUILE_LOAD_COMPILED_PATH in 2.0, which you can set to the
> proper path in your $builddir... which, ummm, doesn't appear to be
> documented. Sorry about that. Want to patch our docs? :)

It doesn't appear to work using 1.9.13:
(PWD is /home/ian/lilypond)
i...@greebo$ echo $GUILE_LOAD_COMPILED_PATH/home/ian/lilypond/scm/out
i...@greebo$ ls $GUILE_LOAD_COMPILED_PATH
dummy.dep
i...@greebo$ guile-tools compile scm/lily-library.scm
wrote
`/home/ian/.cache/guile/ccache/2.0-0.S-LE-4/home/ian/lilypond/scm/lily-library.scm.go'
i...@greebo$

Cheers,
Ian

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJM9rxEAAoJEBqidDirZqASGEMIAJnbJDLwp/Gv/ORrEnyB+rSp
aG/Wa1UC6nrjcAPH2tJ8+410RGMHEDp5YWagSP37JEKBqH6sjJTpZ4cXbUaUyJCO
+Fktd04uL2yr48wZzi71fjUXJOjNSe0WtJ4DqokbJ75jESj1nNLmKkTr+OJhPBvU
Z18NejAWWT8Tsob8nIJfyPnfQQ7tB55aUsbjvF3VvcNCAJ59i/CS8JZ0dCHZPueW
ARHbzL8raLCLBk1/A9kNUpCy8Gl5pjOkBWe4WS2QJwY6ObWyAwLUrUPeW3U4sXYB
TB67DzKfNQTth7+xiB5+gQNHNLaQVSbjpaGy2Vlv9eL7p648p2OXSFULgGrKhZk=
=NNrA
-END PGP SIGNATURE-



Re: List functions

2010-12-01 Thread Keith Wright
> Cc: adams...@email.unc.edu, guile-user@gnu.org
> From: Hans Aberg 
> 
> 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 means

 first argument of apply should be a function
 but it is: sin, which is a symbol

> I'm not sure when to use quote or list, here.
> Quote seems to work when the list is data,
> not a list of functions.

It's the other way around; |quote| is a keyword
that means that the following is data.
If you want to make a list of anything other
than literal data, use |list|.

So '(sin cos) is data: a list of two symbols,
the same as (list 'sin 'cos).

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, to the two arguments, ie.
sin and cos, giving a list of functions.

> This normality only has to do with parser grammar
> implementation. If in the evaluation syntax f ...,
> and the binding syntax corresponding in Haskell to
> \... -> f, the two "..." use the same syntax, I can
> eliminate the "\". Then the evaluation syntax (f_1,
> ..., f_k) x becomes available. I could eliminate it
> semnatically or set it to what is common in math, if
> not too complicated.
> 
>  and () x into (() x), but I'm not sure if the
>  lists (f g) and () can be made acting as functions
>  this way.
> >
> > I have not only never seen the "normal syntax" in
> > use here, but I have no guess what it is supposed
> > to mean.  In Scheme "(() x)" means nothing at all.
> > In fact it is so far from meaningful that I can
> > not guess how to fix it.
> 
> 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 functions
to a single argument, and get a list of the
results of applying each function separately
to the same argument.

guile> 
(define (fmap fs x)
  (if (null? fs)
  '()
  (cons (apply (car fs) (list x))
(fmap (cdr fs) x) )))

guile> (fmap (list sin cos) 2)
(0.909297426825682 -0.416146836547142)

The only tricky part is that apply takes
a function and a list of arguments,
and so (list x) is a list of one argument.

   -- Keith



Re: Generating compiled scm (.go) files as part of LilyPond build

2010-12-01 Thread Andy Wingo
On Wed 01 Dec 2010 22:21, Ian Hulin  writes:

> i...@greebo$ guile-tools compile scm/lily-library.scm
> wrote
> `/home/ian/.cache/guile/ccache/2.0-0.S-LE-4/home/ian/lilypond/scm/lily-library.scm.go'

You will want to set the -o option, as in GCC. See guile-tools compile
--help.

Cheers,

Andy
-- 
http://wingolog.org/



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, to the two arguments, ie.
sin and cos, giving a list of functions.


The parse problem I have is that x y is function application x(y), and  
must be constructed as Guile (x y). But then what should (x, y) be  
constructed as? Here, x should never be applied to y. On the other  
hand, '(x y) will suspend evaluation of x an y, which should not happen.





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 means

   first argument of apply should be a function
   but it is: sin, which is a symbol


Yes, I realized this.


I'm not sure when to use quote or list, here.
Quote seems to work when the list is data,
not a list of functions.


It's the other way around; |quote| is a keyword
that means that the following is data.
If you want to make a list of anything other
than literal data, use |list|.

So '(sin cos) is data: a list of two symbols,
the same as (list 'sin 'cos).


Strictly speaking, they are, as you noted, symbols. Quote turns off  
further evaluation. If one should have a more normal evaluation model  
of tuples, perhaps one should use back-quote and commas (see below).



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, to the two arguments, ie.
sin and cos, giving a list of functions.


I build lists directly using the Guile C functions. However, I  
encountered an ambiguity in my implementation which has to do with the  
(x) = x property of tuples: both x y and (x, y) parsed as Guile (x y)  
= (list x y).


If one writes just (x_1, ..., x_k), what Guile object should one get?  
(x_1 ... x_k) may cause later evaluation, '(x_1 ... x_k) turns off  
evaluation of the arguments. So perhaps one should construct  
`(,x_1 ... ,x_k).



This normality only has to do with parser grammar
implementation. If in the evaluation syntax f ...,
and the binding syntax corresponding in Haskell to
\... -> f, the two "..." use the same syntax, I can
eliminate the "\". Then the evaluation syntax (f_1,
..., f_k) x becomes available. I could eliminate it
semnatically or set it to what is common in math, if
not too complicated.


and () x into (() x), but I'm not sure if the
lists (f g) and () can be made acting as functions
this way.


I have not only never seen the "normal syntax" in
use here, but I have no guess what it is supposed
to mean.  In Scheme "(() x)" means nothing at all.
In fact it is so far from meaningful that I can
not guess how to fix it.


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 functions
to a single argument, and get a list of the
results of applying each function separately
to the same argument.


Yes, and the first item of the list should not treat the following  
items as its arguments for an evaluation. It is a different data  
object than the Guile evaluation list.



guile>
(define (fmap fs x)
(if (null? fs)
'()
(cons (apply (car fs) (list x))
(fmap (cdr fs) x) )))

guile> (fmap (list sin cos) 2)
(0.909297426825682 -0.416146836547142)

The only tricky part is that apply takes
a function and a list of arguments,
and so (list x) is a list of one argument.


Thank you. I will try some different possibilities.




Re: fluid-let?

2010-12-01 Thread Marek Kubica
Hi,

On Wed, 01 Dec 2010 14:41:30 +0100
l...@gnu.org (Ludovic Courtès) wrote:

> > Is there a way to get fluid-let for Guile? Or something like
> > ?
> 
> Guile has fluids and ‘with-fluids’, which is similar to what you want
> (info "(guile) Fluids and Dynamic States").  It also has SRFI-39
> parameter objects (info "(guile) SRFI-39").

Oh, SRFI-39 looks exactly what I was looking for. Now my code looks way
better, more DSLish. Thanks a lot!

regards,
Marek



Does Guile have a curry form?

2010-12-01 Thread Marek Kubica
Hi,

Before I reinvent the wheel, does Guile have support for something
similar to Racket's curry/curryr or Pythons functools.partial, which
returns me a lambda with some arguments already pre-set?

regards,
Marek



GOOPS:Can I just overload "slot-set!" under #:virtual and let alone "slot-ref" ?

2010-12-01 Thread Nala Ginrut
Hi, everybody!
I got a question while I'm trying GOOPS, here is some example code pieces:
;;guile code
(define-class  ()
  (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!