Simplified slot access in goops

2008-11-27 Thread Maciek Godek
Hi, Below is a simple set of functions and macros to make the access to goops object properties easier: (use-modules (oop goops)) (use-syntax (ice-9 syncase)) (define-syntax let-alias (syntax-rules () ((_ ((id alias) ...) body ...) (let-syntax ((helper (syntax-rules ()

Re: Unspecified?

2008-11-14 Thread Maciek Godek
>> but I find it kinda surprising that these are not available >> by default in the system. > > They are not documented because they are not... specified. :-) Yeah, I get that :D > Actually, Guile defines `*unspecified*' and also provides > `unspecified?', so all you need to define is `specified

Unspecified?

2008-11-14 Thread Maciek Godek
Hey all yoh! Is there any "official" way to check whether or not a function returns a (specified) value? As I ran into the problem, I quickly came with a workaround: (define unspecified (if #f #t)) which allows to define the most basic predicates: (define (unspecified? x) (eq? x unspecified)) (def

Re: SOS: Simple Object System

2008-09-26 Thread Maciek Godek
2008/9/25 Clinton Ebadi <[EMAIL PROTECTED]>: >> No wonder -- lambda calculus is a formal system to express concepts >> and you can express practically anything in it. C was invented to program >> von Neumann machines, and both C++ and Java are derivatives of C. > > C predates Common Lisp and any Li

Re: SOS: Simple Object System

2008-09-25 Thread Maciek Godek
2008/9/25 David Séverin <[EMAIL PROTECTED]>: >> (or at least that's what the most people think. CLOS is rarely used >> compared to C++ and Java -- can you explain why?) > > also because people in command sometimes have fear to take their > responsability: here in Rio de Janeiro, 2 years ago, at PU

Re: SOS: Simple Object System

2008-09-24 Thread Maciek Godek
2008/9/24 Clinton Ebadi <[EMAIL PROTECTED]>: > >> The other is that in GOOPS a method is something >> different than what is commonly known in OOP, because >> a class doesn't know its methods (and furthermore, >> methods can be created at any time of program execution, >> not only during class defi

Re: SOS: Simple Object System

2008-09-24 Thread Maciek Godek
Thanks a lot for your all attention and clues. If it comes to GOOPS, I think it would be best to specify a well-defined C-level interface (for it would go with the spirit of guile). This is the one thing. The other is that in GOOPS a method is something different than what is commonly known in OO

SOS: Simple Object System

2008-09-13 Thread Maciek Godek
Hi, Using some hints you gave me, I've implemented a really tiny object system -- and I would like to know your opinion ("why it's still better to use goops" :D) The notation for defining classes is following (using example of a sphere): (define sphere (class '(x y radius) '((move (dx

set-pair!

2008-08-20 Thread Maciek Godek
Hi, I've been trying to write a function or macro that would work like this: (let ((a 0)(b 0)) (set-pair! '(a . b) '(1 . 2)) (cons a b)) ; => (1 . 2) I eventually wrote: (define (set-pair! pair values) (let ( (e (the-environment)) (a (car pair)) (d (cdr pair)) ) (local-eval `(

Re: References/locations

2008-08-18 Thread Maciek Godek
Clinton Ebadi: >> I've been thinking of implementing this "location" stuff >> as a smob, but you've got the point that it is (probably) >> impossible to implement the location system without >> redefining set! and define. > > You may want to read a few documents on functional programming to see >

Re: References/locations

2008-08-15 Thread Maciek Godek
Kjetil: > Well, here's a relatively clean way, I think: > > (define-macro (location name) > (define new-val (gensym)) > `(lambda (,new-val) > (set! ,name ,new-val))) > > (define old-set! set!) > > (define-macro (set! a b) > `(if (procedure? ,a) ;; Needs a better check. > (,a ,b)

Re: References/locations

2008-08-15 Thread Maciek Godek
Stephen Compall: > Actually, if you (use-syntax (ice-9 syncase)), you should be able to > define lexical symbol-macros that expand a single symbol, even in a > set! place, something like: > > (define v #(1 2 3)) > (define-syntax v1 > (lambda (stx) >(syntax-case stx () > (_ v I don't

Re: eval and exceptions

2008-08-13 Thread Maciek Godek
cedric cellier: > For the concern about malicious users I will address this later, when > and if eventually there will be any actual user :) OK, let me know how's the progress sometime, because I'm extremely interested in the topic >> I've been trying to address this problem by implementing a ne

Re: eval and exceptions

2008-08-11 Thread Maciek Godek
Cedric Cellier: > In the attempt to drastially reduce the work required for a little > project (a small wargame), I want to use guile to "box" the game engine > (that is to be) written in C. I also want the players GUI to be > connected to the game via sockets established by guile (15 lines of > c

Re: References/locations

2008-08-10 Thread Maciek Godek
Kjetil: >> Hi, >> it's me again, asking silly questions. > > Not at all, your questions are very good. :-) That's werid. Every time I write a post I've got the strange feeling that I'm thinking in the way that should be forbidden :) I can give you the background of this idea. I've been trying to

Re: Me no understand scoping

2008-08-10 Thread Maciek Godek
Hello Andy! >> [Neil] >>> 1. IMO this could be really beautifully done in GOOPS, by defining >>> custom metaclasses and slot types. >> >> I've been considering that, and I'm still having doubts. >> The main reason is that there's no documented way >> of accessing GOOPS objects from C (except from

Re: Me no understand scoping

2008-08-10 Thread Maciek Godek
2008/8/8 Neil Jerram <[EMAIL PROTECTED]>: >> The main reason is that there's no documented way >> of accessing GOOPS objects from C (except from using >> scm_c_eval_string etc.), or at least I couldn't find any >> documentation for that. > > Yes, that's a fair point. And one that keeps coming up.

References/locations

2008-08-07 Thread Maciek Godek
Hi, it's me again, asking silly questions. This time I would like to know if there's a simple way to store a reference to a variable in another variable -- say, an element of vector or hash table. I imagine this could look like this: (define v #(1 2 3)) (define v1 (vector-location v 1)) v1 : 2 (se

Re: Me no understand scoping

2008-08-02 Thread Maciek Godek
>> I'm currently working on a little project (in my spare time). [...] > > Many thanks for providing this description. The project looks fun, so > I hope it continues to go well. > > A few thoughts occurred to me when reading through. > > 1. IMO this could be really beautifully done in GOOPS, by d

Re: Me no understand scoping

2008-08-02 Thread Maciek Godek
> Time to trot out the tired old koan [1] ... > > " The venerable master Qc Na was walking with his student, Anton. Hoping to > prompt the master into a discussion, Anton said "Master, I have heard that > objects are a very good thing - is this true?" Qc Na looked pityingly at > his student and r

Re: What happened to the infix module?

2008-08-02 Thread Maciek Godek
Thien-Thi Nguyen wrote: > () "Maciek Godek" <[EMAIL PROTECTED]> > () Sat, 2 Aug 2008 14:10:24 +0200 > > http://gnuvola.org/software/guile/doc/Reading-Infix.html > Yet there's no such module in the repository. > What happened? > > Well, that docu

What happened to the infix module?

2008-08-02 Thread Maciek Godek
Browsing the web, I ran into the documentation of guile's ice-9 infix module: http://gnuvola.org/software/guile/doc/Reading-Infix.html Yet there's no such module in the repository. What happened? M.

Re: Me no understand scoping

2008-08-01 Thread Maciek Godek
2008/8/1 Clinton Ebadi <[EMAIL PROTECTED]>: > > module-define! MODULE NAME VALUE > > e.g. > (let ((foo 'bar)) > (module-define! (current-module) foo 5) > bar) > => 5 > > Issue: this will be a top level binding, but a solution using `eval' > would also produce a top level binding (as it executes t

Re: Me no understand scoping

2008-07-31 Thread Maciek Godek
>> Here comes another one: >> Suppose I want to define a variable, but I don't know its name >> -- it is contained in another variable. For example: >> (define a 'b) >> I want to assign a value to the symbol "contained" in a. >> (that would be b in this example). The problem is that "define" >> quo

Re: Me no understand scoping

2008-07-31 Thread Maciek Godek
Neil Jerram <[EMAIL PROTECTED]>: >> How to achieve this effect without using eval? >> (I've tried (+ . l) but it didn't work out) > > (apply + l) Correct :) Here comes another one: Suppose I want to define a variable, but I don't know its name -- it is contained in another variable. For example:

Re: Me no understand scoping

2008-07-30 Thread Maciek Godek
>> as for eval, it will always be there (in RnRS) > > EVAL has not been in every report. R4RS did not specify EVAL, nor did R3RS, > RRRS, RRS. The fact that R5RS does only proves the fact that they should have :) By the way I have a question (regarding not using eval). I want to pass the content

Re: Me no understand scoping

2008-07-30 Thread Maciek Godek
Clinton Ebadi: > `macroexpand-1' is helpful here -- (local-eval ,f env) is wrong. > > As a matter of style, you probably want to avoid local-eval as it will > have to be removed whenever Guile ends up with a faster compiler On the other hand, local-eval is explained in guile manual, while I could

Me no understand scoping

2008-07-29 Thread Maciek Godek
Hi, consider the following code (simple iteration construct invented mainly to cause naming conflict, as the function 'times' is already defined in guile) (define-macro (times n f) `(let ((env (the-environment))) (let loop ((i 0)) (if (< i ,n) (begin (local-ev

Re: What new libraries or functionality does Guile need?

2008-07-18 Thread Maciek Godek
>> Hi- > >> If you could ask someone to write a library or package a set of >> functionality for Guile that it doesn't currently have, what would it >> be? (My personal projects are near completion, and I may have some >> Saturdays free.) > > Bindings for OpenGL/GLU/GLUT would be great. They defin

Getting a type of a variable

2008-07-18 Thread Maciek Godek
Hello, I'm looking for an efficient way to check the type of an SCM variable. I imagine that I could write something like: (define (type? x) (cond ((integer? x) 'int) (cond ((real? x) 'double) ... ) and then convert guile symbol to C string, but that would be terribly inefficient. (I could als

Re: Closure?

2008-07-14 Thread Maciek Godek
>> This certainly looks like trashing global namespace >> (which isn't good in the long run) and doesn't allow you >> to have object handlers (like many variables referring >> to the same object) without additional quirks. >> > > It's just an example of what local-eval can > be good for. It's an ex

Re: Closure?

2008-07-14 Thread Maciek Godek
Kjetil S. Matheussen: > I think local-eval is necessary for making > a namespace system of the below type without having to use > codewalking macros to expand the bodies of functions: > > (define-namespace bank) > (def-bank sum 0) > (def-bank (add n) > (set! sum (+ n sum)) ;; Note that it's enoug

Re: Closure?

2008-07-13 Thread Maciek Godek
>> As the practise shows, although guile documentation says something >> different. In section 3.1.4.7 (A Shared Persistent Variable) >> >> "An important detail here is that the `get-balance' and `deposit' >> variables must be set up by `define'ing them at top level and then >> `set!'ing their valu

Re: Closure?

2008-07-12 Thread Maciek Godek
>> I don't actually get the line with c-display. >> Does it require any additional module? >> 'Cause it ain' workin' for me. >> (and besides what does it do? >> the remaining part works fine) >> > > Just ignore that one. c-display is just a debugging > function I forgot to remove. :-) OK, actually

Re: Closure?

2008-07-12 Thread Maciek Godek
> Hi Maciek, > > Just picking up another point from your original email. You may have > already worked this out, but just in case... OK, it's always good to say to much than not to say enough (at least if it comes to hacking ;]) >> Additionaly, it would be nice to see the possibility >> of expli

Re: Closure?

2008-07-11 Thread Maciek Godek
Kjetil S. Matheussen: > The function "local-eval" is probably what you want. > > I use local-eval a lot, it's one of the really really > nice features provided by Guile: > > > (define-macro (with env . code) > `(local-eval (quote (begin ,@code)) ,env)) > > > (define ++ > (let ((c 0)) >(c-dis

Re: Closure?

2008-07-11 Thread Maciek Godek
2008/7/11 Ludovic Courtès <[EMAIL PROTECTED]>: > "Maciek Godek" <[EMAIL PROTECTED]> writes: > >> I've been wondering if there's any way to recall >> (or get inside) an environment of a closure (= to >> directly access variables bound t

Closure?

2008-07-11 Thread Maciek Godek
7;t find anything in the documentation) tia4i (thanks in advance for implementation :) Maciek Godek

Passing C pointers through guile

2008-07-04 Thread Maciek Godek
Hi, is there any portable and recommended way for passing C pointers around in guile environment? I think of something like scm_to_ptr (analogous to scm_to_int etc.). Certainly such a value would be completely useless for the interpreter. One can achieve simillar functionality using the aforementio

guile-1.8/mingw bootstrap problem

2008-04-28 Thread Maciek Godek
hare/guile/1.8/ice-9 Could someone help me? Best regards Maciek Godek