freeride-devel
[Top][All Lists]
Advanced

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

RE: [FR-devel] Database slot-type addition


From: Rich Kilmer
Subject: RE: [FR-devel] Database slot-type addition
Date: Sat, 3 Aug 2002 13:07:15 -0400

Here is some code:

databus = FreeBASE::DataBus.new
slot = databus["/foo/bar/slot1"]
slot2 = slot1["../slot2"]

puts slot1.path #=> /foo/bar/slot1
puts slot2.path #=> /foo/bar/slot2

We use the [<path>] to navigate the slot hierarchy (I misspoke before in
saying with use []=).  The normal idiom of hash value access is
hash[key] but since on a slot this refers to another slot (slot[path])
and not its data value we cannot use it.  Although []= is available and
we could do:

class Slot
 def []=(key, value)
  @hash[key]=value
 end
end

We could not use [] to pull the value out...and I think that that is
confusing.  It would be like

slot = databus["/foo/bar/slot1"]
slot["x"]=25
puts slot["x"] #=> #<FreeBASE::DataBus::Slot:0x2af1a10>

Which would be confusing.

-rich

> -----Original Message-----
> From: address@hidden [mailto:freeride-
> address@hidden On Behalf Of Hal E. Fulton
> Sent: Saturday, August 03, 2002 12:54 PM
> To: address@hidden
> Subject: Re: [FR-devel] Database slot-type addition
> 
> ----- Original Message -----
> From: "Rich Kilmer" <address@hidden>
> To: <address@hidden>
> Sent: Friday, August 02, 2002 7:26 PM
> Subject: RE: [FR-devel] Database slot-type addition
> 
> 
> > > > > Well, I see your point where slot.data={}
> > > > > is concerned. But for the others, we could
> > > > > make #hash create an object that was a
> > > > > subclass of Hash, with the [] and []=
> > > > > doing notification. Couldn't we? This
> > > > > would be more convenient than a #get and
> > > > > a #put, IMO.
> > > > >
> >
> > The problem is that the slot[] and []= are used to retrieve
subslots.  I
> > don't want to confuse the issue of slot access ([], []=) and slot
> > storage.
> 
> Can you explain this? I trust your judgment,
> but I'd like to understand what you're saying...
> 
> Hal
> 
> 
> 
> _______________________________________________
> Freeride-devel mailing list
> address@hidden
> http://mail.freesoftware.fsf.org/mailman/listinfo/freeride-devel





reply via email to

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