[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02299] Re: setter() for local variables

From: ts <decoux@...>
Date: 2000-03-31 15:19:23 UTC
List: ruby-talk #2299
>>>>> "Y" == Yukihiro Matsumoto <matz@netlab.co.jp> writes:

Y>        def []=(k,v)
Y>          @tbl[k] = v
Y>          @db[::Mashal::dump(k)] = ::Mashal::dump(v)
Y>        end

 I must do the same for def [], in theory, i.e.

     def [](k)
        @tbl[k] = @db[::Marshal::dump(k)]
        @tbl[k]
     end

 otherwise I lost the possibility to have transaction. A littele example (I
 don't like the syntax actually, it's copied from the C interface but
 perhaps there is a better way of doing it)

pigeon% cat b.rb
#!/usr/bin/ruby
require "bdb"
env = BDB::Env.new("/tmp", ["DB_DATA_DIR /tmp"],
                  BDB::CREATE | BDB::INIT_MPOOL | BDB::INIT_TXN)
db = env.open_db(BDB::BTREE, "aa", nil, BDB::CREATE, 0644)
db["a"] = 12
a, b = env.begin(db)
  b["a"] = 24
  c, d = a.begin(db)
    d["a"] = 36
    p db["a"]
  c.abort
  p db["a"]
a.abort
p db["a"]
pigeon% b.rb
"36"
"24"
"12"
pigeon% 

 This mean that I must manage the database and an hash (or an array for
 DB_RECNO, DB_QUEUE).

 I lost the advantage of BerkeleyDB, no ?


Guy Decoux

In This Thread