Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

DyBASE test

 [1/21] from: robert:muench:robertmuench at: 23-Dec-2003 18:21


Hi, playing around with DyBASE I ran into a problem. The script I work on can be found at http://www.robertmuench.de/dybase-test.r What does it do? It reads all messages from an IOS Messenger and stores them into a database. Further it keeps track of some fields thru indices. Adding records works, I'm working with the messages from Developer server. Rerunning the script after it has finished doesn't work as it seems the database can't be opened again from the same session. Don't know why. Does anybody know what the problem is? How to close down a program so that I can run it from the same session again? Running a fesh instance give than the following error: ** Script Error: fetch-component has no value ** Where: _lookup-object ** Near: set in obj (to word! field-name) fetch-component On the second run the script tries to check if a message already was added to the database. There seems to be a problem. For those of you without an IOS message base I have created a ZIP with 15 messages, so you can try the script as well. You can find the files at http://www.robertmuench.de/messages.zip -- Robert M. Münch Management & IT Freelancer Mobile: +49 (177) 245 2802 http://www.robertmuench.de

 [2/21] from: knizhnik:garret:ru at: 23-Dec-2003 21:54


Hello Robert, Sorry, stupid bug in storage close method ("func" keyword was missed) cause that problem: database was not closed and so could not be reopened. The language constructions should be more protected from errors:) New version of DyBASe 0.17 is available at my site. I has changed (once again) implementation of object cache in Rebol API. Explicit increase of hash size makes it possible to obtain satisfactory insert in hash performance, but remove operation (which cause shift left of all elements next to deleted one in the block associated with the hash) is still very slow (remove has quadratic complexity). That is why I have to implement hash myself using array and collision chains. Insert and search operation are slightly slower, but speed of remove is significantly increased (for large number of objects). Tuesday, December 23, 2003, 8:21:56 PM, you wrote: RMM> Hi, playing around with DyBASE I ran into a problem. The script I work on RMM> can be found at http://www.robertmuench.de/dybase-test.r RMM> What does it do? It reads all messages from an IOS Messenger and stores RMM> them into a database. Further it keeps track of some fields thru indices. RMM> Adding records works, I'm working with the messages from Developer server. RMM> Rerunning the script after it has finished doesn't work as it seems the RMM> database can't be opened again from the same session. Don't know why. Does RMM> anybody know what the problem is? How to close down a program so that I RMM> can run it from the same session again? RMM> Running a fesh instance give than the following error: RMM> ** Script Error: fetch-component has no value RMM> ** Where: _lookup-object RMM> ** Near: set in obj (to word! field-name) fetch-component RMM> On the second run the script tries to check if a message already was added RMM> to the database. There seems to be a problem. RMM> For those of you without an IOS message base I have created a ZIP with 15 RMM> messages, so you can try the script as well. You can find the files at RMM> http://www.robertmuench.de/messages.zip RMM> -- RMM> Robert M. Münch RMM> Management & IT Freelancer RMM> Mobile: +49 (177) 245 2802 RMM> http://www.robertmuench.de -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [3/21] from: gchiu:compkarori at: 24-Dec-2003 22:53


Re: DyBASE test
> database can't be opened again from the same session. Don't know why. Does > anybody know what the problem is? How to close down a program so that I > can run it from the same session again?
Hi Robert, I haven't looked at your script yet, but notice that
>> probe db/close
["Close the storage"] == ["Close the storage"] ie. it doesn't call the dybasedll.dll to close the database. I guess you will get a problem if you try and open the database twice. -- Graham

 [4/21] from: robert:muench:robertmuench at: 24-Dec-2003 12:02


On Tue, 23 Dec 2003 21:54:19 +0300, Konstantin Knizhnik <[knizhnik--garret--ru]> wrote:
> Sorry, stupid bug in storage close method ("func" keyword was missed) > cause that problem: database was not closed and so could not be > reopened. The language constructions should be more protected from > errors:) >> ? protect
USAGE: PROTECT value DESCRIPTION: Protect a word or block to prevent from being modified. PROTECT is a native value. ARGUMENTS: value -- The word or block of words to be protected (Type: word block)
> New version of DyBASe 0.17 is available at my site.
Thanks for the quick fix, I continue my test with it.
> That is why I have to implement hash myself using array and collision > chains. Insert and search operation are slightly slower, but speed of > remove is significantly increased (for large number of objects).
What speed improvements have you achieved by this step? Robert

 [5/21] from: knizhnik:garret:ru at: 24-Dec-2003 14:25


Hello Robert, Wednesday, December 24, 2003, 2:02:11 PM, you wrote: RMM> On Tue, 23 Dec 2003 21:54:19 +0300, Konstantin Knizhnik RMM> <[knizhnik--garret--ru]> wrote:
>> Sorry, stupid bug in storage close method ("func" keyword was missed) >> cause that problem: database was not closed and so could not be >> reopened. The language constructions should be more protected from >> errors:) >>> ? protect
RMM> USAGE: RMM> PROTECT value RMM> DESCRIPTION: RMM> Protect a word or block to prevent from being modified. RMM> PROTECT is a native value. RMM> ARGUMENTS: RMM> value -- The word or block of words to be protected (Type: word block) It looks like I should know where I am going to make a bug to use protect construction:) Also PROTECT will not help in my case: make object! [ close: ["close database"] [dybase_close db] ] Which word do you want to protect? "close"? It has to be defined... The bug is that word "func" is missed, so instead of method definition this code is treated by Rebol as initialization of "close" field with block ["close database"]. What compiler does with second block is not clear to me, I think it was just skipped. This bug seems to be similar with classical fortran bug "DO I=1.10" which cause crash of satellite. That is why I said that language should be less error prone. It can be less flexible, require redundant definitions, but it should be safe and be able to catch at compiler time as many bugs as possible. Certainly I am not experience Rebol user and that is why i doing such stupid mistyping (like this or "hash append value") But fro my point of view, compiler should be able to detect such bugs.. RMM> What speed improvements have you achieved by this step? Robert In testindex example insertion and sreach speed is also not changed. But if you do not reset object hash each 100th iteration, then remove speed is increased about 10 times. -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [6/21] from: g:santilli:tiscalinet:it at: 24-Dec-2003 12:52


Hi Konstantin, On Wednesday, December 24, 2003, 12:25:55 PM, you wrote: KK> The bug is that word "func" is missed, so instead of method definition KK> this code is treated by Rebol as initialization of "close" field with KK> block ["close database"]. What compiler does with second block is not KK> clear to me, I think it was just skipped. There's no compiler, and there's no construct... that's why there's no error too. KK> That is why I said that language should be less error prone. There's no way it could, in this specific case. Setting a word to a block is perfectly legitimate... Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [7/21] from: rotenca:telvia:it at: 24-Dec-2003 13:45


Hi, Konstantin Knizhnik
> make object! [ > close: ["close database"] [dybase_close db]
<<quoted lines omitted: 5>>
> block ["close database"]. What compiler does with second block is not > clear to me, I think it was just skipped.
No, it is evaluated and the evaluation of a block is the block itself. make object! [close: ["close database"] print 1] make object! [close: ["close database"] (print 1)] The body block of an object is simply evaluated, as-is: make object! [print 1] If the interpreter should warn for every evaluated block, you could not do: pick [1 2 3] 2 without a warning, because [1 2 3] is evaluated before passing it to the function pick. The point here is that there is no difference between code and data in Rebol. And that can be detected only at run time. An help for the programmer could be a /debug mode for the interpreter which outputs a list of warning during execution, but we have only the trace mode just now. --- Ciao Romano Paolo Tenca

 [8/21] from: greggirwin:mindspring at: 24-Dec-2003 8:27


Hi Konstantin, Gabriele and Romano already pointed out some technical aspects, so I'll just add some comments. KK> That is why I said that language should be less error prone. KK> It can be less flexible, require redundant definitions, but it should KK> be safe and be able to catch at compiler time as many bugs as KK> possible. Certainly I am not experience Rebol user and that is why i KK> doing such stupid mistyping (like this or "hash append value") KK> But fro my point of view, compiler should be able to detect such KK> bugs.. First, we all do stupid things from time to time, it's not just people new to REBOL. After you start understanding REBOL, you can *really* get yourself in all kinds of trouble being clever. :) It's the same with many other powerful languages. Now, I can only give *my opinion* about why things are the way they are in REBOL, and why I can live with them (or not). I don't intend to preach here, but you triggered some thoughts with your comment, so I'll get them out of my head here. :) To me, REBOL as it exists today is a great starting point, not the end of the story. I would like a debugger and an IDE of some kind, and I think we'll see them someday; we just don't have them *yet*. It's like C before all the supporting tools were built up around it. Many aspects of REBOL development might be seen as crude compared to things like Visual Studio or various Java IDEs, but the foundation is the important thing. If we were to build an IDE for REBOL--one that worked like most other IDEs in existence--it might not be a bad thing, but it would hardly exploit what REBOL is really all about: communication. I want an IDE/debugger that knows what *kind* of code I'm debugging. That is, it should know if I'm developing a dialect and provide special tools and analysis for that. If I'm writing code *in* a dialect, it should know that too, and give me different kinds of help, suggestions, and support to catch my errors. If I'm defining an object, it could automatically create a visualization--showing words, their value type, etc. If I'm writing a one-liner, or simple script, I may not care about 'Design by Contract' support, but if I'm writing code to control a satellite, I probably do. So, it should be smart enough to know what I want, what standards to adhere to, etc. Because of the way REBOL works, we can go waaaaaaaayyyyy beyond things like a STRICT pragma and tools like Lint--at least I believe we can--such is the power of communication and dialects. We'll have to give it some help along the way, as we build and train these smart new tools. The opportunity is here and now, though, to start doing those things. For me, REBOL delivers a lot today, but what excites me most is that I see it as just the-tip-of-the-tip-of the iceberg. :) -- Gregg

 [9/21] from: SunandaDH:aol at: 24-Dec-2003 12:16


Gregg:
> For me, REBOL delivers a lot today, but what excites me most is that > I see it as just the-tip-of-the-tip-of the iceberg. :)
Of course, it's all those bits under water that you can't see that sink ships. REBOL is lacking in lint-type utilities and debuggers and so on. As several people over the years have pointed out, it is hard to write such tools when the whole language is so soft. A line of code like: print if either or and but may be completely valid in its context. But hard-to-write doesn't mean impossible. And REBOL is ideally suited for such a task. Tools like that are definitely on my Christmas present list this year. But I doubt Santa Claus' elves are up to it. Perhaps they can be on some of our New Year resolutions' lists as well. Happy holidays all, Sunanda.<

 [10/21] from: AJMartin:orcon at: 24-Jan-2004 11:41


Sunanda wrote:
> A line of code like: > > print if either or and but > > may be completely valid in its context.
And so is this dialect (Caution: C# code inside!): Person: "Person's details." [ Honourific: Honourific Global/Mesh/Honourifics Forename: string Surname: string Nickname: string Gender: Gender Relations: many Relation Birthday: DateTime Residence: Residence Global/Mesh/Residences Cellphone: Cellphone Global/Mesh/Cellphones Address: Address Global/Mesh/Addresses Email: many Email this: { public string Age { get { if (0 != birthday.Ticks) { int Days, Months, Years; DateTime Now = DateTime.Now; DateTime Birth = Birthday; Days = Now.Day - Birth.Day; if (Days < 0) { Months = Birth.Month + 1; Years = Birth.Year; if (12 < Months) { Months = 1; Years++; } DateTime n = new DateTime (Years, Months, 1); Days = (n - Birth).Days + Now.Day - 1; Birth = n; } Months = Now.Month - Birth.Month; Years = Now.Year - Birth.Year; if (Months < 0) { Months = Months + 12; Years = Years - 1; } return Years + " years, " + Months + " months, " + Days + " days."; } return ""; } } public override string ToString () { return Forename + " " + Surname; } } ] :) Andrew J Martin Speaking in tongues and performing miracles. ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [11/21] from: robert:muench:robertmuench at: 25-Dec-2003 15:33


On Wed, 24 Dec 2003 12:16:18 EST, <[SunandaDH--aol--com]> wrote:
> REBOL is lacking in lint-type utilities and debuggers and so on. As > several people over the years have pointed out, it is hard to write such > tools when the whole language is so soft.
What I would like as a first step is a way to query a word for all it's contexts and the values in those contexts. IMO this is the hardest part to get right in Rebol and the most unusal feature. Robert<

 [12/21] from: robert:muench:robertmuench at: 25-Dec-2003 16:57


On Tue, 23 Dec 2003 21:54:19 +0300, Konstantin Knizhnik <[knizhnik--garret--ru]> wrote:
> New version of DyBASe 0.17 is available at my site.
Hi, the db/close bug id gone but I still have a problem:
>> do %robby-test.r
to-index from-index msg-id-index id: 2987 msg-id to ** Script Error: set expected word argument of type: any-word block ** Where: _lookup-object ** Near: set in obj probe (to word! field-name) I put a probe statement into _lookup-object. It looks like this function has problems with field-names that are normal Rebol worlds. Could this be the case? It should allow any word inside an object to be used, no matter if this word is defined by Rebol as well. Robert<

 [13/21] from: knizhnik:garret:ru at: 25-Dec-2003 20:25


Hello Robert, Certainly it should be possible to use any word as object field. As I understand from your mail, the problem takes place while processing of "to" field. I added "to" field to my guess example. It works without any problems. So the problem seems to be somewhere else. Can you send me sources of robby-test.r, so that I can try to reproduce the problem myself? Also I have fixed some bugs introduced when I have replaced methods of persistent class with global functions (I forgot to replace references to "self" in some functions). I have updated version 0.17 at my site. Thursday, December 25, 2003, 6:57:08 PM, you wrote: RMM> On Tue, 23 Dec 2003 21:54:19 +0300, Konstantin Knizhnik RMM> <[knizhnik--garret--ru]> wrote:
>> New version of DyBASe 0.17 is available at my site.
RMM> Hi, the db/close bug id gone but I still have a problem:
>>> do %robby-test.r
RMM> to-index RMM> from-index RMM> msg-id-index RMM> id: 2987 RMM> msg-id RMM> to RMM> ** Script Error: set expected word argument of type: any-word block RMM> ** Where: _lookup-object RMM> ** Near: set in obj probe (to word! field-name) RMM> I put a probe statement into _lookup-object. RMM> It looks like this function has problems with field-names that are RMM> "normal" Rebol worlds. Could this be the case? It should allow any word RMM> inside an object to be used, no matter if this word is defined by Rebol as RMM> well. Robert -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [14/21] from: robert:muench:robertmuench at: 27-Dec-2003 11:36


On Thu, 25 Dec 2003 20:25:14 +0300, Konstantin Knizhnik <[knizhnik--garret--ru]> wrote:
> Certainly it should be possible to use any word as object field. > As I understand from your mail, the problem takes place while > processing of "to" field. I added "to" field to my guess example. > It works without any problems. So the problem seems to be somewhere > else. Can you send me sources of robby-test.r, so that I can try to > reproduce the problem myself?
Hi, good to know this isn't the problem. You can download the code and test data thru these two links: rebol code: http://www.robertmuench.de/robby-test.r test data : http://www.robertmuench.de/messages.zip
> Also I have fixed some bugs introduced when I have replaced methods of > persistent class with global functions (I forgot to replace references > to "self" in some functions). I have updated version 0.17 at my site.
Ok, thanks a lot, I'm going to use the new version. Robert<

 [15/21] from: knizhnik:garret:ru at: 28-Dec-2003 1:04


Hello Robert, Saturday, December 27, 2003, 1:36:17 PM, you wrote: RMM> On Thu, 25 Dec 2003 20:25:14 +0300, Konstantin Knizhnik RMM> <[knizhnik--garret--ru]> wrote:
>> Certainly it should be possible to use any word as object field. >> As I understand from your mail, the problem takes place while >> processing of "to" field. I added "to" field to my guess example. >> It works without any problems. So the problem seems to be somewhere >> else. Can you send me sources of robby-test.r, so that I can try to >> reproduce the problem myself?
RMM> Hi, good to know this isn't the problem. You can download the code and RMM> test data thru these two links: RMM> rebol code: http://www.robertmuench.de/robby-test.r RMM> test data : http://www.robertmuench.de/messages.zip The bug was trivial: There is no field "to" in "record" object and it was declared as prototype for the persistent object. Attempt to set field which doesn't exists in object context cause such strange error message. I once again want to notice that prototype object is considered as class , so it should contain definitions of all fields and methods which are present in the objects created using these prototype. Unfortunately, Rebol doesn't allow to append field to the object. And without it, loading of persistent objects with arbitrary field set is impossible (at least I do not know how to implement it). The problem is that I have to create object prior fetching of its fields from the database (to handle cyclic reference). And once object is created it is not possible to add fields to it (very strange restriction for such flexible and dynamic language as Rebol).
>> Also I have fixed some bugs introduced when I have replaced methods of >> persistent class with global functions (I forgot to replace references >> to "self" in some functions). I have updated version 0.17 at my site.
RMM> Ok, thanks a lot, I'm going to use the new version. Robert -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [16/21] from: SunandaDH:aol at: 27-Dec-2003 17:18


Konstantin:
> And once object > is created it is not possible to add fields to it (very strange > restriction for such flexible and dynamic language as Rebol).
In simple cases (if the object is not yet referenced anywhere else), it is very simple.... an-object: make object! [field1: now] an-object: make an-object [field2: true] ;; "adds a field" Problems may arise if the original an-object is referenced elsewhere: a-block: copy [] an-object: make object! [field1: now] append a-block an-object an-object: make an-object [field2: true] append a-block an-object probe a-block/1 ;; not the same as probe a-block/2 ;; this See also http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=extend-an-obje ct.r and its documentation -- it may be doing what you need (though it doesn't solve the existing-references problem) Sunanda.<

 [17/21] from: knizhnik:garret:ru at: 28-Dec-2003 11:13


Hello SunandaDH, Sunday, December 28, 2003, 1:18:52 AM, you wrote: Sac> Konstantin:
>> And once object >> is created it is not possible to add fields to it (very strange >> restriction for such flexible and dynamic language as Rebol).
Sac> In simple cases (if the object is not yet referenced anywhere else), it is Sac> very simple.... Sac> an-object: make object! [field1: now] Sac> an-object: make an-object [field2: true] ;; "adds a field" Sac> Problems may arise if the original an-object is referenced elsewhere: Certainly it is referenced! The main idea of creation object before loading its fields is to be able to handle cyclic references. So when object is created, it is placed in hash table which maps OID (object identifier) to the object instance. So if during fetching object fields I find reference to the same OID, reference to it can be obtained from hash table and there is no idle recursion. Also please notice that there are not only direct self references (in this case I can use "self" word in initialization of correspondent field). But fetched fields can contain references to other objects which also has to be loaded and then indirectly reference original object. Certainly it is possible to do fetching of object in two steps - at first jusrt extract all fields data, store it in some temporary block. Then create object using this block. And after it resolve references by performing OID lookup. But it significantly complicates fetch procedure and also make it not possible to load object methods (because only data fields are stored in database). Sac> a-block: copy [] Sac> an-object: make object! [field1: now] Sac> append a-block an-object Sac> an-object: make an-object [field2: true] Sac> append a-block an-object Sac> probe a-block/1 ;; not the same as Sac> probe a-block/2 ;; this Sac> See also Sac> http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=extend-an-obje Sac> ct.r Sac> and its documentation -- it may be doing what you need (though it doesn't Sac> solve the existing-references problem) Sac> Sunanda. -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [18/21] from: knizhnik::garret::ru at: 28-Dec-2003 14:21


New version 0.18 of DyBASE Rebol API is available. Now it is not necessary to specify prototype object: DyBASE is able to fetch object with arbitrary set of fields. It is possible because now fetching of object is done in three steps: 1. Fetch object fields into the block 2. Create object using constructed block 3. Resolve references using load-object method Certainly this approach is less efficient than used before (instantiation of fetched object using prototype object and assignment to object field using "set in" construction) but it is more flexible and performance penalty is not so large - about 50%. Also this approach makes it possible to change format of the objects without recreation of database. New version of DyBASE is located at http://www.garret.ru/~knizhnik/dybase.html -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [19/21] from: gchiu:compkarori at: 24-Jan-2004 11:41


Re: Re: DyBASE test
> New version 0.18 of DyBASE Rebol API is available.
Hi Konstantin, Can you make it is so that attempting to close a database twice results in an error rather than a crash? Cheers, -- Graham

 [20/21] from: knizhnik:garret:ru at: 28-Dec-2003 23:55


Hello Graham, Sunday, December 28, 2003, 10:18:05 PM, you wrote: GC> Re: Re: DyBASE test
>> New version 0.18 of DyBASE Rebol API is available.
GC> Hi Konstantin, GC> Can you make it is so that attempting to close a database GC> twice results in an error rather than a crash? ok, will be fixed in next release. GC> Cheers, GC> -- GC> Graham -- Best regards, Konstantin mailto:[knizhnik--garret--ru]

 [21/21] from: moliad:aei:ca at: 30-Dec-2003 0:17


did you know you didn't have to use actual objects to implement object-like behaviour. this has the effect that you can extend the "object" at will... just use a block with set-word values. I have no ideas about speed, just that this could be a solution to your problem example:
>> object: [
id none name none ]
>> object/name: "gary"
== [ id none name "gary" ] == print object/name gary add a new item to object:
>> append object reduce ['field "chester the cat"]
== [ id none name "gary" field "chester the cat" ]
>> print object/field
chester the cat Some gurus on this list might might correct me, but in the context of your problem, this sounds like a fix to your problem. You can also put functions in such a block and use it, BUT remember that self word is not set by default, you would have to add it to the function's arguments (like in python) and supply the block, to which the function is part of... like this: object: compose [ id none name "gary" field "chester the cat" status ( func [self][ probe length? self foreach [item data] self [ either (function! <> type? :data) [ print [item "=" data] ][ print [item "()"] ] ] ]) ] object/id: 1234 object/status object 8 id = 1234 name = gary field = chester the cat status () HTH!!! -MAx

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted