Re: [Chicken-users] DBI

2008-04-06 Thread Ozzi

The status is I'm lazy and haven't done much of anything.

I did take a brief look at OpenDBX:

http://www.linuxnetworks.de/doc/index.php/OpenDBX

Perhaps we'd be better off wrapping this than writing our own wrapper for each 
DB? Thoughts anyone?


Matthew Welland wrote:

What is the status of this effort?

I have written a *very* simplistic DBI which supports lowest common 
demoninator access to sqlite3 and postgresql. It is only 90 or so lines of 
code but so far seems enough to let me write for sqlite and switch to 
postgresql etc.


I'd be interested in making this into an egg if anyone thought it'd be 
useful to them but I don't want where we have multiple solutions to the 
same problem on the eggs page  so I'll pass if the "real" dbi is coming to 
market any time soon.


Let me know, eggify or put on snippets or wait for real dbi? Also, if I did 
make it an egg what to call it? sdbi for simple dbi?
 
;;

;; sqlite3 example simple test code for
;;
(use sqlite3)
(system "rm -f tests/test.db")
(load "mrwdbi.scm")
(dbi:open 'sqlite3 '((dbname . "tests/test.db")))
(dbi:exec db "CREATE TABLE foo(id INTEGER PRIMARY KEY,name TEXT);")
(dbi:exec db "INSERT INTO foo(name) VALUES(?);" "Matt")
(dbi:for-each-row 
 (lambda (tuple)

   (print (vector-ref tuple 0) " " (vector-ref tuple 1)))
 db "SELECT * FROM foo;")
(dbi:close db)
(system "rm -f tests/test.db")

;;
;; postgresql simple test code
;;
(system "dropdb test")
(system "createdb test")
(use postgresql)
(load "mrwdbi.scm")
(define db (dbi:open 'pg '((dbname   . "test")
  (user . "matt")
  (password . "**")
  (host . "localhost"
(dbi:exec db "CREATE TABLE foo(id SERIAL  PRIMARY KEY,name TEXT);")
(dbi:exec db "INSERT INTO foo(name) VALUES(?);" "Matt")
(dbi:for-each-row 
 (lambda (tuple)

   (print (vector-ref tuple 0) " " (vector-ref tuple 1)))
 db "SELECT * FROM foo;")
(dbi:close db)
(system "dropdb test")


On Saturday 01 March 2008 10:26:45 am Vincent Manis wrote:

On 2008 Feb 29, at 23:13, Alex Shinn wrote:

However, different backends represent
this (and various other extensions we'll eventually want) in
different ways.  SQL could just generate a standard syntax
that all the backends would have to support, but then they'd
be reparsing the SQL string we just generated and then
putting it back together in their own way.  It makes more
sense to integrate the SQL generation with the backends from
the start.

This all sounds uncomfortably like ODBC to me. I would not
use a module like that, but would use a DBI-like module,
for the reasons we discussed a couple of days ago: prototyping,
relatively quick-and-dirty applications, and teaching.

A caution against overengineering isn't out of place here.
What is the problem this high-level API is trying to solve?

-- vincent


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users







___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] New immediate values

2008-02-29 Thread Ozzi Lee
I don't see that anyone's mentioned the existing sql-null egg yet. Is 
there anything wrong with it?


http://chicken.wiki.br/sql-null

Graham Fawcett wrote:

On Fri, Feb 29, 2008 at 2:57 PM, Tobia Conforto <[EMAIL PROTECTED]> wrote:

So, to recap:


Perfect recap! :-)


(define-record-type sql-null (sql-null) sql-null?)

 Not too bad.  Any piece of code could create null values with (sql-
 null), even in different compilation units.  People would just have to
 remember to use (sql-null? x) instead of eq?.  The API could state
 that eq? on two sql-null values is undefined.


True. I suspect there will be slightly more overhead here than with
using an immediate, perhaps noticeably on large queries. Ideally
(sql-null) would be a closure that constantly returned the same
instance, while (sql-null?) was just a record predicate, as in your
example.

I *believe* that if multiple modules include (define-record sql-null
...), that the predicates will work across definitions. E.g. if your
module defines a sql-null record, and mine does too, then instances of
your type will satisfy my predicate, as long as the type-names match.
This is *ugly*, but it would be better than forcing each db egg to
dynamically link to some "sql-null egg".

This is not a terrible answer for the sql API, though perhaps more
terrible for other APIs, and I don't think it would be bad to solve
both problems at once (the sql-null, and the well-intentioned 'abuse'
of (void) in current eggs).


A new immediate value

 IMHO the best option, and it could be useful for other APIs too, but
 if Felix says no he's probably right.


My preference by far, too.

Thanks for this summary, Tobia,
Graham


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: argument against using '() for null values? ([Chicken-users] DBI)

2008-02-27 Thread Ozzi

Vectors are currently used in the Postgres egg to represent date-time
values. Not saying it's good, but there it is. (BTW, a dbapi needs
consistent date/time support too...)

In Common Lisp, NIL is the same as '(), and both mean "false". In
Scheme we have an explicit #f. For the same reasons we should have an
explicit #. It is important that (sql-null? (sql-null)) is
#t, and (sql-null? anything-else) is #f.


 Since SQL NULL values are common, I really like the simple null? test. It's 
intuitive.


How is (sql-null?) harder or less intuitive?


It's not harder, but not being able to use null? to test for NULL is 
counterintuitive in my eyes.


Count me as on the fence I guess, between null void and sql-null.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: argument against using '() for null values? ([Chicken-users] DBI)

2008-02-27 Thread Ozzi

Three that I can think of:

1) It would make alist representations ugly:
(query "select foo, NULL as bar, baz from stuff") =>
((foo . 1) (bar) (baz . "a string"))


This doesn't bother me.


2) It is not a disjoint type. (list? '()) => #t. That's bad.

3) As a special case of (2), some databases have array-type columns.
An empty list may be a valid column value.


All right, there's the big problem.

How about keeping '() for sql NULL, and using vectors to represent array-type 
columns?


Since SQL NULL values are common, I really like the simple null? test. It's 
intuitive.


On the other hand, I didn't even know array-type columns existed until tonight. 
I'd prefer to go with something slightly less intuitive for representing them if 
it will let us use '() for NULL.


Thoughts?


Personally, I'm okay with (void), though Vincent's comment about
displaying results is a good one. I think the only logical alternative
to (void) is a # value, similar in implementation to
#: a disjoint type plus a predicate. (Currently that's how
the postgresql egg handles it.)

Graham



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: argument against using '() for null values? ([Chicken-users] DBI)

2008-02-27 Thread Ozzi

I suggest that a row be an a-list, and that null columns be represented
by being non-existent in the a-list.  If you end up preferring a plain
list or a vector, then use (void) instead -- I am trying to get this
standardized as the Chicken representation of SQL's NULL.


Is there an argument against using '() instead of (void) SQL NULL values?


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: void as a return value (Re: [Chicken-users] DBI)

2008-02-27 Thread Ozzi


Vincent Manis wrote:

\begin{rant}
On the subject of using void as a return value (rather than to indicate 
that

a function or method doesn't return anything), E.

Please, please, don't ever write functions that return void as anything 
other

than an indication that no value was returned.

#;44> (car (db-fetch-row (db-query "select salary where empname='Bilbo 
Baggins'")))

#;45>


I don't yet have an opinion on using void, but this function would return either

a list: ( (void) )
or an alist: ( (salary . (void) )

depending on which we used to represent rows. Either way, there would indeed be 
a return value.


So now, (a) you get no output, which might be mystifying and (b) car is 
now returning
void. Neither of these violates any language rule, but each violates the 
Law of

Least Astonishment.

For SQL nulls, one could use '(), as has been mentioned; alternatively, 
an object
called the-SQL-null-object could be created (perhaps as a record type 
value).


Incidentally, there are several different meanings for null in SQL, 
including no
information, not applicable, no value presently exists (but one might in 
the future),
etc. You can find lengthy essays on the appropriateness of using NULL in 
several
of Chris Date's `Writings on Database' books. People have enough trouble 
understanding
SQL null without further conflating it with `this function returns no 
values'.


\end{rant}

Sorry :-) -- vincent


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] DBI

2008-02-27 Thread Ozzi Lee

Jeremy Sydik wrote:
I've been working a little in the same vein, but it's still pretty tied 
to a specific project
My needs are pretty light, but I'm finding that the most useful 
functions seem to be


sql:query-list
and
sql:query-alist

I started out thinking in terms of Perl/Python type DBI, but I'm 
questioning that now.  I'd like
 to see a lightweight layer that means I don't have to remember as many 
specifics of the
 specific DB egg -- I agree with John that, most of the time, plugging 
in multiple DBs isn't
 that relevant.  I have one project that does it, but it uses such basic 
SQL-92 that I'm getting
 away with supporting multiple DBs.  In terms of staying lightweight, 


Agreed, light weight is my goal as well.


I'd like to look at the
suggested functions:

dbi:connect => I'm currently doing this as individual 
(driver:get-connection)'s that produce
a function that takes a message to support the rest of the dbi.  
This seems like a potential

win


I'm not sure I understand. Do you mean having functions like the following:

dbi:connect-mysql
dbi:connect-postgresql

and etc?

dbi:query => like I mentioned above, I'm using query-list and 
query-alist.  I also see value for
query-vector, but haven't done much with it.  The question is, would 
we be better having
individual functions or a single dbi:query that takes a (defaulted) 
argument that specifies

the output?


I'd like to have a single representation for a row, myself, so we can 
just have query return whatever we decide that should be, unless there 
are compelling reasons to have multiple output formats. Perhaps there 
are performance issues of alists vs lists vs vectors that would come 
into play? I have no idea.



dbi:num-rows => I've found that I almost always end up using (length) 
instead.  Probably not

optimal, but I've not had a major problem here.
dbi:fetch-row => I've not used this either, but I'm usually pushing my 
queried list into a for-each

or a map.  the question is, what is our specific use case?


num-rows and fetch are actually there to support an implementation of 
representing query results as Streams that I'm considering, mostly.


dbi:query-fold, dbi:query-map, query-for-each.  I thought about 
implementing these, but I
haven't been able to think of the use case that makes them necessary 
in the presence
Scheme's fold, map, and for-each, other than as shorthand (which 
could be define'd

in place in a heartbeat for anyone who wants it)


These would be here for performance. To use the Scheme map function, we 
have to build up a list of all the resulting rows first. With a 
dbi:query-map function, we wouldn't.


This is the also the same reason I was thinking about a Stream 
implementation. If that ended up being workable we wouldn't need these.


dbi:insert-id  Should this come from a function, or should it be 
returned as a response to
dbi:query?  I wouldn't mind seeing the query handler be smart enough 
that if my query
involves INSERT and i've inserted a row that becomes ID 42, that the 
response would
be something like '((rows-affected 1) (insert-id 42)) Certainly, 
we'd want to look at what

we'd want to normalize these labels to, but that's not a huge issue.

The related question is whether singleton response values (like 
rows-affected with
nothing else) should return as a singleton (a)list or as a numeric 
value --> My vote would
be to return the singleton (a)list  to simplify the conditional 
checking the caller needs

to use.



I'll add this to the open questions on the Wiki, I'm not sure what we 
should do about return values in general.



This leaves
(dbi:connect driver-proc [[connection params]])
In my case, I'm using SRFI-89 style define* for named params and 
defaults.  What do

other people think of this approach?
(dbi:query conn str [[output type option?]])  With alist, the output 
type option probably isn't
that important depending on how NULL is handled.  It might also be 
nice to make query
smart enough to give sensible responses for non SELECT queries, so 
we'd need to

decide what the alist-names for these should look like
Is this over-simplified?

Row representation.  I think my preference would be using alists as the 
the representation
Thinking about it, Scheme already gives us everything we need to get 
value lists, vectors,
and hash-tables if we start from alists, so it seems like the better 
choice.


Agreed.

I've tended to let null be '(), but that partly comes from liking the 
look of
(null? (alist-ref 'field result))  I'm not entirely comfortable with 
leaving the

value entirely absent simply because the mapping I mention to value
lists and vectors becomes more problematic.  That said, my usage of
value lists and vectors is limited enough that I'm not that tied to it 
either.


That's true, conversion to other representations from the alist will 
have to be considered.



___

Re: [Chicken-users] DBI

2008-02-27 Thread Ozzi Lee

I suggest that a row be an a-list, and that null columns be represented
by being non-existent in the a-list.  If you end up preferring a plain
list or a vector, then use (void) instead -- I am trying to get this
standardized as the Chicken representation of SQL's NULL.


I like a-lists as rows for well. I'm not sure about null columns not 
existing, I think I like it but I guess I'd have to think about/play 
with it. Otherwise I agree (void) is probably a good idea.



In reality, though, I think portability between databases is more
hypothetical than real.  Projects typically start with one database and
stick to it, for moving between databases *even if a portability layer
is in use* turns out to be hard -- all sorts of stuff outside the main
code base ends up changing (path names, load scripts, whatever).


I agree that portability isn't that great in practice. I'd like to see a 
DBI egg for two reasons:


1. Starting out on a project, 90% of the time I'll use SQLite, because 
it's the easiest. Often I'll want to switch to MySQL once things get 
rolling. A single DBI interface makes this quite a bit easier.


2. For quick and dirty scripts that need to access a database, it would 
be nice to have to keep in the differences between the different interfaces.


I would like for a DBI egg itself to be as agnostic as possible. SQL 
implementation issues (DBI won't mess with SQL at all) and outside 
scripts aside, do you know of any incompatibilities that would affect this?



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] DBI

2008-02-27 Thread Ozzi Lee
Has anyone looked into creating a DBI egg yet? I started a wiki page 
with the barest outline of a proposal for one:


http://chicken.wiki.br/dbi

Let me know what you think. If someone's already got something going I'd 
like to pitch in as well.



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] nondescript eggs

2008-02-24 Thread Ozzi

Guilty.

I've committed my statvfs and filesystem eggs. Whatever svn-fu I may have once 
had is rusty. Can I just svn mv them into releases/3? Not sure I even have 
permissions for that...


WHAT DO I DO NOW?!?? :-)



(sorry for the dupe Felix, forgot to hit "Reply All" the first time)

Felix Winkelmann wrote:

Hello!

The following eggs have currently no ".meta" file and seem to
be in a state of flux, or have not been implemented yet
(but are registered in the repository:

* binary-tree/
* dns/
* filesystem/
* gl-display-glx/
* gl-font/
* libapreq-mfd-parser/
* meroonet/
* methods/
* minioop/
* scoop/
* sockets/
* statvfs/
* swt/
* wxchicken/

These have been moved into the "nondescript" branch and can be
accessed as usual (the permissions will be updated accordingly).
Whoever is working on these, please consider moving them into
the release/3 branch later, once you think they are ready for
being made available.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Playing with ideas for a chicken website

2008-02-20 Thread Ozzi
Just playing around with some ideas I had for a Chicken website, figured I might 
as well post them up and let everyone see what I wasted a couple of hours on 
tonight :-)


Be warned, the javascript crashed Firefox here on OS X a few times. I built it 
in Safari, works fine there.


http://ozzilee.com/chicken_mockup/


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] sqlite3 wtf

2008-02-18 Thread Ozzi

Upgrading to sqlite 3.5.6 on the linux box seems to have fixed it.

Ozzi wrote:
The sqlite3 egg seems to have issues on Dreamhost (Linux). Works fine on 
OS X here.


;; Works fine...
(sqlite3:prepare (sqlite3:open "db.sqlite3") "select * from foo")

;; but do the same thing again...
(sqlite3:prepare (sqlite3:open "db.sqlite3") "select * from foo")

;; and get a weird error!
Error: (sqlite3:prepare) unrecognized token: "@"
#
"select * from foo"

Call history:

(sqlite3:prepare (sqlite3:open 
"db.sqlite3") "select * from foo")

(sqlite3:open "db.sqlite3")
  (sqlite3:prepare (sqlite3:open "db.sqlite3") 
"select * from foo")

  (sqlite3:open "db.sqlite3") <--


Anybody have an idea where to start on this one?

Chicken 2.740 on both machines. Reinstalled all the eggs on Dreamhost, 
no change.


Ozzi


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] sqlite3 wtf

2008-02-17 Thread Ozzi

The sqlite3 egg seems to have issues on Dreamhost (Linux). Works fine on OS X 
here.

;; Works fine...
(sqlite3:prepare (sqlite3:open "db.sqlite3") "select * from foo")

;; but do the same thing again...
(sqlite3:prepare (sqlite3:open "db.sqlite3") "select * from foo")

;; and get a weird error!
Error: (sqlite3:prepare) unrecognized token: "@"
#
"select * from foo"

Call history:

(sqlite3:prepare (sqlite3:open "db.sqlite3") 
"select * from foo")

(sqlite3:open "db.sqlite3")
  (sqlite3:prepare (sqlite3:open "db.sqlite3") "select * 
from foo")

  (sqlite3:open "db.sqlite3") <--


Anybody have an idea where to start on this one?

Chicken 2.740 on both machines. Reinstalled all the eggs on Dreamhost, no 
change.

Ozzi


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] domain query

2008-02-16 Thread Ozzi

> Perhaps we should also add a more inviting home-page. Maybe some photos
> of managers and developers smiling at a table, shaking hands. With
> everyone wearing nice suits.

I'm on board with cleaning up the web site(s). No suits.

> BTW, how are we paying for this suff? It's nice to have a volunteer to
> pick up the tab, but many of us probably would be happy to support the
> effort. Felix and Toby have done us all a great service (also the
> Galinha folks, but I assume there are public funds supporting the wiki
> site?), we should nurture a little fund to cover some of their costs.

I'd also be happy to toss some change into the chicken bucket.


Graham Fawcett wrote:
On Feb 16, 2008 3:53 PM, Toby Butzon <[EMAIL PROTECTED] 
> wrote:


+1 chickenscheme.org  for me too.


+1 from me too.

I like cleverness of call-with-current-continuation.org 
. But it seems as if Chicken 
is growing up, and a boring-but-descriptive domain name is a good idea 
to welcome and retain new visitors.


Perhaps we should also add a more inviting home-page. Maybe some photos 
of managers and developers smiling at a table, shaking hands. With 
everyone wearing nice suits.


(OK, maybe not suits. Or managers. Shaking hands may also be overkill.)





For a .org, I might be able to get some hosting at our university. If 
anyone's interested, I'll ask and find out.


Graham




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] domain query

2008-02-16 Thread Ozzi

I'll cast my ballot for chickenscheme as well.

Elf wrote:


as it comes around time to do my yearly domain registrations (not involving
chicken), i happened to notice that many chicken-based domain names are
not currently taken, like chickenscheme.org/net/com, 
chicken-scheme.org/net/com,

schemechicken.org/net/com, etc etc etc.

two questions:

a) do a majority of people want Yet Another set of domains for chicken?
b) if a, what does the majority want to register?


-elf



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] egg documentation

2008-02-12 Thread Ozzi

The whole point of the note on the wiki was that we need _one_ documentation
system.  The current system sucks, because you keep switching interfaces.
Say you're looking for some documentation, so you search using the wiki
system.  However, the docs you're looking for happen to be written in eggdoc
or the legacy HTML documentation.  Besides not being able to search these
docs, when you visit them, you go to another site and you lose the
navigational tools you get in the wiki.


Fair enough. I agree that one method would be best.


Visually it's also confusing, because the three docs look different.  This
last point might sound trivial, but I'm sure when a potential new user is
browsing for a new scheme implementation, he's might get scared away just
because he has no idea why some docs are on this site, some on that and why
they look and act differently.  I know Chicken is a "hacker's scheme", but
there's no point in alienating people.


This I agree with 100%. I still haven't figured out why Chicken seems to be 
spread across three different sites.


http://galinha.ucpel.tche.br
http://chicken.wiki.br
http://www.call-with-current-continuation.org/

> Why do you want to make a distinction?

The idea I was trying to get at was something like a "standard library" for 
Chicken. When I go to the "Eggs Unlimited" page right now, there are lots and 
lots of eggs, which is great, except there's no easy way to tell what's 
standard-issue Scheming and what's more exotic stuff.


It would be great if there were a set of eggs that were considered to be a 
standard part of Chicken, to help people who haven't been writing Scheme code 
for years get oriented. Python and Ruby have lots of standard functionality 
built in, but with Chicken you have to hunt down each egg you need. I think a 
standard library of sorts would help.


I also believe it would help to focus development. If a consensus could be 
reached as to what kind of functionality should be included in a reasonably 
complete standard library for a useful language, then we could easily go about 
implementing that functionality. A standard library would provide a smaller 
target than the current wide-open universe of eggs.


So these are my ideas, and I'll admit they probably don't have much to do with 
documentation per se, but that's just what happened to convince me to write them 
down.



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] egg documentation

2008-02-12 Thread Ozzi
This is perhaps a different concern, but I wonder if there would be value in 
designating certain eggs as "part of" Chicken, and holding these eggs to a 
stricter standard of documentation.


For example, most (all?) of the SRFIs could be considered canon. I'd imagine 
Spiffy would as well, along with many other eggs.


Something like ode, a "numerical solver framework for systems of first-order 
differential equations", on the other hand, probably wouldn't.


This distinction would allow us to dictate, for example, that all documentation 
for the eggs which are a part of Chicken has to be written in a certain style 
and available in a certain place, without messing with libraries that are made 
available as eggs but aren't really designed as a part of Chicken itself.




Oz

Graham Fawcett wrote:

Ivan raised a good point on the Hackathon1 page (where he asks that
people don't move his egg documentation out of the egg and into the
wiki, because it's a pain to deal with eggs that don't have a copy of
their docs in the egg directory itself).

It's good to have the wiki docs, and especially so with Toby's
excellent callcc.org site as a search interface. But it doesn't
address "local" documentation very well. We've done some work on
wiki->texi conversion, which is good, but it's not integrated with
chicken-setup in any way, and that's a drawback.

One can imagine pushing local docs into the wiki upon releasing a new
egg version; or adding an "include" mechanism to the wiki to pull in
external docs (though that would make search-indexing harder if not
done properly). Since the wiki is stored in the svn repository, there
are opportunities for svn-commit hooks to do some of the work, as well
as opportunities for a decent inclusion mechanism.

Before we venture too far into 'wikifying' all of the egg
documentation, if that's a hackathon goal, we should probably ensure
that we have a consistent documentation plan that ensures a local copy
of the docs is preserved in some form.

Personally, I'd love to have texi documentation, and (optionally) have
chicken-setup do the necessary work to pull egg docs into the 'info'
system. I'd never have to leave Emacs to look something up, and that
would (for me) be more efficient than keeping a callcc.org browser
open.

Graham


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Two Eggs & Repo Access

2008-01-15 Thread Ozzi

I've written two eggs. Comments are appreciated.

I'd like access to the SVN repo as well, to release them. Username: ozzilee.


statvfs
---

A simple wrapper the statvfs system call, returns a vector of filesystem 
information. Tested on Debian and OS X.


Exports:
statvfs


filesystem
--

Wraps statvfs so for now Posix-only, but could be extended to work on other 
systems without statvfs.


Exports:
filesystem:block-size
filesystem:blocks-total
filesystem:blocks-free
filesystem:blocks-available

blocks->bytes
Takes a blocksize and a multiplier, i.e. 1000 for kilobytes.

blocks->kilobytes
Takes a blocksize and an exponent, 1 for kilobytes, 2 for megabytes. 1000-based.

blocks->kibibytes
Takes a blocksize and an exponent, 1 for kibibytes, 2 for mebibytes. 1024-based.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Adding (system->string) somewhere

2008-01-14 Thread Ozzi
Yes, that egg was pointed out to me. It's a neat egg, but I feel more 
complicated than necessary 9 times out of 10.


Ivan Raikov wrote:

Hello,

  If I understand this description correctly, the runcmd egg has this
functionality. Take a look at its documentation and see if it would
work for you.

   -Ivan


Ozzi <[EMAIL PROTECTED]> writes:


Could we get something akin to (system->string) added to Chicken
somewhere? Summary from:

http://practical-scheme.net/wiliki/schemexref.cgi?system-%3estring

"Appends all strings, then calls the result string as a command, and
collects the output from the command into a string to be returned. See
system."

I am using the following code, which just takes a single string:

(define (system->string cmd)
  (string-chomp (with-input-from-pipe cmd read-all)))

Either the library or posix units look like good candidates to me.




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Adding (system->string) somewhere

2008-01-10 Thread Ozzi
Could we get something akin to (system->string) added to Chicken somewhere? 
Summary from:


http://practical-scheme.net/wiliki/schemexref.cgi?system-%3estring

"Appends all strings, then calls the result string as a command, and collects 
the output from the command into a string to be returned. See system."


I am using the following code, which just takes a single string:

(define (system->string cmd)
  (string-chomp (with-input-from-pipe cmd read-all)))

Either the library or posix units look like good candidates to me.


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Event Scheduling?

2008-01-03 Thread Ozzi
I'm looking to write a daemon that will periodically poll a HTTP server. Is 
there an event scheduling egg out there somewhere? If not, does anyone have an 
opinion on how best to implement such a thing?


I've considered using set-alarm! or thread-sleep!, or perhaps porting TIMER 
(http://www.xach.com/lisp/timer/doc.html)


Thoughts?

Thanks,

Oz



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] r5rs url help

2008-01-03 Thread Ozzi
Just replace the % with %25. That's what safari shows in the location bar when 
you visit one of the links. There's probably an Objective-C function somewhere 
to do URL encoding, you should probably use that.


See Also:
http://en.wikipedia.org/wiki/URL-encoding


Rick Taube wrote:
i have a slightly-off-chicken problem that Im hoping someone on this 
list can help me solve. I have a Scheme code editor and im trying to 
implement symbol help lookup for r5rs scheme symbols. The basic idea is 
that you put your mouse on a r5rs symbol, type Command-? and then the 
r5rs doc for that symbol should pop up in your default browser. It all 
works except for the fact that -- at least on the the Mac -- trying to 
open Scheme's r5rs document at specific html #index locations fails 
because all r5rs #indexes start with '%'  which causes the url opening 
to fail!  Ive traced this to the to fact that the % char apparently 
screws up the Open command. For example if you type this open command in 
a Terminal:


galen:/Lisp/grace hkt$   open 
'http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_idx_630' 



You get the error:

008-01-03 11:06:08.086 open[1708] No such file: 
/Lisp/grace/http:/www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_idx_630 



Ive tried various sorts of quoting on the url string, tried replacing 
'%' with '&37;' but nothing seems works. does anyone know how I can 
defeat the '%' character expansion so I can call a browser with urls 
with indexes like  %_idx_630  in them?


thanks for any info or ideas...
rick










___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] PyFFI

2007-12-30 Thread Ozzi

That fixed it for 2.3.4.

When I changed pyflags to:

(define pyflags
  (map cons (list "-I/opt/local/Library/Frameworks/Python.framework/Headers 
-F/opt/local/Library/Frameworks/") (list  "-framework Python")))


it wouldn't compile until I removed the #if directives around the definition of 
DecRef and IntRef in pyffi-support.scm.


Now it compiles, but running

(use pyffi) (py-start) (py-import "sys") (py-eval "sys.version")

still gives me 2.3.5.

Do you know how to get it to compile and run against my MacPorts version of 
Python?

Thanks for the help. Hopefully this will benefit others besides myself as well.

Oz


Ivan Raikov wrote:

  Well, I just discovered that on the Mac system I was testing pyffi
on, there is both Python 2.3.5 and 2.4, and even though python -V
returns 2.3.5, the "-framework Python" option causes the pyffi library
to be linked with Python 2.4. I have created a new version of pyffi
that provides its own definitions of DecRef/IncRef when used with
Python 2.3. Please check the Eggs Unlimited page to see when pyffi 2.5
is available, and try it again.

   -Ivan

Ozzi <[EMAIL PROTECTED]> writes:


Yeah, python's 2.3.5.


chicken-setup output follows.

Thanks for the help.




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] PyFFI

2007-12-28 Thread Ozzi

Yeah, python's 2.3.5.


chicken-setup output follows.

Thanks for the help.



downloading catalog ...
downloading catalog from www.call-with-current-continuation.org ...
GET /eggs/repository HTTP/1.0
Host: www.call-with-current-continuation.org
Connection: close
Content-length: 0

HTTP/1.1 200 OK
Date: Sat, 29 Dec 2007 02:44:46 GMT
Server: Apache/1.3.37
Last-Modified: Sat, 29 Dec 2007 02:18:29 GMT
ETag: "3068d3-5d5b-4775ae75"
Accept-Ranges: bytes
Content-Length: 23899
Connection: close
Content-Type: text/plain

downloading pyffi.egg from (www.call-with-current-continuation.org eggs 80)
  creating directory `pyffi.egg-dir'
changing working directory to `pyffi.egg-dir'
  gzip -d -c ../pyffi.egg | tar xvf -
pyffi.meta
version
pyffi.scm
pyffi-eggdoc.scm
pyffi-support.scm
pyffi.setup
example.scm
swriter.scm
executing pyffi.setup ...
gcc  -I/System/Library/Frameworks/Python.framework/Headers -no-cpp-precomp 
-fno-strict-aliasing -fno-common -DHAVE_CHICKEN_CONFIG_H -Os 
-fomit-frame-pointer t1deb.c -L/usr/local/lib -framework Python -lm >/dev/null  ...

succeeded.
  /usr/local/bin/csc -feature compiling-extension -v -d2 -s -o pyffi-support.so 
-check-imports -emit-exports pyffi-support.exports pyffi-support.scm -L " 
-framework Python " -C " -I/System/Library/Frameworks/Python.framework/Headers " 
-X easyffi
/usr/local/bin/chicken pyffi-support.scm -output-file pyffi-support.c -dynamic 
-feature chicken-compile-shared -quiet -feature compiling-extension -debug-level 
2 -check-imports -emit-exports pyffi-support.exports -extend easyffi

Warning: preprocessor conditional `~A' ignored (assuming false)
(pp-if open-paren open-paren (id "PY_MAJOR_VERSION") (op "==") (num 2) 
close-paren (op "&&") open-paren (id "PY_MINOR_VERSION") (op ">=") (num 5) 
close-paren close-paren)

Warning: preprocessor conditional `~A' ignored (assuming false)
(pp-if open-paren open-paren (id "PY_MAJOR_VERSION") (op "==") (num 2) 
close-paren (op "&&") open-paren (id "PY_MINOR_VERSION") (op ">=") (num 5) 
close-paren close-paren)

Warning: global variable `pytype-name' is never used
Warning: global variable `PyDict_Keys' is never used
Warning: global variable `PyDict_GetItem' is never used
Warning: global variable `PyImport_ImportModule' is never used
Warning: global variable `pytype-to-set!' is never used
Warning: local assignment to unused variable `*py-functions*' may be unintended
Warning: global variable `pytype-name-set!' is never used
Warning: global variable `PyDict_Size' is never used
Warning: global variable `pytype-from-set!' is never used
Warning: global variable `PyModule_GetDict' is never used
Warning: global variable `PyDict_GetItemString' is never used
Warning: global variable `PyErr_Occurred' is never used
Warning: global variable `PyObject_Str' is never used
Warning: global variable `PyImport_GetModuleDict' is never used
Warning: global variable `PyString_asString' is never used
Warning: global variable `pytype?' is never used
Warning: global variable `PyImport_Import' is never used
gcc pyffi-support.c -o pyffi-support.o -c -no-cpp-precomp -fno-strict-aliasing 
-fno-common -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fPIC -DPIC 
-DC_SHARED -I /usr/local/include 
-I/System/Library/Frameworks/Python.framework/Headers

pyffi-support.c: In function 'pyffi_PyUnicode_AsUnicode':
pyffi-support.c:32: warning: return from incompatible pointer type
pyffi-support.c: In function 'pyffi_PyUnicode_FromUnicode':
pyffi-support.c:36: warning: passing argument 1 of 'PyUnicodeUCS2_FromUnicode' 
from incompatible pointer type

rm pyffi-support.c
gcc pyffi-support.o -o pyffi-support.so -bundle -L/usr/local/lib -framework 
Python -lm -lchicken

/usr/bin/ld: Undefined symbols:
_Py_DecRef
_Py_IncRef
collect2: ld returned 1 exit status
*** Shell command terminated with exit status 1: gcc pyffi-support.o -o 
pyffi-support.so -bundle -L/usr/local/lib -framework Python -lm -lchicken

Error: shell invocation failed with non-zero return status
"/usr/local/bin/csc -feature compiling-extension -v -d2 -s -o pyffi-support.so 
...
256

Ivan Raikov wrote:

  Okay, can you give me the output of `chicken-setup -v pyffi`. And
just in case, what is the version of Python you have on your system?
Mine is Python 2.3.5. 


   -Ivan

Ozzi <[EMAIL PROTECTED]> writes:


No luck, still the same message.
Chicken 2.732, Apple Python.
Odd.




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] PyFFI

2007-12-28 Thread Ozzi

No luck, still the same message.
Chicken 2.732, Apple Python.
Odd.

Ivan Raikov wrote:

Hello,

  I have committed a new version of pyffi (2.4) that I have tested on
Mac OS with Chicken 2.739 and the standard Apple Python. Could you
please try and see if it works for you?

   -Ivan


Ozzi <[EMAIL PROTECTED]> writes:


I'm having some trouble install the PyFFI egg, does anyone have any pointers?
Chicken is 2.732, Mac OS X.

I get the same message when I hack the pyffi.setup file to use the
python I've installed from MacPorts.

Thanks,

oz



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] PyFFI

2007-12-18 Thread Ozzi

I'm having some trouble install the PyFFI egg, does anyone have any pointers?
Chicken is 2.732, Mac OS X.

I get the same message when I hack the pyffi.setup file to use the python I've 
installed from MacPorts.


Thanks,

oz

  /usr/local/bin/csc -feature compiling-extension -d2 -s -o pyffi-support.so 
-check-imports -emit-exports pyffi-support.exports pyffi-support.scm -L " 
-lpython " -C " -I/opt/local/include/python2.4 " -X easyffi

Warning: preprocessor conditional `~A' ignored (assuming false)
(pp-if open-paren open-paren (id "PY_MAJOR_VERSION") (op "==") (num 2) 
close-paren (op "&&") open-paren (id "PY_MINOR_VERSION") (op ">=") (num 5) 
close-paren close-paren)

Warning: preprocessor conditional `~A' ignored (assuming false)
(pp-if open-paren open-paren (id "PY_MAJOR_VERSION") (op "==") (num 2) 
close-paren (op "&&") open-paren (id "PY_MINOR_VERSION") (op ">=") (num 5) 
close-paren close-paren)

Warning: global variable `pytype-name' is never used
Warning: global variable `PyDict_Keys' is never used
Warning: global variable `PyDict_GetItem' is never used
Warning: global variable `PyImport_ImportModule' is never used
Warning: global variable `pytype-to-set!' is never used
Warning: local assignment to unused variable `*py-functions*' may be unintended
Warning: global variable `pytype-name-set!' is never used
Warning: global variable `PyDict_Size' is never used
Warning: global variable `pytype-from-set!' is never used
Warning: global variable `PyModule_GetDict' is never used
Warning: global variable `PyDict_GetItemString' is never used
Warning: global variable `PyErr_Occurred' is never used
Warning: global variable `PyObject_Str' is never used
Warning: global variable `PyImport_GetModuleDict' is never used
Warning: global variable `PyString_asString' is never used
Warning: global variable `pytype?' is never used
Warning: global variable `PyImport_Import' is never used
pyffi-support.c: In function 'pyffi_PyUnicode_AsUnicode':
pyffi-support.c:31: warning: return from incompatible pointer type
pyffi-support.c: In function 'pyffi_PyUnicode_FromUnicode':
pyffi-support.c:35: warning: passing argument 1 of 'PyUnicodeUCS2_FromUnicode' 
from incompatible pointer type

/usr/bin/ld: Undefined symbols:
_Py_DecRef
_Py_IncRef
collect2: ld returned 1 exit status
*** Shell command terminated with exit status 1: gcc pyffi-support.o -o 
pyffi-support.so -bundle -L/usr/local/lib -lpython -lm -lchicken

Error: shell invocation failed with non-zero return status
"/usr/local/bin/csc -feature compiling-extension -d2 -s -o pyffi-support.so 
-ch...
256


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Getting disk space

2007-12-18 Thread Ozzi

> Hi,
>
> Can anyone tell me how I can get available disk space from a chicken
> program.   I want the same results you get with df in linux.   If the
> answer is using process or open-input-pipe.etc. and actually running df
> please explain how this is done since I cannot get it to work no matter
> what I do.
> If there is a way of duplicating df in code - even in c - I would
> appreciate that as well.
>
> Bill

Below is the code I am using. Should work on at least Debian and OS X. It's my 
first adventure in FFI-land.


The df command basically wraps statfs. (statfs) will give you some of the same 
info df does in an alist. You'll have to do some math with the blocksize to get 
the size in useful units. Here are a couple functions I use:



(define (blocks-to-GiB blocksize blocks)
  (/ (round (* blocks (/ blocksize (expt 1024 3)) 10)) 10))

(define (blocks-to-GB blocksize blocks)
  (/ (round (* blocks (/ blocksize (expt 1000 3)) 10)) 10))


I'd love to see this wrapped up in an egg at some point, I just haven't the time 
to do it myself. If someone else wants to do it I'd be glad to help. I'm sure 
that it could be simplified/expanded/improved. I do know that there are some 
differences in the way BSD and Linux work on this, but I haven't dug into it 
very deeply. I got this working on OS X and Debian both, and it was good enough 
for me at the time.


Oz



(foreign-declare #<
#include 
#else
#include 
#endif
END
)

(define-foreign-record (statfs "struct statfs")
  (constructor: make-statfs)
  (destructor: free-statfs)
  (long f_bavail)
  (long f_blocks)
  (long f_bsize))

(define c-statfs
  (foreign-lambda int statfs c-string c-pointer))

(define (statfs)
  (let ((ptr (make-statfs)))
(c-statfs "/" ptr)
(let ((a `((f_bavail . ,(statfs-f_bavail ptr))
   (f_blocks . ,(statfs-f_blocks ptr))
   (f_bsize . ,(statfs-f_bsize ptr)
  (free-statfs ptr)
  a)))


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] RFC: Daemonize

2007-11-30 Thread Ozzi

Hans Bulfone wrote:

hi,

sorry for the late reply, i didn't have much time/energy for chicken
in the last few weeks :(


No problem, I'm in the same situtation.


i also wanted to create an egg from that code, along with some
syslog functions, but was to lazy to do it as yet :)

perhaps we should merge our code...


Actually, I think there's three eggs here.

Syslog: The syslog functions.

Daemon: Mostly a clone of C's or Perl's daemon() function. Could be a wrapper to 
the C function.


Daemonize: A more robust daemonization function/library that can take care of 
PID files, output redirection to log files, and anything else related to 
managing a daemon. It may include functionality from Syslog, if appropriate (I'm 
not sure right now). It should probably be named something other than Daemonize, 
though.


The Syslog and Daemon eggs might be best off merged into the Posix unit.


afaik daemon() already calls fork() so i don't think you'd really
need to call (process-fork) then.
otoh - daemon() is like my (daemon:ize) function above, it terminates
the parent process which means your api would change and it would no
longer be directly possible to fork multiple independent daemon processes
from a single master.


Indeed, it may be appropriate to have different functions for daemonizing the 
current processing and forking a new daemon process.




Let me know what you think about merging daemon and syslog into posix, if you 
agree we should see what everyone else thinks and go from there.


Oz


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] declare-foreign-record and typedefs

2007-11-29 Thread Ozzi

I would like to declare a foreign record for the following struct:

 struct statfs {
 short   f_otype;/* type of file system (reserved: zero) */
 short   f_oflags;   /* copy of mount flags (reserved: zero) */
 longf_bsize;/* fundamental file system block size */
 longf_iosize;   /* optimal transfer block size */
 longf_blocks;   /* total data blocks in file system */
 longf_bfree;/* free blocks in fs */
 longf_bavail;   /* free blocks avail to non-superuser */
 longf_files;/* total file nodes in file system */
 longf_ffree;/* free file nodes in fs */
 fsid_t  f_fsid; /* file system id (super-user only) */
 uid_t   f_owner;/* user that mounted the file system */
 short   f_reserved1;/* reserved for future use */
 short   f_type; /* type of file system (reserved) */
 longf_flags;/* copy of mount flags (reserved) */
 longf_reserved2[2]; /* reserved for future use */
 charf_fstypename[MFSNAMELEN]; /* fs type name */
 charf_mntonname[MNAMELEN];/* directory on which mounted */
 charf_mntfromname[MNAMELEN];  /* mounted file system */
 charf_reserved3;/* reserved for future use */
 longf_reserved4[4]; /* reserved for future use */
 };

Is there a way to deal with fsid_t and uid_t, other than looking into the header 
file and using whatever they're declared as instead?


Thanks,

Ozzi


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] RFC: Daemonize

2007-11-16 Thread Ozzi
I'm most definitely not a scheme guru, so if someone with half a clue would take 
a look at my little daemonize egg below and let me know what they think, I'd 
appreciate it.


I ended up using the (foreign-lambda int "daemon" int int) approach.

I use on-exit to remove the PID file, which means that the daemon have to handle 
signals and exit cleanly. I added a default handler for signal/term to call 
(exit), there are probably other default handlers that should be added.


Oz



(define (daemonize proc #!key (pidfile #f))

  (define (create-pid-file filename pid)
(with-output-to-file filename (lambda () (print pid

  (define (remove-pid-file filename)
(delete-file* filename))

  (define (run-pre-fork-tests)
(when pidfile
(when (file-exists? pidfile)
  (error "PID file exists."))
(unless (file-exists? (pathname-directory pidfile))
  (error "Directory for PID file does not exist."))
(unless (and
 (file-read-access? (pathname-directory pidfile))
 (file-write-access? (pathname-directory pidfile))
 (file-execute-access? (pathname-directory pidfile)))
  (error "Insuficcient rights to create PID file."

  (define (set-default-signal-handlers)
(set-signal-handler! signal/term (lambda (signum) (exit

  (define (cleanup)
(if pidfile (remove-pid-file pidfile)))

  (run-pre-fork-tests)

  (process-fork
   (lambda ()
 ((foreign-lambda int "daemon" int int) 0 0)
 (on-exit cleanup)
 (if pidfile (create-pid-file pidfile pid))
 (set-default-signal-handlers)
 (proc))) #t)


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Using headers from MacPorts when compiling

2007-11-15 Thread Ozzi
Can someone tell me how to tell chicken to use /opt/local/include along with 
/usr/local/include when looking for .h files when compiling eggs. Specifically, 
the numbers egg is looking for gmp.h, which I have in /opt/local/include, not 
/usr/local/include.


Thanks,
Oz


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Wrapping C's printf

2007-10-30 Thread Ozzi

I'd like to wrap C's printf so that I can do something like this:

(c-printf "The %s of %d and %d is %d" "sum" 1 1 2)

Which would print "The sum of 1 and 1 is 2."

I realize that I can't use a simple foreign-lambda, as I need to call C's printf 
with an arbitrary argument list.


Is there a clean way to do this with ffi?

If there is not, my idea is to chop the format string up into chunks, like so:

'("The %s" " of %d" " and %d" " is %d")

and run each chunk through the correct single-argument foreign-lambda of printf. 
That means I will have to create one foreign function for each type of argument 
printf can take, which shouldn't be a big deal.


Any comments on this method?

Of course, if someone knows of a pre-made version of printf with C syntax that 
will work with chicken, all of this will be moot, and I will be grateful.


Oz


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] daemonize egg: redirect I/O?

2007-10-30 Thread Ozzi

Thomas Christian Chust wrote:

> I think it would suffice for daemonize to wrap the call to the daemon's
> main procedure in a dynamic-wind block and call the cleanup function
> from the exit thunk. Unless the daemon procedure terminates itself with
> a low-level _exit or by sending itself a kill signal, the cleanup code
> should then always be executed.


Ok, I think I understand what you're getting it. Unfortunately I can't get it to 
work. You'll have to excuse the thrown-together quality of the code below, but 
it demonstrates the problem I have. Perhaps I am just mis-using dynamic-wind, or 
I have to use something besides (exit) when catching the kill signal, I'm not sure.


(use posix)

(define (silly-daemon)
  (dynamic-wind
  ;; Before: Create our test pid file. It's empty, that's ok.
  (lambda () (system "touch /tmp/test.pid"))
  ;; Proc: Sleep a bit.
  (lambda ()
;; Exit cleanly (?) on kill.
(set-signal-handler! signal/term (lambda () (exit)))
(sleep 5))
  ;; After: Delete our test pid file.
  (lambda () (system "rm /tmp/test.pid"

;; Start silly-daemon.
(let ((pid (process-fork silly-daemon)))
  ;; Wait long enough for silly-daemon to finish sleeping.
  (sleep 7)
  ;; See if it deleted the pid file.
  (if (file-exists? "/tmp/test.pid")
  (print "Failure!")
  (print "Success!")))

;; "Success!" is printed.

;; Start silly-daemon.
(let ((pid (process-fork silly-daemon)))
  ;; Wait a second, then...
  (sleep 1)
  ;; ...kill silly-daemon before it finishes sleeping.
  (system (format "kill ~a" pid))
  ;; Wait a second before...
  (sleep 1)
  ;; ...checking to see if it deleted the pid file.
  (if (file-exists? "/tmp/test.pid")
  (print "Failure!")
  (print "Success!")))

;; "Failure!" is printed.

Thomas Christian Chust wrote:

Ozzi wrote:





cu,
Thomas



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] daemonize egg: redirect I/O?

2007-10-26 Thread Ozzi

Thomas Christian Chust wrote:


I wonder why one would want to pass this cleanup argument to the daemon
procedure -- why should the spawned process simply perform cleanup once
the daemon procedure returns?


The problem with that, as I see it, is that sometimes daemons don't get to 
return normally, i.e. if they get killed. Of course any proper daemon will 
implement signal handlers and such so that it will clean up after itself and 
exit gracefully. With my implementation you can implement that sort of stuff 
anyway you like, and just call the additional (cleanup) proc to take care of 
whatever you had daemonize set up for you, i.e. the PID file.


Of course, it might be nice to have daemonize take care of everything, including 
signal handlers and such. I would see that as a further abstraction.


(define (super-daemonize proc)
  (daemonize (lambda (cleanup)
   (set-signal-handler! ...) ; Call cleanup if we get killed.
   (proc)
   (cleanup



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] daemonize egg: redirect I/O?

2007-10-25 Thread Ozzi
I am working on for creating unix daemons. Can anyone tell me how to redirect 
stdout and stderr? I want to redirect them to /dev/null by default.


I would also be interested in comments on my plans for the egg in general. 
Presently, the interface is as follows:


daemonize is a function that takes a "daemon" proc of one argument, that 
argument being a "cleanup" proc which the "daemon" proc should call before it exits.


In addition, daemonize will take a number of keyword arguments, including 
stdout:, stderr:, and pidfile:. stdout and stderr are simply where to redirect 
those outputs to. pidfile is the name of the file that the daemon should keep 
it's PID in.


For a silly example:

(daeamonize
 (lambda (cleanup)
   (sleep 10)
   (cleanup))
 pidfile: "/tmp/my.pid")

Will fork a new process and create the file "/tmp/my.pid" with the PID of the 
process. The new process will sleep for 10 seconds, then call the cleanup proc, 
which deletes the PID file.


Let me know what you think, and if you have any other ideas or suggestions.

Ozzi


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Creating a C library with Chicken?

2007-10-23 Thread Ozzi
Is there a way to create a library with chicken that could be included as if it 
were a standard C library into, say, Objective-C?


The reason I ask is that I would like to write some OpenGL views in Chicken, but 
then manipulate them from Cocoa/Objective-C to make some fancy windows out of them.


I know that I can interact with Cocoa through Chicken, but I would rather keep 
the Cocoa code in Interface Builder and Objective-C, where it belongs.



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Writing documentation for use/include/require/etc

2007-10-21 Thread Ozzi

Looks like it's time for me to write some more documentation :-)

Below I've included all the ways I've found to include code, along with the 
pages from the wiki where I got the info. If anyone who knows of more of either 
could tack that on, I'll start working on untangling the mess so new users 
(including myself) will know what to use when.



Methods:
(require-extension ...)
(use ...)
(require ...)
(include ...)
(load ...)
(load-relative ...)
(declare (uses ...))

Reference:
http://galinha.ucpel.tche.br:8080//Non-standard%20macros%20and%20special%20forms
http://galinha.ucpel.tche.br:8080//Unit%20eval#Loading%20extension%20libraries
http://galinha.ucpel.tche.br:8080//Using%20the%20compiler


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Re: (use foo) versus (declare (uses foo)), csi versus csc

2007-10-20 Thread Ozzi
Yes, I think this is what I was looking for. I would be interested in a 
discussion about the differences between (use foo) and (include "foo"), and 
which one is appropriate when.


I'm guessing use for shared libraries, where include is for bringing in pieces 
of program code that have been broken out into separate files. Is this correct?


Tobia Conforto wrote:

Ozzi wrote:

Is there an easy way to write something that can be either compiled
or interpreted


I'm not sure this is exactly what you're asking, but I find include
most useful:

$ cat > bar.scm
(define (fac n)
  (if (zero? n)
  1
(* n (fac (- n 1)

$ cat > foo.scm
(include "bar")
(write (fac 10)) (newline)

$ csi -s foo.scm
3628800

$ csc foo.scm -o foo

$ ./foo
3628800


Tobia


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken on PPC macs?

2007-10-19 Thread Ozzi
I've given up on it, but if I have some time I'll get it running and try to run 
some test scripts or something. I'll let you know how it pans out.



felix winkelmann wrote:

On 10/18/07, Ozzi <[EMAIL PROTECTED]> wrote:

I've got an older G3 iBook that I'm trying to get Chicken working on in
preparation to getting it going on some G4 servers. Normally I run it on an
Intel mac, and I'm running into some problems. Chicken itself installed fine
(latest release from source), but now I'm working on extensions and so far it's
a no go.



Very strange. I use chicken on a ppc mac for quite some time.
This may be an installation problem. Can you run and compile
code that uses syntax-case?


cheers,
felix



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] (use foo) versus (declare (uses foo)), csi versus csc

2007-10-19 Thread Ozzi

I think this is best described with an example:


foo.scm

(declare (uses bar))

(write (fac 10)) (newline)




bar.scm

(declare (unit bar))

(define (fac n)
  (if (zero? n)
  1
  (* n (fac (- n 1))) ) )



This can be compiled with:

% csc -c bar.scm
% csc foo.scm bar.o -o foo


However, it can NOT be run with:

% csi foo.scm


If the (declare ...) calls are replaces with (uses ...) it can be run with csi, 
but not compiled. What am I missing? Is there an easy way to write something 
that can be either compiled or interpreted, or do I need to resort to using lots 
of command-line options to do one or the other?


Thanks for the help,

Oz




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Chicken on PPC macs?

2007-10-18 Thread Ozzi
Yeah, no dice here, I'm just going to start working on that Debian box. The G4s 
are too slow anyway.


Thanks for the help.

Mario Domenech Goulart wrote:

Hi Ozzi,

On Wed, 17 Oct 2007 19:33:08 -0500 Ozzi <[EMAIL PROTECTED]> wrote:


I've got an older G3 iBook that I'm trying to get Chicken working on
in preparation to getting it going on some G4 servers. Normally I run
it on an Intel mac, and I'm running into some problems. Chicken itself
installed fine (latest release from source), but now I'm working on
extensions and so far it's a no go.


I could successfully install packrat on my system (Linux on PPC G3):

$ LD_LIBRARY_PATH=/usr/local/chicken-2.720/lib 
/usr/local/chicken-2.720/bin/chicken-setup packrat

The extension packrat does not exist.
Do you want to download it ? (yes/no/abort) [yes]
downloading required extensions (syntax-case) ...
downloading syntax-case.egg from (www.call-with-current-continuation.org eggs 
80) .
installing required extensions ...
  gzip -d -c ../syntax-case.egg | tar xf -
  /usr/local/chicken-2.720/bin/csi -script psyntax-bootstrap.scm
bootstrapping psyntax.pp ...
expanding psyntax.scm to psyntax-chicken.pp ...
  /usr/local/chicken-2.720/bin/csc -feature compiling-extension -s -O2 -d1 
syntax-case.scm
Warning: local assignment to unused variable `macro?' may be unintended
Warning: local assignment to unused variable `undefine-macro!' may be unintended
Warning: local assignment to unused variable `macroexpand' may be unintended
Warning: local assignment to unused variable `##sys#macroexpand-1-local' may be 
unintended
(don't despair - still compiling...)
  rm -fr /usr/local/chicken-2.720/lib/chicken/3/syntax-case.so
  cp -r syntax-case.so /usr/local/chicken-2.720/lib/chicken/3/syntax-case.so
  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/syntax-case.so
  cp -r syntax-case-chicken-macros.scm 
/usr/local/chicken-2.720/lib/chicken/3/syntax-case-chicken-macros.scm
  chmod a+r 
/usr/local/chicken-2.720/lib/chicken/3/syntax-case-chicken-macros.scm
  cp -r syntax-case.html /usr/local/chicken-2.720/lib/chicken/3/syntax-case.html
  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/syntax-case.html

* Installing documentation files in /usr/local/chicken-2.720/lib/chicken/3:
  cp -r syntax-case.html /usr/local/chicken-2.720/lib/chicken/3/syntax-case.html

  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/syntax-case.setup-info
  rm -fr syntax-case.egg-dir
downloading packrat.egg from (www.call-with-current-continuation.org eggs 80) .
  gzip -d -c ../packrat.egg | tar xf -
  /usr/local/chicken-2.720/bin/csc -feature compiling-extension packrat.scm -s 
-O2 -d1 -R syntax-case
  cp -r packrat.scm /usr/local/chicken-2.720/lib/chicken/3/packrat.scm
  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/packrat.scm
  cp -r packrat.html /usr/local/chicken-2.720/lib/chicken/3/packrat.html
  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/packrat.html
  rm -fr /usr/local/chicken-2.720/lib/chicken/3/packrat.so
  cp -r packrat.so /usr/local/chicken-2.720/lib/chicken/3/packrat.so
  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/packrat.so

* Installing documentation files in /usr/local/chicken-2.720/lib/chicken/3:
  cp -r packrat.html /usr/local/chicken-2.720/lib/chicken/3/packrat.html

  chmod a+r /usr/local/chicken-2.720/lib/chicken/3/packrat.setup-info
  rm -fr packrat.egg-dir
  rm -fr /home/mario/packrat.egg

Best wishes,
Mario



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Chicken on PPC macs?

2007-10-17 Thread Ozzi
I've got an older G3 iBook that I'm trying to get Chicken working on in 
preparation to getting it going on some G4 servers. Normally I run it on an 
Intel mac, and I'm running into some problems. Chicken itself installed fine 
(latest release from source), but now I'm working on extensions and so far it's 
a no go.


Below is the output from it trying to compile packrat. Any hints? If all else 
fails I'll get a debian box running, which I've been meaning to do anyway, but 
I'd like to be able to put that off a bit longer.


Thanks for any help,

Ozzi



downloading packrat.egg from (www.call-with-current-continuation.org eggs 80)
installing required extensions ...
  /usr/local/bin/csc -feature compiling-extension packrat.scm -s -O2 -d1 -R 
syntax-case

Error: call of non-procedure: #

Call history:

(begin (##core#require-extension (quote 
syntax-case)))

(##core#require-extension (quote syntax-case))
(begin (begin (##core#require-for-syntax (quote 
syntax-case))) (##core#undefined))
(begin (##core#require-for-syntax (quote 
syntax-case)))

(##core#require-for-syntax (quote syntax-case))
(quote syntax-case) <--
*** Shell command terminated with exit status 1: /usr/local/bin/chicken 
packrat.scm -output-file packrat.c -dynamic -feature chicken-compile-shared 
-quiet -feature compiling-extension -optimize-level 2 -debug-level 1 
-require-extension syntax-case

Error: shell invocation failed with non-zero return status
"/usr/local/bin/csc -feature compiling-extension packrat.scm -s -O2 -d1 -R 
synt...
256


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Compiling readline.egg on Mac OS X 10.4.10

2007-10-04 Thread Ozzi

I also put some info under "Platforms"
http://chicken.wiki.br/platforms#Installing%20the%20readline%20egg

I'm wondering if an "Installation" page on the wiki would be useful. For 
example, pretty much everyone will want to install readline, but it's not 
necessarily clear to new users that they should do so.


It would also be a good place to keep track of installation issues people 
encounter.

I'll work on putting it together unless someone has a reason that it shouldn't 
be done.


Zbigniew wrote:

Done: http://chicken.wiki.br/readline

On 10/4/07, felix winkelmann <[EMAIL PROTECTED]> wrote:

Putting this on the wiki would be helpful indeed.



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Compiling readline.egg on Mac OS X 10.4.10

2007-10-03 Thread Ozzi

Thanks. I did this:

ln -s /opt/local/lib/libchicken.dylib /usr/local/

and it seemed to work. I have tab completion and history now, anyway.

Should this go on the Wiki somewhere, or maybe in the readline egg 
documentation? Unless it's already there and I couldn't find it, of course.


Kon Lovett wrote:


On Oct 3, 2007, at 11:21 AM, Ozzi wrote:

Do you know if I will cause problems if I just change that symlink to 
point to a macports-installed version of libreadline? Is there a 
better approach?


Monkey w/ Apple's installation at your peril.

Suggest you add symlinks from /usr/local include & lib to the 
corresponding file or directory in /opt/local include & lib.




Thanks for the help,

Ozzi







___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Compiling readline.egg on Mac OS X 10.4.10

2007-10-03 Thread Ozzi
Do you know if I will cause problems if I just change that symlink to point to a 
macports-installed version of libreadline? Is there a better approach?


Thanks for the help,

Ozzi

Kon Lovett wrote:


On Oct 3, 2007, at 10:55 AM, Ozzi wrote:


I have installed the latest version of Chicken from SVN. When I run:

sudo chicken-setup readline

I get the following response:

Password:

The extension readline does not exist.
Do you want to download it ? (yes/no/abort) [yes] yes
downloading readline.egg from (www.call-with-current-continuation.org 
eggs 80)

  gzip -d -c ../readline.egg | tar xf -
  /usr/local/bin/csc -feature compiling-extension -s -O2 -d0 
readline.scm -L -lreadline -emit-exports readline.exports -L -ltermcap

readline.c: In function 'gnu_readline_init':
readline.c:221: warning: assignment from incompatible pointer type
/usr/bin/ld: Undefined symbols:
_history_truncate_file
collect2: ld returned 1 exit status
*** Shell command terminated with exit status 1: gcc readline.o -o 
readline.so -bundle -L/usr/local/lib -lreadline -ltermcap -lm -lchicken

Error: shell invocation failed with non-zero return status
"/usr/local/bin/csc -feature compiling-extension -s -O2 -d0 
readline.scm -L -lr...

256

Is it possible I have something messed up locally, or is this a bug in 
the readline egg?


Apple symlinked /usr/lib/libreadline.dylib -> libedit.dylib, which is 
NOT readline. You must get a real readline. Maybe fink or macports. I 
just compiled it myself.


HTH,
Kon




___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Best Wishes,
Kon





___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Compiling readline.egg on Mac OS X 10.4.10

2007-10-03 Thread Ozzi

I have installed the latest version of Chicken from SVN. When I run:

sudo chicken-setup readline

I get the following response:

Password:

The extension readline does not exist.
Do you want to download it ? (yes/no/abort) [yes] yes
downloading readline.egg from (www.call-with-current-continuation.org eggs 80)
  gzip -d -c ../readline.egg | tar xf -
  /usr/local/bin/csc -feature compiling-extension -s -O2 -d0 readline.scm -L 
-lreadline -emit-exports readline.exports -L -ltermcap

readline.c: In function 'gnu_readline_init':
readline.c:221: warning: assignment from incompatible pointer type
/usr/bin/ld: Undefined symbols:
_history_truncate_file
collect2: ld returned 1 exit status
*** Shell command terminated with exit status 1: gcc readline.o -o readline.so 
-bundle -L/usr/local/lib -lreadline -ltermcap -lm -lchicken

Error: shell invocation failed with non-zero return status
"/usr/local/bin/csc -feature compiling-extension -s -O2 -d0 readline.scm -L 
-lr...
256

Is it possible I have something messed up locally, or is this a bug in the 
readline egg?



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users