[REBOL] Series essay Re:(5)
Hi, Joel, although not been asked, trying to answer some questions. 1) The model of binding Gabriele (not Gabrielle) proposed was proposed as a hypothesis, that could explain the Rebol behaviour. Since then it has succeeded to explain every situation encountered and to make valid predictions, so it's validity is much less questionable than validity of any other binding model proposed. 2) When you use a code like: a: 1 b: 'a use [a] [print 'a = b print same? 'a b] you get: true false which really means that the words you are comparing are somehow equal and somehow different. The model: Every word (e.g. 'a) is an entity that has at least attributes: text-representation (e.g. "a") binding (e.g. the global context) From the model point of view the words are considered equal as long as their text-representations are equal. The words compared above are considered equal, but are not the same, because their binding attributes differ. 3) About the difference between the global context and any other context: Any word can be bound to the global context. (In other words: the global context is enlarge-able.) That is why the 'c being bound to the global context looks "clobbered". As to the local contexts: The local contexts created with a help of the Use function (or a similar mechanism) are limited in the following sense: Bind Word Local-Context-Word doesn't change the Word's binding, if it doesn't encounter the Word's equivalent in the Local-Context. That is why within F 'a and 'b don't change their binding - the 'a and 'b words are not in the F's local context. Ladislav - Pùvodní zpráva - Od: [EMAIL PROTECTED] Komu: [EMAIL PROTECTED] Odesláno: 27. prosince 1999 20:15 Pøedmìt: [REBOL] Series essay Re:(4) Gabrielle, Thanks for your descriptions! They've stimulated some additional questions, given below. Might I trouble you for some more ideas? [EMAIL PROTECTED] wrote: My model for binding/contexts is the following: {{context! * *}} ^ | `- ... 1 ... ; values (simplified notation) \| \ `--- ... a ... ; words (simplified notation) \ \ {{word! * *}} | V #"a" ... obj: make object! [ [a: 1 [b: 2 [] first obj == [self a b] second obj == [ make object! [ a: 1 b: 2 ] 1 2] From other languages, I had a concept of "environment" -- basically a dictionary ("a-list" in LISP, "hash" in Perl, etc.) which supported looking up a variable/word/token and obtaining the corresponding value. That much seems compatible with the model you provided. You've persuaded me that one part of that concept does NOT apply to REBOL -- that of searching a chain of environments, from most-local to most-global, to find the appropriate binding for a word. While that notion works well for pure lexical scoping and pure dynamic scoping, I don't see how it effectively supports REBOL's word-at-a-time capability accessed via 'bind. It seems clear that context-juggling is implicitly performed via entry and exit to the bodies of functions and 'use, as in: a: "global a" == "global a" f: func [][print a] g: func [/local a][a: "g's local a" print a f print a] h: func [][use [a][a: "h's local a" print a g print a]] h h's local a g's local a global a g's local a h's local a I'm not clear on whether it's better to think of the above as 1) a single word 'a whose context is being magically managed by the interpreter, or 2) three words, whose names happen to share the same spelling. To display my ignorance (and confusion) on this point, consider this console transcript: a: 1 == 1 b: 2 == 2 e: [a b c] == [a b c] reduce e ** Script Error: c has no value. ** Where: c That was expected, as I had not defined 'c previously. f: func [n /local c] [c: n bind e 'c print e] f 12 1 2 12 So far, still expected, as 'f supplies a context for 'c to be evaluated in. e == [a b c] print e 1 2 12 c ** Script Error: c has no value. ** Where: c same? 'c third e == false This WASN'T what I expected. It appears that the third element of 'e is a different 'c from the one whose name I can type into the console. g: func [m /local a b] [bind e 'a a: m b: m + 1 print e] g 20 20 21 12 e == [a b c] print e 20 21 12 No surprise here. h: func [][bind e third e print e] h 20 21 12 H. Within 'f (where we've bound 'c) the words 'a and 'b would have evaluated globally. However, attempting to bind 'e back to that context doesn't restore 'a and 'b (in e!) to refer to the global 'a and 'b. bind e 'f == [a b c] print e ** Script Error: c has no value.
[REBOL] Thanks Re:(2)
Hi Petra, it is a bitter truth. Jobwise you will currently find more opportunities with Perl than with REBOL. You will also find far more competent competitors in the market. If I may wonder out loud: How many people on this list know of job openings that could be filled with someone who knows REBOL (no, I'm not looking for a job ;-). Frankly, Perl IMHO has a rather steep learning curve. By the time you master Perl, you may find that REBOL has become far more marketable. You could always easily build a Perl generating engine in REBOL and let REBOL do your Perl work for you ;-). To remain realistic, at this point in time I'd have a very bad conscience, if I were to recommend that anyone pursue REBOL as a career decision. If you can control which scripting or programming language you want to use, if you would rather learn a superior scripting/programming language, if this is going to be your first programming language, if you are willing to take a gamble (careerwise that is), then definitely go with REBOL. I don't have any empirical material to support this last claim, but I'm willing to bet that you will probably find it much easier to learn Perl, once you've mastered REBOL. REBOL will teach you how to program (provided this is your first programming language) and it's much easier to figure out other programming languages once you've mastered your first one. And Perl certainly can't beat REBOL as an introductory language. You may find that the time you spend learning REBOL will significantly reduce the time it takes you to learn Perl. Enough of being reasonable. Learn REBOL and apply for a job with REBOL Tech ;-). Now that's a career decision. Elan
[REBOL] logical value referencing ... Re:
Hi Elan, I think you've got us all mystified. You said to Joel: You also quote excerpts that demonstrate the use of the verb "to refer" in a context where something is being referred to. This class of quotes does not make any statement about WHAT IS DOING the referring. What use are quotes that demonstrate that values can be referred to, even though they are not words? I never claimed that values being referred to must be words. I said that only words are references, and only words can be dereferenced: help get Gets the value of a word. Arguments: word -- Word to get (any-word) Refinements: /any -- Allows any type of value, even unset. I can't for the life of me see how the help for GET says anything about the technical meaning of the word of the term "refer" or "reference", given that the word isn't used at all. Then when you go on to prove that string values cannot refer by showing that strings cannot be used as an argument to GET, my confusion is compounded many-fold. Where does it say that only words can be dereferenced? I haven't even seen the term "dereference" in the documentation. Maybe this will help me understand what you're thinking. How do you explain what happens here? string: "abcdefghij" == "abcdefghij" b: [] loop 5 [append b string string: next string] == "fghij" b == ["abcdefghij" "bcdefghij" "cdefghij" "defghij" "efghij"] unset 'string remove first b == "bcdefghij" b == ["bcdefghij" "cdefghij" "defghij" "efghij" "fghij"] Here's an interesting use of the term "reference" from the User's Guide 2.2.0 [DRAFT 2] (sersearch.html) Search Constraints The /part refinement takes one argument, a range to search. This can be a numeric range, or series. When a series is used, find/part uses the count of elements between the current index of the search series and the current index of the series argument as the range to constrain to. The series used as the range argument must reference the same series that's being searched. You'll see that a "series" is said to reference a "series" - not terribly clear wording, but given that they haven't had time to fully consider Joel's proposals I'd say it's a forgivable lapse. The behavior described here may be illustrated as follows: a: "this is a string to be searched" == "this is a string to be searched" find a "string" == "string to be searched" find a "search" == "searched" find/part a "string" find a "search" == "string to be searched" find/part a "search" find a "string" == none In the final statement here, find a "string" returns a reference to A which constrains the find/part to a portion of A which doesn't include the substring "search" Here's another example, from sercopy.html: Copying Embedded Series With the /deep Refinement The /deep refinement forces copy to copy all series values within a block. When copying series values in a block, the reference to the series is copied, not the series itself. Modifications to series in a copied block will modify the series in the copy. It implies quite clearly that references can exist within a block. BTW, you may have spotted Joel's solution to my puzzle, which I confess is a silly variation of one of Ladislav's puzzles. See you, Eric
[REBOL] Series essay Re:(6)
[EMAIL PROTECTED] wrote: Hi, Joel, although not been asked, trying to answer some questions. 1) The model of binding Gabriele (not Gabrielle) [sigh...] It seems I am unable to type these days without making a typo! [My apollogies, Gabriele!] proposed was proposed as a hypothesis, that could explain the Rebol behaviour. Since then it has succeeded to explain every situation encountered and to make valid predictions, so it's validity is much less questionable than validity of any other binding model proposed. Gabriele's email to which I was responding certainly expressed some ideas that were helpful to me. My questions were intended to help me understand it better. I appreciate your assistance in that regard. So, let me do a sanity check by attempting to answer the questions I raised, based on my understanding of what you and Gabriele have said. You've persuaded me that one part of that concept does NOT apply to REBOL -- that of searching a chain of environments... There is no "chain of environments". Each word directly refers to its own context. e == [a b c] print e 1 2 12 c ** Script Error: c has no value. ** Where: c same? 'c third e == false The 'c at the third element of 'e ['s value] had been bound to the local context of a function (value of 'f), and was therefore a different word from a global 'c (although spelled the same). h: func [][bind e third e print e] h 20 21 12 H. Within 'f (where we've bound 'c) the words 'a and 'b would have evaluated globally. However, attempting to bind 'e back to that context doesn't restore 'a and 'b (in e!) to refer to the global 'a and 'b. Precisely because global 'a and 'b aren't in the context to which the third element of 'e ['s value] is bound, and therefore aren't changed by the 'bind within 'h ['s value]. bind e 'f == [a b c] print e ** Script Error: c has no value. ** Where: c a == 1 print first e a print get first e 1 The last one is the only one I'm still trying to understand. Running the following (in a fresh REBOL console) highlights my question. a: 1 == 1 b: 2 == 2 e: [a b c] == [a b c] print e ** Script Error: c has no value. ** Where: c f: func [n /local c][c: n bind e 'c print e] f ** Script Error: f is missing its n argument. ** Where: f f 99 1 2 99 print e 1 2 99 bind e 'e == [a b c] print e ** Script Error: c has no value. ** Where: c What I think you've said is that the bind in f affects only the third element of e because the other elements refer to words not in the context used for the bind. c is bound, but a and b are left alone. OTOH, the last bind above affects all of a, b, and c, because it the target context is the global context. Therefore, a and b get bound back to a context where they already have values, but c gets bound to a context where it does NOT have a value. Did I interpret your description correctly? Thanks for your feedback (and patience) ! -jn-
[REBOL] Re: How to form a rule?
Hello [EMAIL PROTECTED]! On 27-Dic-99, you wrote: P [thru "s" "om" skip " " "t" thru "t" " " "to" " " "p" skip P skip "se"] What about: [thru "som" skip " t" thru " to p" 2 skip "se"] It shouldn't be a problem to build that. Regards, Gabriele. -- o) .-^-. (--o | Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila | | GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ | o) `-v-' (--o
[REBOL] Series essay Re:(7)
Yes, that's what I tried to say. You're welcome. Ladislav - Pùvodní zpráva - Od: [EMAIL PROTECTED] Komu: [EMAIL PROTECTED] Odesláno: 28. prosince 1999 16:43 Pøedmìt: [REBOL] Series essay Re:(6) [EMAIL PROTECTED] wrote: Hi, Joel, although not been asked, trying to answer some questions. 1) The model of binding Gabriele (not Gabrielle) [sigh...] It seems I am unable to type these days without making a typo! [My apollogies, Gabriele!] proposed was proposed as a hypothesis, that could explain the Rebol behaviour. Since then it has succeeded to explain every situation encountered and to make valid predictions, so it's validity is much less questionable than validity of any other binding model proposed. Gabriele's email to which I was responding certainly expressed some ideas that were helpful to me. My questions were intended to help me understand it better. I appreciate your assistance in that regard. So, let me do a sanity check by attempting to answer the questions I raised, based on my understanding of what you and Gabriele have said. You've persuaded me that one part of that concept does NOT apply to REBOL -- that of searching a chain of environments... There is no "chain of environments". Each word directly refers to its own context. e == [a b c] print e 1 2 12 c ** Script Error: c has no value. ** Where: c same? 'c third e == false The 'c at the third element of 'e ['s value] had been bound to the local context of a function (value of 'f), and was therefore a different word from a global 'c (although spelled the same). h: func [][bind e third e print e] h 20 21 12 H. Within 'f (where we've bound 'c) the words 'a and 'b would have evaluated globally. However, attempting to bind 'e back to that context doesn't restore 'a and 'b (in e!) to refer to the global 'a and 'b. Precisely because global 'a and 'b aren't in the context to which the third element of 'e ['s value] is bound, and therefore aren't changed by the 'bind within 'h ['s value]. bind e 'f == [a b c] print e ** Script Error: c has no value. ** Where: c a == 1 print first e a print get first e 1 The last one is the only one I'm still trying to understand. Running the following (in a fresh REBOL console) highlights my question. a: 1 == 1 b: 2 == 2 e: [a b c] == [a b c] print e ** Script Error: c has no value. ** Where: c f: func [n /local c][c: n bind e 'c print e] f ** Script Error: f is missing its n argument. ** Where: f f 99 1 2 99 print e 1 2 99 bind e 'e == [a b c] print e ** Script Error: c has no value. ** Where: c What I think you've said is that the bind in f affects only the third element of e because the other elements refer to words not in the context used for the bind. c is bound, but a and b are left alone. OTOH, the last bind above affects all of a, b, and c, because it the target context is the global context. Therefore, a and b get bound back to a context where they already have values, but c gets bound to a context where it does NOT have a value. Did I interpret your description correctly? Thanks for your feedback (and patience) ! -jn-
[REBOL] logical value referencing ... Re:(2)
Hi, sorry for disagreeing with you: not silly. Ladislav Hi Elan, I think you've got us all mystified. You said to Joel: You also quote excerpts that demonstrate the use of the verb "to refer" in a context where something is being referred to. This class of quotes does not make any statement about WHAT IS DOING the referring. What use are quotes that demonstrate that values can be referred to, even though they are not words? I never claimed that values being referred to must be words. I said that only words are references, and only words can be dereferenced: help get Gets the value of a word. Arguments: word -- Word to get (any-word) Refinements: /any -- Allows any type of value, even unset. I can't for the life of me see how the help for GET says anything about the technical meaning of the word of the term "refer" or "reference", given that the word isn't used at all. Then when you go on to prove that string values cannot refer by showing that strings cannot be used as an argument to GET, my confusion is compounded many-fold. Where does it say that only words can be dereferenced? I haven't even seen the term "dereference" in the documentation. Maybe this will help me understand what you're thinking. How do you explain what happens here? string: "abcdefghij" == "abcdefghij" b: [] loop 5 [append b string string: next string] == "fghij" b == ["abcdefghij" "bcdefghij" "cdefghij" "defghij" "efghij"] unset 'string remove first b == "bcdefghij" b == ["bcdefghij" "cdefghij" "defghij" "efghij" "fghij"] Here's an interesting use of the term "reference" from the User's Guide 2.2.0 [DRAFT 2] (sersearch.html) Search Constraints The /part refinement takes one argument, a range to search. This can be a numeric range, or series. When a series is used, find/part uses the count of elements between the current index of the search series and the current index of the series argument as the range to constrain to. The series used as the range argument must reference the same series that's being searched. You'll see that a "series" is said to reference a "series" - not terribly clear wording, but given that they haven't had time to fully consider Joel's proposals I'd say it's a forgivable lapse. The behavior described here may be illustrated as follows: a: "this is a string to be searched" == "this is a string to be searched" find a "string" == "string to be searched" find a "search" == "searched" find/part a "string" find a "search" == "string to be searched" find/part a "search" find a "string" == none In the final statement here, find a "string" returns a reference to A which constrains the find/part to a portion of A which doesn't include the substring "search" Here's another example, from sercopy.html: Copying Embedded Series With the /deep Refinement The /deep refinement forces copy to copy all series values within a block. When copying series values in a block, the reference to the series is copied, not the series itself. Modifications to series in a copied block will modify the series in the copy. It implies quite clearly that references can exist within a block. BTW, you may have spotted Joel's solution to my puzzle, which I confess is a silly variation of one of Ladislav's puzzles. See you, Eric
[REBOL] Re: Series essay Re:(4)
Hello [EMAIL PROTECTED]! On 27-Dic-99, you wrote: j Thanks for your descriptions! They've stimulated some j additional questions, given below. Might I trouble you for j some more ideas? No trouble. :-) I'll try to provide you my own answers, even if they could be wrong. :-) j You've persuaded me that one part of that concept does NOT j apply to REBOL -- that of searching a chain of environments, j from most-local to most-global, to find the appropriate j binding for a word. Yes. Indeed, in the beginning I thought that a word had to mantain a list of contexts, from the most "local" to the most "global", but Ladislav (IIRC) showed me I was wrong. The magic is done by bind, which sets the reference to the context in a word only if it is present in that context. j It seems clear that context-juggling is implicitly performed j via entry and exit to the bodies of functions and 'use, as in: Actually, nothing happens when entering or exiting the functions. The binding is done when they are created. That is, make function! creates a new context based on the spec, and then binds the body block to that context. j 2) three words, whose names happen to share the same spelling. Three different words. It's like having series with the same sequence but a different position --- you have words with the same spelling but different contexts. j same? 'c third e j== false j This WASN'T what I expected. It appears that the third element j of 'e is a different 'c from the one whose name I can type j into the console. Not really surprising: {{context! * *}} ; the global context ^ | `- ... | `--- ... | {{word! * *}} ; global 'c | `--- #"c" ^ | .---' / {{word! * *}} ; local 'c | | v {{context! * *}} ; the local context | ` 12 `-- c Even if they referred to the same sequence of character, they would refer to a different contexts. Actually, in your example even the sequence of characters would have not been exactly the same. j H. Within 'f (where we've bound 'c) the words 'a and 'b j would have evaluated globally. However, attempting to bind 'e j back to that context doesn't restore 'a and 'b (in e!) to j refer to the global 'a and 'b. This is not a surprise too. Within f's context there's no 'a or 'b, so bind simply ignores them. Their binding is not changed; keep in mind that you are not binding code, but single words --- every word can have its own context. The following example should not surprise you: block: [x] == [x] x: 1 == 1 reduce block == [1] use [x] [x: 2 insert tail block 'x] == [] use [x] [x: 3 insert tail block 'x] == [] use [x] [x: 4 insert tail block 'x] == [] block == [x x x x] reduce block == [1 2 3 4] See, four different x's. j But 'f is defined in the global context for which 'a - 1, 'b j - 2, and 'c is undefined. So, although it seems clear why j this last use of 'bind restored 'a and 'b (in 'e!) to their j global binding, it's not immediately obvious to me why 'c (in j 'e) got clobbered (when the 'bind in 'g didn't affect it). Because 'c actually exists in the global context, and its value is unset!. Look: c ** Script Error: c has no value. ** Where: c type? get/any 'c == unset! j So, every word simply mantains a reference to a context (and j probably, for efficiency, directly to its value in that j context --- this could be proven in the previous version of j REBOL), j Fascinating! Could you provide a code speciment that j demonstrates? REBOL = 2.1 made possible to modify the first and the second componets of objects, that is, the list of words and the list of values of its context. Something like: obj: make object! [a: 1 b: 2] words: first obj == [self a b] values: second obj == [ make object! [ a: 1 b: 2 ] 1 2] change next words 'c == [b] words == [self c b] print mold obj make object! [ c: 1 b: 2 ] (This is no longer possible, for security; now first obj would return a copy of the actual block.) If we had an 'a bound to that context that evaluated to 1 before the change, it would continue to evaluate to 1 after the change, even if 'a no more exists in that context after the change. Regards, Gabriele. -- o) .-^-. (--o | Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila | | GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ | o) `-v-' (--o
[REBOL] Series essay Re:(7)
Don't know if you tried this, Joel, but here's a few more interesting lines to add to your example. a: 1 == 1 b: 2 == 2 e: [a b c] == [a b c] print e ** Script Error: c has no value. ** Where: c f: func [n /local c][c: n bind e 'c print e] f ** Script Error: f is missing its n argument. ** Where: f f 99 1 2 99 print e 1 2 99 bind e 'e == [a b c] print e ** Script Error: c has no value. ** Where: c ; (more) f 99 1 2 99 print e 1 2 99 ; 'c is restored to the 'e context c: 12 bind e 'e == [a b c] print e 1 2 12 ; 'e binds to 'c in the this context unset 'c print e ** Script Error: c has no value. ** Where: c ; no 'c in this context now f 99 1 2 99 print e 1 2 99 bind/copy e 'e == [a b c] print e 1 2 99 ; with the copy refinement, 'e binds to the 'c in the 'f local context. f 98 1 2 98 print e 1 2 98 ; and when the 'c in the the 'f local context changes, so does the 'c in the 'e local context a: 65 65 print e 65 2 98 ; and we are still bound to the orignal 'a So to retain a word set to a value in a local context, we can use the 'bind/copy refinement. At first, I was thinking we were copying the 'c from the 'f context. But I guess we're really copying the 'c from the 'e context. Bind is operating in the block outside of 'e and so 'c does not exist to it. But I guess the /copy refinement recreates the local 'c so that bind can use it. It doesn't seem to be a "copy" in the usual sense though, since it appears to be the same value first created in 'f. Just as a value can be shared between words, perhaps a word can be shared among contexts. -Ted.
[REBOL] logical value referencing ... Re:(2)
Hi Eric, you appear baffled by my use of the term "dereference". I hope the following quote will help. Note the sentence: "Is it important to clear large blocks of data before DEREFERENCING them?" Quote Begins Here From: [EMAIL PROTECTED] Hi Bo, Thank you very much for showing me your history list functions. I just have a couple of questions. One is that it seems REBOL automatically purges the history list of duplicates, so I didn't try to put that into mine. Was that necessary for an older version of REBOL? I notice that you do clear system/console/history system/console/history: history Is clearing the history important for releasing the memory that the list occupied? Is it important to clear large blocks of data before dereferencing them? One thing that I think would be very useful for a lot of functions, not just for a history-search function, would be the ability do something like this: userdata: ask/default "Prompt: " "Edit this string" The user would see: Prompt: Edit this string and would be able to edit the default string, just like you can edit a string selected from the history list with the up and down keys. Is there any way to do this with REBOL now? Thanks again, Eric Quote Ends Here Hope this helps, Elan
[REBOL] Series essay Re:(6)
{{ Actually, nothing happens when entering or exiting the functions. The binding is done when they are created. That is, make function! creates a new context based on the spec, and then binds the body block to that context. }} Which also neatly explains why local values are persistent. They are (apparently) intialized to none when the block is made, and continue through the session. It's only our prior knowledge of other languages that lead us think locals might wax and wane whenever a function is evaluated. {{ Because 'c actually exists in the global context, and its value is unset!. Look: c ** Script Error: c has no value. ** Where: c type? get/any 'c == unset! }} Since this works as the first statement in a new session, I guess that, theoretically, this would mean all words exist, but are initially 'unset. -Ted.
[REBOL] finding an item's position Re:(3)
I may be totally naive, but what is "Shadowrun"? On 27-Dec-1999/2:37:47-6:00, [EMAIL PROTECTED] wrote: Hello, On 26-Dec-99, [EMAIL PROTECTED] wrote: foo: [a b c d e] == [a b c d e] index? find foo 'b == 2 Short and sweet, thanks. Now to start figuring out how I want to make the rest of the script work. One part will be to let the user choose the order of the items. First I need to start organizing whatever data I'll be working with. (FYI, it'll be a Shadowrun character generator) Elliott -- Bohdan "Bo" Lechnowsky REBOL Adventure Guide REBOL Technologies 707-467-8000 (http://www.rebol.com) Download the REBOL Messaging Language for all Platforms
[REBOL] ZIP and RAR archives with REBOL
Hi, is there any way how to go into ZIP and RAR archives with REBOL? I need to get archive structure at least (list of compressed files in the archive) thanx oLdes
[REBOL] Handy Timer Functions
Hi all Below are some handy timer functions for REBOL. The idea of tic and toc comes from the MATLAB numeric package. One advantage of using a pair of functions is that they can be placed most anywhere in a piece of code without modifying it (as is sometimes necessary with the time-block approach. I provide three implementations which differ in how the initial time is stored. example usage: tic loop 100 [sine 30] toc elapsed time: 0:00:02 The first approach is plain vanilla; the initial time is stored in a global variable. To minimize name conflicts, I gave it an unusual name: __t__. (feel free to be creative with this name) tic1: func [] [__t__: now/time exit] toc1: func [] [print ["elapsed time:" now/time - __t__]] In the second approach, the initial time is stored in a literal block in the body of the tic function, and then retrieved by toc. tic2: func [] [change [] now/time exit] toc2: func [] [print ["elapsed time:" now/time - first second second :tic2]] In the third approach, the initial time is stored in the body of the toc function which is created by tic. tic3: func [] [toc3: func [] compose/deep [print ["elapsed time:" now/time - (now/time)]]] Just choose the one you like and rename to plain tic and toc. Comments welcome! Larry
[REBOL] Series essay Re:(6)
Gabriele, I think, using your example, that I have found a bug in REBOL. block: copy [] repeat i 4 [use [x] [x: i * i append block 'x]] == [x x x x] do x/1 == 1 do x/2 == 4 x/1 = x/2 == true x/1 == x/2 == true What do you think? Is it a bug? Jerry
[REBOL] Series essay Re:(7)
Jerry, What is 'x supposed to be in your example? block: copy [] repeat i 4 [use [x] [x: i * i append block 'x]] == [x x x x] print block 1 4 9 16 do x/1 ** Script Error: x has no value. ** Where: do x/1 do x/2 ** Script Error: x has no value. ** Where: do x/2 I didn't have any global named 'x, nor did the initialization of 'block create one. Did you perhaps have one left over from some prior activity? -jn- Gerald Goertzel wrote: Gabriele, I think, using your example, that I have found a bug in REBOL. block: copy [] repeat i 4 [use [x] [x: i * i append block 'x]] == [x x x x] do x/1 == 1 do x/2 == 4 x/1 = x/2 == true x/1 == x/2 == true What do you think? Is it a bug? Jerry
[REBOL] logical value referencing ... Re:(2)
Hi Eric, I have a moment, so here is another piece of the puzzle. You wrote: The series used as the range argument must reference the same series that's being searched. You'll see that a "series" is said to reference a "series" - not terribly clear wording, but given that they haven't had time to fully consider Joel's proposals I'd say it's a forgivable lapse. You appear to be unhappy with the wording. I have to agree with you in this case. Here the word series is not used in the sense of a datatype, it is used as a name for a specific value of that datatype. What is being confused is: series: [1 2 3 4] == [1 2 3 4] series? series == true A value of type series! is being referred to by the word 'series. Of course the word series is not the same thing as the datatype series: type? series! == datatype! series? series! == false En passant, when you nail down what the quote is saying, you find that it supports my position. My statement was that only words can be references. The quote happens to use the word 'series to refer to a value of type series! I'm curious what you think? Elan [: - )]
[REBOL] How to form a rule? Re:(3)
Hi Petr, I'm also interested in a good challenge - and I happen to be looking for an opportunity to practive parse rules. If you have the time, could you release (on or off list) a more detailed specification for what you are trying to do? If parse can't handle it well, I'd like to know that that is the case and what the limitation is in your case. TIA, Elan [: - )] At 11:23 PM 12/28/99 +0100, you wrote: [EMAIL PROTECTED] wrote: Hello [EMAIL PROTECTED]! On 27-Dic-99, you wrote: P [thru "s" "om" skip " " "t" thru "t" " " "to" " " "p" skip P skip "se"] What about: [thru "som" skip " t" thru " to p" 2 skip "se"] Well, it doesn't solve my situation actually. The search string user enters can be something like "s?me", and you have to scan for the "s" occurance, followed by the rest of the rule - skip "me" " " etc The buil-rule function seems to work, seems to translate ? and * into right (almost, need to think about t*t case :-) sequences. The problem is really skip to "right" occurance of "s", to match the rule. I am now thinking about using some "ordinary" iteration, which should use 'find, to find "s", and then will try to apply the rule. I know the solution with rule | skip was also suggested here, but I think it will slow things a little bit Anyway, thanks for the help ... -pekr- It shouldn't be a problem to build that. Regards, Gabriele. -- o) .-^-. (--o | Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila | | GIESSE on IRC \ \-\_/-/ / http://www.amyresource.it/AGI/ | o) `-v-' (--o
[REBOL] Series essay Re:(7)
See remarks below: Russell [EMAIL PROTECTED] - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 28, 1999 4:34 PM Subject: [REBOL] Series essay Re:(6) Gabriele, I think, using your example, that I have found a bug in REBOL. block: copy [] repeat i 4 [use [x] [x: i * i append block 'x]] == [x x x x] do x/1 I get an error here; x has no value. Did you mean to use 'block in that expression and below, whereever 'x appears? do block/1 returns 1, do block/2 returns 4. Thus it appears that even though x has no value globally, it can be "done", ie, evaluated. Interestingly, if you precede your "code" with x: 25, it retains that value after executing your first code line. So the x's that appear in block [x x x x] differ from the global x with value 25. == 1 do x/2 == 4 x/1 = x/2 == true x/1 == x/2 == true What do you think? Is it a bug? Jerry
[REBOL] learning to code... Re:
t wrote: I've followed the "thanks" thread with interest, because I'm in a similar boat to Petra's. Probably next semester I'll start with C or Java or somthing. If you have the choice, choose Java or C++ first, then C later. Bjarne Stroustrup recently pointed out that it's better for beginners to learn C++ first, then C. So Rebol won't ruin me for other languages, but instead help me understand them? I'm already loyal to REBOL (its got a very high "cool" rating). But I think I have to really dive in to it to learn it. I've written two funcional scripts, but I'm out of stuff to do. Any ideas about how I can creep up the learning curve? As Elan suggested, a REBOL language or dialect that generates Java or C++ code would be interesting and would greatly increase your skill level in that language and in REBOL. Andrew Martin [EMAIL PROTECTED] http://members.xoom.com/AndrewMartin/ Online @ 33,600 Baud! --
[REBOL] Handy Timer Functions Re:(3)
Larry wrote: tic5: func [/local t] [ t: now/time toc5: func [] [print ["elapsed time:" now/time - t]] ] This might be slightly more accurate/faster: tic6: func [/local t] [ toc6: func [] [print ["elapsed time:" now/time - t]] t: now/time ] I've just swapped the two lines. Andrew Martin [EMAIL PROTECTED] http://members.xoom.com/AndrewMartin/ Online @ 33,600 Baud! --