Ahhh... that is much cleaner. I've also changed over to throwing an error. Thanks for the pointers.

Glenn

On Aug 30, 2008, at 3:19 AM, Slava Pestov wrote:

Another tip: you can write this word without using locals.

: <DV-ENV> ( -- DB-ENV/f )
0 0 <int> [ db_env_creat ] keep *int [ \ DB-ENV new swap alien- address >>dbenv ] db-item-create ;

Finally, in Factor we throw errors instead of returning null on error, so it is better to have your word check for an error condition and throw an error instead of returning f (assuming that's really what it does).

Slava

On Sat, Aug 30, 2008 at 1:02 AM, Glenn Tarcea <[EMAIL PROTECTED]> wrote:
Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
0 err db_env_creat err *int [ \ DB-ENV new swap alien- address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
[EMAIL PROTECTED]
Hey brother, can you paradigm?






---------------------------------------------------------------------- --- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk


---------------------------------------------------------------------- --- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

V. Glenn Tarcea
[EMAIL PROTECTED]
Hey brother, can you paradigm?





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to