[REBOL] Objects, Making-Of
Hi Rebols, while playing around with objects, I trapped into this: f: func [] [print "Hello!"] f Hello! spec: [] == [] append spec to-set-word 'attribute == [attribute:] append spec 5 == [attribute: 5] append spec to-set-word 'function == [attribute: 5 function:] append spec :f == [attribute: 5 function: func [][print "Hello!"]] Okay, looks like I'm now having an appropriate specification block for making an object, but: probe object: make object! spec Hello! ** Script Error: function needs a value. ** Where: function: func [][print "Hello!"] What's this? Shouldn't the above return something like make object! [ attribute: 5 function: func [][print "Hello!"] ] The same error occurs if I'm printing spec: print spec Hello! ** Script Error: function needs a value. ** Where: function: func [][print "Hello!"] where one would expect 5 ?function? I'm guessing that the error occurs because of wrong contexts of the words in the spec block. Am I right? And what am I doing wrong here? Even studying the Rebol.org threads on Contexts and Rebol internals implementation (recently mentioned on the list) gave me no idea ... Christian [EMAIL PROTECTED]
[REBOL] Objects, Making-Of Re:
Hi, Hi Rebols, while playing around with objects, I trapped into this: f: func [] [print "Hello!"] f Hello! spec: [] == [] append spec to-set-word 'attribute == [attribute:] append spec 5 == [attribute: 5] append spec to-set-word 'function == [attribute: 5 function:] append spec :f == [attribute: 5 function: func [][print "Hello!"]] Okay, looks like I'm now having an appropriate specification block for making an object, but: probe object: make object! spec Hello! ** Script Error: function needs a value. ** Where: function: func [][print "Hello!"] What's this? Shouldn't the above return something like make object! [ attribute: 5 function: func [][print "Hello!"] ] The same error occurs if I'm printing spec: print spec Hello! ** Script Error: function needs a value. ** Where: function: func [][print "Hello!"] where one would expect 5 ?function? I'm guessing that the error occurs because of wrong contexts of the words in the spec block. Am I right? And what am I doing wrong here? Even studying the Rebol.org threads on Contexts and Rebol internals implementation (recently mentioned on the list) gave me no idea ... Christian [EMAIL PROTECTED] 1) you shouldn't redefine Function (a Rebol mezzanine), but that didn't cause your trouble 2) the problem has nothing in common with contexts. You shouldn't use append spec :f instead try eg. append spec reduce ['first reduce [:f]] Regards Ladislav
[REBOL] Webcam URL Re:(4)
Looks like the webcam: http://demo.rebol.net/webcam/ is still stuck. Perhaps it has something to do with the mysterious green light in the center of the screen? Have aliens landed and mucked about with the REBOL webcam? --Ralph
[REBOL] Objects, Making-Of Re:(2)
Hi Ladislav, 1) you shouldn't redefine Function (a Rebol mezzanine), but that didn't cause your trouble This was just to use speaking names for the example :) 2) the problem has nothing in common with contexts. Obviously I'm still not able to assume correctly where my problems with Rebol are located ... instead try eg. append spec reduce ['first reduce [:f]] Thanks! That surely did it - even I still don't fully understand the problem. Looks as if I were trying to append the function itself instead of just it's source code (spec and body). BTW, meanwhile I found that append spec reduce ['func first :f second :f] works, too. I once knew about that, but thought there should be a more direct approach. Like Yours. Regards Christian [EMAIL PROTECTED]
[REBOL] windowless start of a script crash ....
Hi, I tried to start REBOL script in windowless version and it caused REBOL to crash. It was rebweb.r script from rebol.org IIRC. Is it possible to have rebol web server (or in general any rebol server :-) running in the background? Thanks, -pekr-
[REBOL] to-path curio
I was attempting to create a filename like "anz-visa-statement [30-may-2000 27-jun-2000].r" using the to-path. What I found was: to-path "astring[anotherstring]" == astring/[anotherstring] to-path "astring anotherstring" == astring/anotherstring and mysteriously (to me) to-path "astring anotherstring]" ** Syntax Error: Missing [ at end-of-block. ** Where: (line 1) astring anotherstring] also somewhat unexpectedly to-path #1-3-4 == 1-Mar-2004 I obviously have a limited understanding of paths. Can someone educate me in the ways of the path please? Or is this all there is to say about it? I did manage to get something like my desired filename using print rejoin [%anz-visa-statement to-path {[30-may-2000 27-jun-2000] } %.r] anz-visa-statement[30-May-2000 27-Jun-2000].r It just misses a space. And finally print replace %anz-visa-statement--.r "--" { [30-May-2000 27-Jun-2000]} anz-visa-statement [30-May-2000 27-Jun-2000].r Success. Last question: Are such filenames legal on other OSs (other than Windows)? Brett.
[REBOL] Objects, Making-Of Re:(3)
2) the problem has nothing in common with contexts. Obviously I'm still not able to assume correctly where my problems with Rebol are located ... instead try eg. append spec reduce ['first reduce [:f]] Thanks! That surely did it - even I still don't fully understand the problem. Looks as if I were trying to append the function itself instead of just it's source code (spec and body). Exactly. BTW, meanwhile I found that append spec reduce ['func first :f second :f] works, too. I once knew about that, but thought there should be a more direct approach. Like Yours. Your approach should preferrably be: append spec reduce ['func third :f second :f] The approach append spec reduce ['first reduce [:f]] works for any-functions (ie. for natives and actions too), but your approach takes care of the contexts. Regards Christian [EMAIL PROTECTED]
[REBOL] Rebol page
hi there is a Rebol/flash page: http://oldes.multimedia.cz/flash/zion-7-7-multi1600x1200na800x600.html oldes
[REBOL] Rebol page Re:
What does it have to do with REBOL ? - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 04, 2000 2:55 AM Subject: [REBOL] Rebol page hi there is a Rebol/flash page: http://oldes.multimedia.cz/flash/zion-7-7-multi1600x1200na800x600.html oldes
[REBOL] to-path curio Re:
Hi Brett, you're definitely into it, finding all traps at once ;-) path! file! (!!!) a file! is the representation of a file on some media, optionally including the path to where it's located. e.g. %/home/ingo/.rebol a path! on the other hand is the access to words in an object!, or a function with refinements included, like load/markup , system/words , etc. in short, use to-file "anz-visa-statement [30-may-2000 27-jun-2000].r" and be happy. (What you get may be looking a bit funny, because " ", "[" and "]" get encoded). BTW, all in all it's not ideal to include characters other than a-zA-Z1-0 .-_ in filenames, there may be some platforms where it is not allowed, and they are mostly troublesome when not using a gui interface. They are allowed on Linux, but not thought to be good style (at least by me :-) regards, Ingo Once upon a time [EMAIL PROTECTED] spoketh thus: I was attempting to create a filename like "anz-visa-statement [30-may-2000 27-jun-2000].r" using the to-path. What I found was: to-path "astring[anotherstring]" == astring/[anotherstring] -- do http://www.2b1.de/ _ ._ ingo@)|_ /| _| _ We ARE all ONE www._|_o _ _ ._ _ www./_|_) |o(_|(/_ We ARE all FREE ingo@| |(_|o(_)| (_| ._| ._|
[REBOL] Re: Random chaos
- Open Your Mind - Quoting from Ingo's message (02-Jul-00 16:40:13). i h If connected? cannot determine whether a connection exists then it returns true. i i Odd, I'd say... Wouldn't it be better if it returned false? i i I'd say it should return 'none, thus i i 'true would mean: I'm sure to be connected i 'false : I'm sure not to be connected i 'none : Sorry, your on your own here Ah, you're right. I like it. No, wait! I just thought of something better! It should return 'perhaps ! Think about it, by just adding the 'perhaps state to the logic! datatype, the whole computer science can be rebolutionized, allowing a computer to honestly admit its total confusion about what you just asked! We're writing history, here! The next step will be adding the 'Im-sorry-Dave-Im-afraid-I-cant-do-that error in REBOL/9000. N.B.: :-) I was serious in the "I like it" part only. :-) Alessandro Pini ([EMAIL PROTECTED]) "HAL, are you *sure* you're Y2K compliant?" "Certainlk, Frank, whk do kou ask?" (-: Bowman HAL 9000 O-)
[REBOL] Re: Objects, Making-Of
Hello [EMAIL PROTECTED]! On 03-Lug-00, you wrote: [...] C I'm guessing that the error occurs because of wrong contexts C of the words in the spec block. Am I right? And what am I C doing wrong here? No, contexts have nothing to do with that. :) It's just that you're inserting a FUNCTION! value inside the spec, and not the three values FUNC (word!), [] (block!) and [print "Hello!"] (block!). The word FUNC evaluates to a function that creates another function; when a function value is evaluated, instead, it is executed, not returned. Look at the difference: type? f: do [func [] [print "hello!" 3]] == function! type? do probe compose [(:f)] [func [][print "hello!" 3]] hello! == integer! The two blocks look the same, but they aren't. type? first [func [] [print "hello!" 3]] == word! type? first compose [(:f)] == function! To solve your problem, change the line: append spec :f to: append spec [:f] or to: append spec compose/deep [first [(:f)]] Regards, Gabriele. -- Gabriele Santilli [EMAIL PROTECTED] - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[REBOL] Random chaos Re:(3)
It would be exceedingly useful if the algorithms for determining "connectedness" were known. We've spent a lot of time on this very task on the Windows platform, and it's sometimes important to know when you can and can't trust use a particular algorithm. -- Tim Lesher [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 02, 2000 10:40 To: [EMAIL PROTECTED] Subject: [REBOL] Random chaos Re:(2) Once upon a time [EMAIL PROTECTED] spoketh thus: - Open Your Mind - Quoting from Holger Kruse's message (29-Jun-00 17:57:38). h If connected? cannot determine whether a connection exists then it returns true. Odd, I'd say... Wouldn't it be better if it returned false? I'd say it should return 'none, thus 'true would mean: I'm sure to be connected 'false : I'm sure not to be connected 'none : Sorry, your on your own here Just my few cents, regards, Ingo
[REBOL] Linked list in rebol
Hello: I'd like to implement a *triple* linked list in rebol. Below is a "c" structure: I'd welcome advice on how to translate this to a rebol data structure. If I'm correct, the nxt and prv elements are encapsulated by a rebol list. What I'd like to figure out is how to manually reference another node in the list. (the mrk element) typedef struct test_node { struct test_node *nxt; // points to next node struct test_node *prv; // points to previous node struct test_node *mrk; // points to a randomly selected node long num; }TestNode; Thanks In Advance Regards -Tim
[REBOL] Linked list in rebol Re:
Well, as you know, you get doubly linked lists for free in REBOL. That's called a block. To do the other part, I'd just make the items in your block another block or an object. Then hold an index in one of the vars in that. triple: copy [] ; the linked list foreach item [[none 42] [4 9700] [1 15] [3 1846]] [ repend triple item ] now there are four items in triple. Each item is a block where the first number is what you call *mrk in your structure and the second number is the num you have in your struct. The marker is an index back into triple so that you can do 'pick triple triple/2/1' and that will bring back the block indexed by the third link of the second item in triple, namely item number four "[3 1846]". Another thing you could do is put an actual reference to triple into the block: repend triple [skip triple 3 675] This way the first item in the block is actually a refernce into the triple block. You could do this with objects as well instead of blocks but I'll leave that excercise to the reader. The implementation you choose should be the one best suited for your application. Take into account all the uses of that third link, how much data you want to store in this item, and how you will be manipulating it. Sterling Hello: I'd like to implement a *triple* linked list in rebol. Below is a "c" structure: I'd welcome advice on how to translate this to a rebol data structure. If I'm correct, the nxt and prv elements are encapsulated by a rebol list. What I'd like to figure out is how to manually reference another node in the list. (the mrk element) typedef struct test_node { struct test_node *nxt; // points to next node struct test_node *prv; // points to previous node struct test_node *mrk; // points to a randomly selected node long num; }TestNode; Thanks In Advance Regards -Tim
[REBOL] Parser seems to have bug - different results on multiple calls. Re:
not bad...for whatever it's worth, it opens up the Gateway catalog file at the top of my screen behind the taskbar, so I can't easily turn it off...may be a unique problem with my system. ds At 04:25 PM 7/1/00 +1000, you wrote: Howdy, I've been having trouble with strange results in the parser. Rebol seems to cache the parse rules, which seems like a good idea, but I've found something unexpected. If you copy the code below and paste it (Win or call script in Linux) into your Rebol session you can see how the three calls to parse will change results even though it is the same rule and data. If in the same session you repeat the process you will get the same results again - that is, the first line is right again! Have I done something wrong? BTW, Wouldn't it be nice if there was a parse /explain that would show the "plan" or description of the state machine that will be used for parsing, or whatever is used. I'm always getting confused on the parse syntax. Having this would make it easier for me anyway! Appears in REBOL/View 0.9.9.3.1 1-Jun-2000 REBOL/Core 2.3.0.3.1 on Windows NT 4 SP 4 Brett Handley ; Here starts the code only-string: func[ s [any-string! none!] ][ either s [s][{}]] quoted-data-rule: [ (cell-data: {} Print "Setting the cell-data value") ; This seems to get ignored on subsequent calls of parse. {"} copy data to {"} {"} (append cell-data only-string data) any [ {"} copy data to {"} {"} (append cell-data rejoin [{"} only-string data]) ] ] parse/all {"""."} quoted-data-rule ; This looks ok. print cell-data ; parse/all {"""Hrmm."} quoted-data-rule ; This is not right. print cell-data ; parse/all {"""oi!"} quoted-data-rule ; Bugger. print cell-data ;
[REBOL] Linked list in rebol Re:(2)
Thanks Sterling: I will follow this proces that you have laid out. BTW: This is the first step in a full-blown DBMS in rebol. I will first attempt to clone the Mix C/Database Toolchest - (written in C), and then to optimize based on rebol's best features. Take care -Tim At 01:36 PM 7/3/00 -0700, you wrote: Well, as you know, you get doubly linked lists for free in REBOL. That's called a block. To do the other part, I'd just make the items in your block another block or an object. Then hold an index in one of the vars in that. triple: copy [] ; the linked list foreach item [[none 42] [4 9700] [1 15] [3 1846]] [ repend triple item ] now there are four items in triple. Each item is a block where the first number is what you call *mrk in your structure and the second number is the num you have in your struct. The marker is an index back into triple so that you can do 'pick triple triple/2/1' and that will bring back the block indexed by the third link of the second item in triple, namely item number four "[3 1846]". Another thing you could do is put an actual reference to triple into the block: repend triple [skip triple 3 675] This way the first item in the block is actually a refernce into the triple block. You could do this with objects as well instead of blocks but I'll leave that excercise to the reader. The implementation you choose should be the one best suited for your application. Take into account all the uses of that third link, how much data you want to store in this item, and how you will be manipulating it. Sterling Hello: I'd like to implement a *triple* linked list in rebol. Below is a "c" structure: I'd welcome advice on how to translate this to a rebol data structure. If I'm correct, the nxt and prv elements are encapsulated by a rebol list. What I'd like to figure out is how to manually reference another node in the list. (the mrk element) typedef struct test_node { struct test_node *nxt; // points to next node struct test_node *prv; // points to previous node struct test_node *mrk; // points to a randomly selected node long num; }TestNode; Thanks In Advance Regards -Tim
[REBOL] Objects, Making-Of Re:(2)
Hello [EMAIL PROTECTED]! On 03-Jul-00, You wrote: [...] The two blocks look the same, but they aren't. [...] That's what was irritating me ... But now the context thing comes in for real, ;-) Look at the following console session -- Start of console session -- a: 0 f: func [] [a] o1: make object! [a: 1 g: func [] [a]] o1/g == 0 o2: make object! append [a: 2 g:] [:f] o2/g == 0 o3: make object! append [a: 3 g:] compose/deep [first [(:f)]] o3/g == 0 o4: make object! append [a: 4 g:] reduce ['first reduce [:f]] o4/g == 0 o5: make object! append [a: 5 g:] reduce ['func first :f second :f] o5/g == 5 o1/g o2/g o3/g o4/g o5/g a 1 5 5 5 5 0 -- End of console session -- o1 is okay, anyway. The making of o3 and o4 are equivalent IMHO (o3 are Gabriele's idea, o4 Ladislav's). o5 is my own approach, it keeps care of contexts, but - as Ladislav pointed out - doesn't work for native!s and action!s. Any idea on how an o6 can be done, which preserves context *and* works for native!s and action!s? And finally, why do I get that strange 1 5 5 5 5 0 results? How does o2 to o4 know about o5's a: 5? Lots of homework to do ... Regards Christian [EMAIL PROTECTED]
[REBOL] Objects, Making-Of Re:(4)
Hello [EMAIL PROTECTED], On 03-Jul-00 You wrote: [...] Your approach should preferrably be: append spec reduce ['func third :f second :f] [...] ^ This one will suit my needs, I think. third :f is even better than first :f, of course! Thank You very much! But now I'm wondering if there's a way to universally create objects by assembling a spec block as I did, appending any-function!s AND taking care of contexts. Finally, another question, closely related, arised in this process: I never understood why -- start of console session -- source func *func*: *func* [ "Defines a user function with given spec and body." [catch] spec [block!] {Help string (opt) followed by arg words (and opt type and string)} body [block!] "The body block of the function" ][ throw-on-error [make function! spec body] ] source throw-on-error throw-on-error: *func* [blk][ if error? blk: try blk [throw blk] :blk ] -- end of console session -- doesn't leed to endless recursion. Thanks again, Regards Christian [EMAIL PROTECTED]
[REBOL] Linked list in rebol/Inserting blocks into blocks Re:
Well, I'm trying insert a block into a series of blocks: Consider the following code: ;=== triple: copy [] insert/only triple [1 234] print mold triple insert/only head triple [2 234] print mold triple insert/only next triple [3 345] print mold triple insert/only triple/2 [4 456] ; I've done this wrong print mold triple ; == the results are: [[1 234]] [[2 234] [1 234]] [[2 234] [3 345] [1 234]] [[2 234] [[4 456] 3 345] [1 234]] ; what I'm really looking for at the last output line is: [[2 234] [4 456] [3 345] [1 234]] What should I do differently? Thanks -Tim At 01:36 PM 7/3/00 -0700, you wrote: Well, as you know, you get doubly linked lists for free in REBOL. That's called a block. To do the other part, I'd just make the items in your block another block or an object. Then hold an index in one of the vars in that. triple: copy [] ; the linked list foreach item [[none 42] [4 9700] [1 15] [3 1846]] [ repend triple item ] now there are four items in triple. Each item is a block where the first number is what you call *mrk in your structure and the second number is the num you have in your struct. The marker is an index back into triple so that you can do 'pick triple triple/2/1' and that will bring back the block indexed by the third link of the second item in triple, namely item number four "[3 1846]". Another thing you could do is put an actual reference to triple into the block: repend triple [skip triple 3 675] This way the first item in the block is actually a refernce into the triple block. You could do this with objects as well instead of blocks but I'll leave that excercise to the reader. The implementation you choose should be the one best suited for your application. Take into account all the uses of that third link, how much data you want to store in this item, and how you will be manipulating it. Sterling Hello: I'd like to implement a *triple* linked list in rebol. Below is a "c" structure: I'd welcome advice on how to translate this to a rebol data structure. If I'm correct, the nxt and prv elements are encapsulated by a rebol list. What I'd like to figure out is how to manually reference another node in the list. (the mrk element) typedef struct test_node { struct test_node *nxt; // points to next node struct test_node *prv; // points to previous node struct test_node *mrk; // points to a randomly selected node long num; }TestNode; Thanks In Advance Regards -Tim