dev-serveez
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dev-serveez] switching to guile


From: Martin Grabmueller
Subject: Re: [dev-serveez] switching to guile
Date: Wed, 03 Jan 2001 17:40:21 +0100

> From: "Raimund 'Raimi' Jacob" <address@hidden>
> Date: Tue, 2 Jan 2001 17:30:55 +0100 (CET)
> 
> i just had a look at the public guile c interface. i still dont have a
> good idea on how to provide serveez' functionality in a guile/scheme
> program.

To which documentation are you referring?

> guile is missing hashes as far as i can see. that makes it rater
> complicated. we need an elegant way to set named fields of a structure
> (in C) from something else (in scheme). Hashes were a good way.

Guile supports hash tables, but not the read syntax I implemented for
Sizzle.  Unfortunately, it is not easy to define such a read syntax in
Guile, because #{...}# is an additional read syntax for symbols.  A
solution would be to change Sizzle's hash syntax from #{bla => 1} to
#[bla => 1].

Internally, hash tables in Guile are implemented similar to Sizzle:
They are simply vectors with association lists as elements, and the
hash functions use hash values of the key objects to decide which
vector slot is to be used for storing/reading the key/value-pairs
from.

> a different way would be to use a list of name - value pairs (a hashmap
> without hash).

Such a `hashmap without hash' is called an association list (or alist
for short) in the Lisp world.

>                 but i am not sure how to do it in scheme. if a cell is
> (car, cdr), can it be a structure/scheme expression like
> 
> (define-server "foo-server1" "foo" (("bar", 100),
>                                     (("reply", "booo"))))
>                                     
> the function "define-server" defines a server of the "foo" type and calls
> it "foo-server1". The new foo server is configured with bar => 100
> (int) and reply => boo (string). the 3rd argument to define-server is a
> list. each car contains a pair with car=name and cdr=value. the cdr
> contains a list of the same format.

A schemey way to do this would be to create a server object with a
procedures like `make-server' (or similar name), bind it to a variable
name and then register it with Serveez:

(define foo-server (make-server 'foo "foo-server1" '((bar . 100)
                    (reply . "booo"))))
(register-server! foo-server)

Another approach would be to fold in creation/registration into one
procedure, since there would not be much use of server objects without
makeing them known to Serveez.  Additionally, one could use keywords
for preventing the creation calls from being cluttered up with
parentheses.

(register-server! #:type 'foo #:name "foo-server1" #:bar 100 #:reply "booo")

> what is the correct syntax for such a constructor in guile ? (mgrabmue?)

Constructors are usually called like `make-vector', `make-string' etc.
It is rather trivial to implement a procedure like the
`register-server!'  above in Guile.  We would have to initialize the
Guile library, register the required procedures, maybe create required
data types, and source in the configuration file.  The
`register-server!' procedure will then verify its parameters and
either create the specified servers or fill in the configuration
structures you invented (and which I have not yet understood).

> do you think it is practical? there are quite a lot of parenthesises. or
> does anyone (mgrabmue) want to implement hashes for guile? with a
> syntax as convenient as the one of sizzle is ?

See above.

> any suggestions ?

Well, I like the more Scheme-like approach I sketched out in this
post, but probably you would rather like to stick to the old syntax of
Sizzle and the hashes.  Tell me what you think about this stuff, and
maybe we can come up with a solution.  Of course, there is still the
problem with Guile on Windoze.

'mgrabmue

-- 
Martin Grabmueller              address@hidden
http://www.pintus.de/mgrabmue/  address@hidden on EFnet



reply via email to

[Prev in Thread] Current Thread [Next in Thread]