[REBOL] Pros and cons Re:

1999-11-21 Thread lmecir
John said: Ok, here is what's at the top of my REBOL wish list: 1. Documentation of the scoping model. ... (rest snipped) I think, there is a help for you with that one... By scope rules are meant the rules the Rebol interpreter follows to resolve the word's binding. The simplest but

[REBOL] Round function Re:(2)

1999-11-22 Thread lmecir
Russell wrote: If you like one-liners, how about: round: func [n][print to-integer n + either n 0 [-.5][.5]] This prints integer closest to n. I am sorry, but this is wrong, too: round -0.5 should be 0 and not -1. Try to compare with these: floor: func [x [number!] /local y] [(y:

[REBOL] Functional programming in REBOL Re:

1999-11-24 Thread lmecir
Hi John, now I can see your point... Have tried to implement immutable lists instead of blocks to use for purely functional programming with o(1) prepend time, but enumerate still doesn't work for more than 1000 elements because of stack overflow... Ladislav

[REBOL] Private attributes

1999-11-26 Thread lmecir
Hi, Rebols! tried this: trial: func [par] [ do func [/local p] [ p: par make object! [ prt: func [] [print p] ] ] ] trial2: func [par /local p] [ p: par make object! [ prt: func [] [print p] ] ] with the following results: a: trial 1 a/prt 1 b: trial 2 b/prt 2 a/prt 1 c:

[REBOL] Private attributes Re:(2)

1999-11-26 Thread lmecir
Elan, THX for explanation. Sorry for the inconvenience, I didn't use my computer to send the last e-mail. Ladislav

[REBOL] Q on Array of Objects Re:

1999-11-27 Thread lmecir
You wrote: I am considering writing an app that would create several hundred or a few thousand copies of a single object. One way to keep track of them is to use an array. A script that tests this syntax is below along with a run which does a "print mold" on the array. It appears that the

[REBOL] Encouraging functional programming Re:(7)

1999-11-27 Thread lmecir
[EMAIL PROTECTED] wrote: Jordan, I calculate the Fibonnacci numbers without recursion using REBOL. For example fib 100 == 3.54224848179262E+20 How would you calculate it with recursion? Jerry fib: func [first second n] [ either n = 1 [first] [ either n = 2 [second] [

[REBOL] Objects: Preventing Code Duplication Re:

1999-12-01 Thread lmecir
Elan wrote: - The following mechanism can be used to avoid inheriting some code. It uses use contexts: ancestor: make object! [ do-something: none use [var-1 var-1 comment {more vars here} func-1 func-2 func-3 ] [ var-1: "this is var-1" var-2: "this is var-2" ;- more

[REBOL] Objects: Preventing Code Duplication Re:(3)

1999-12-01 Thread lmecir
Hi, Elan. You wrote: Hi Ladislav, I like what you did here. What it does not do, is prevent code duplication. - It really does, see later... - I copied the stuff as you wrote it into the REBOL console and added one more, important expression after creating the object 'b: b: make a

[REBOL] Objects: Preventing Code Duplication Re:(3)

1999-12-01 Thread lmecir
Hi, Elan, you wrote: I copied the stuff as you wrote it into the REBOL console and added one more, important expression after creating the object 'b: b: make a [num: num + 1] This additional expression was probe b probe b make object! [ num: 2 messages: make object! [

[REBOL] Objects: Preventing Code Duplication Re:(6)

1999-12-02 Thread lmecir
Hi, Elan, I see your point to use Rebol argument passing. Your idea is quite interesting, i didn't even think about it, because it seemed too complicated to me. The problem is, that if you use the static storage for an argument, you are making another source of ugly bugs - the method calls are

[REBOL] Curried functions

1999-12-03 Thread lmecir
Hi, Rebols, during our discussion with Elan on preventing code duplication in objects it seemed good to have the curried functions. I remember that Jeff submitted something on this, but i lost it somewhere. This is an independent solution, trying to be as complete as possible. Enjoy the

[REBOL] Q on Array of Objects Re:(3)

1999-12-03 Thread lmecir
Hi, Blaz, you wrote: Now a METHOD datatype would make things interesting since I've always had an interest in seeing if one can create a class heirarchy ala Smalltalk within Rebol. I suppose while you're at it adding a METHOD datatype, how about a CLASS datatype ;). Regards Blaz you

[REBOL] Non-reentrant function calling in Rebol

1999-12-03 Thread lmecir
Hi, Rebols, look at this example: ;Identity function, simply duplicates it's input id: func [x [number!]] [:x] ;Increment function, increases it's input by one inc: func [x [number!]] [x + 1] ;The same function as argument samef: func [f [any-function!]] [func [x] [f x]] a: samef :id ;and now

[REBOL] Non-reentrant function calling in Rebol Re:(2)

1999-12-03 Thread lmecir
Hi, Elan, you wrote: Hi Ladislav, look at this example: ;Identity function, simply duplicates it's input id: func [x [number!]] [:x] ;Increment function, increases it's input by one inc: func [x [number!]] [x + 1] ;The same function as argument samef: func [f [any-function!]] [func [x] [f

[REBOL] Objects: Preventing Code Duplication Re:(11)

1999-12-03 Thread lmecir
Hi, Elan you wrote: Hi Ladislav, I wrote: (Oh, and if I concur with my conclusions, please, please make sure that it really does fail!) Read: (Oh, and if YOU concur ... ) Am I being a little self-centered here? ;-) Sorry, Elan - I was so sure, it would fail I didn't test it and

[REBOL] Non-reentrant function calling in Rebol Re:(6)

1999-12-05 Thread lmecir
Hi, Elan, As I understand now, your point of view is, that the definition: samef: func [f [any-function!]] [func [x] [f x]] ; (1) isn't allowed in Rebol "because it doesn't work in Rebol for some reasons ..." (not trying to be personal, just explaining my understanding of what you wrote), so,

[REBOL] Curried functions Re:(2)

1999-12-05 Thread lmecir
Ciao, Gabriele, thanks for your ERROR explanation. Don't you think that CURRIED should have worked as originally written (without the non-re-entrant bugs in Rebol)? Instead of: use [function] [ function: :fnc ... func ... One could write: do func [[throw] /local function] [

[REBOL] Non-reentrant function calling in Rebol Re:(8)

1999-12-05 Thread lmecir
Hi, Jeff, your approach (almost) works, you didn't misuse anything. The problem shows mainly, if you have to write it like this: composite: func [f [function!] g[function!]] [...], then you are out of luck But some nit-picking: even if you do it like this, you do not get a function as result

[REBOL] Non-reentrant function calling in Rebol Re:(10)

1999-12-06 Thread lmecir
Hi Ladislav, we are making progress. That's good and encouraging. you wrote: But think for the second time: 1. Is the samef expected to return a function? Hint: Yes Absolutely! 2. Does it really return a function? Hint: No What?? Of course it returns a function. Oh, my. What do you

[REBOL] Objects: Preventing Code Duplication Re:(11)

1999-12-06 Thread lmecir
Hi, Rebols, Something like: !: func [ object [object!] 'method [word!] /local mth ] [ ; let's skip error checking for clarity mth: get in object/methods method bind second :mth in object 'self return :mth ] ;text skipped a: make object! [ num: 1

[REBOL] Curried functions Re:(3)

1999-12-06 Thread lmecir
Hi, Elan, Your curried doesn't really work. e.g. use this: f: func [x y] [reduce [x y]] But, try the following: recycle/off ;at least the faulty GC will not mess things... curried: func [ "Create curried functions" [catch] fnc [any-function!] "Function to be curried" args

[REBOL] Curried functions Re:(4)

1999-12-06 Thread lmecir
Three cheers for Oliver! - he succeeded to circumvent the GC fault - which I was blind enough not to see. Ladislav -and I didn't succeed to copy the code in my last post, so again, now without a missing row: Rebol [ Title: "Curry" Date: 6/12/1999 File: %curry.r Version: 1.0.0

[REBOL] Curried functions Re:(4)

1999-12-06 Thread lmecir
Three cheers for Oliver! - he succeeded to circumvent the GC fault - which I was blind enough not to see. Ladislav Rebol [ Title: "Curry" Date: 6/12/1999 File: %curry.r Version: 1.0.0 Author: ["Ladislav Mecir" "Oliver Schaefer" "Gabriele Santilli"] Email: [[EMAIL

[REBOL] Curried functions Re:(5)

1999-12-06 Thread lmecir
As you might have probably seen, there are two posts of curry - one of which is missing a line and one is correct. Try the longer one, Selma switched the mails and sent the correct as first and the wrong as second. -Ladislav

[REBOL] Non-functions in Rebol

1999-12-06 Thread lmecir
Joel wrote: [EMAIL PROTECTED] wrote: samef: func [f [any-function!]] [func [x] [f x]] 1. Is the samef expected to return a function? Hint: Yes 2. Does it really return a function? Hint: No Doesn't it? Depends on usage, IMHO. samef: func [f [any-function!]] [func [x] [f x]]

[REBOL] Curried functions Re:(5)

1999-12-06 Thread lmecir
Hi, Elan [some text deleted ...] I think if you take a minute to see how simple the implementation of the curried function really is, something that would be far more complicated to implement in something like Perl, I trust (any Perl experts out there?), you should slowly begin to realize that

[REBOL] Curried functions Re:(8)

1999-12-07 Thread lmecir
Hi, Rebols, Have a look at this, please. Rebol [ Title: "Curry" Date: 7/12/1999 Version: 2.0.0 File: %curry.r Author: "Ladislav Mecir" Email: [EMAIL PROTECTED] Comment: "Thanks, Gabriele" ] ; some helper functions to circumvent a function bug... toblock: func [f

[REBOL] Curried functions Re:(8)

1999-12-07 Thread lmecir
Hi, Rebols, Have a look at this, please. Rebol [ Title: "Curry" Date: 7/12/1999 Version: 2.0.0 File: %curry.r Author: "Ladislav Mecir" Email: [EMAIL PROTECTED] Comment: "Thanks, Gabriele" ] ; some helper functions to circumvent a function bug... toblock: func [f

[REBOL] Non-reentrant function calling in Rebol Re:(10)

1999-12-07 Thread lmecir
Ciao, Gabriele, it was probably a little bit out of thread (although it has much in common) - see the NON-FUNCTIONS. -Ladislav

[REBOL] re-entrancy Re:(2)

1999-12-07 Thread lmecir
Ciao, [...deleted...] However, functions aren't first-class objects if you can't return them as values. They are, and you can. Trust me. :-) [L] Problem is, that you can easily return non-functions (i.e. functions without known value - which aren't functions according to the textbook

[REBOL] A function bug Re:(2)

1999-12-07 Thread lmecir
Hi, Hi, Rebols, found this: block1: [do func[f [any-function!]] [print "OK"] func [x] [print "OK"]] == [do func [f [any-function!]] [print "OK"] func [x] [print "OK"]] block2: [do func [f [any-function!]] [print "OK"]] == [do func [f [any-function!]] [print "OK"]] append block2 :f

[REBOL] A function bug Re:(2)

1999-12-07 Thread lmecir
Hi, Hi Ladislav, I tried duplicating your code on my machine, but since you didn't set 'f to anything in the code you supplied, REBOL reported an error when I tried to evaluate the expression append block2 :f I am therefore limited to commenting on the code you presented: you wrote: block2:

[REBOL] A function bug Re:(3)

1999-12-08 Thread lmecir
Hi, Howdy Ladislav: In this example you posted: --- block1: [do func[f [any-function!]] [print "OK"] func [x] [print "OK"]] == [do func [f [any-function!]] [print "OK"] func [x] [print "OK"]] block2: [do func [f

[REBOL] A function bug Re:(5)

1999-12-08 Thread lmecir
Hi, Hi Ladislav, you wrote: I give you another example: Your composite function: composite: func ['f 'g][func [x] compose [(f) (g) x]] f: func [x [any-function!]] ["OK"] g: func [x] [:x] x: func [x] ["OK"] fg: composite f g [correcting the typo:] result: fg :x ** Script Error: x is missing

[REBOL] A function bug Re:(7)

1999-12-09 Thread lmecir
Hi, Rebols, (Rebol words surrounded by text capitalized) let me introduce another example: f1: func [x] [:x] f2: :type? block1: append copy [do func [x] [print "OK"]] :f1 == [do func [x] [print "OK"] func [x][:x]] block2: append copy [do func [x] [print "OK"]] :f2 == [do func [x] [print "OK"]

[REBOL] A function bug? No Re:

1999-12-09 Thread lmecir
Thanks for every opinion. I think, that the behaviour is really consistent in this case, so if I don't want it as it is, I should circumvent it somehow. Ladislav

[REBOL] Curried functions Re:

1999-12-10 Thread lmecir
Got an improved version of CURRY. Can post it, if anyone's interested. Ladislav

[REBOL] Curried functions Re:(3)

1999-12-11 Thread lmecir
Rebol [ Title: "Curry" Date: 10/12/1999 Version: 2.0.1 File: %curry.r Author: "Ladislav Mecir" Email: [EMAIL PROTECTED] Comment: { The former version had the following limitations: 1. incompatibility with CATCH and THROW attributes in the argument

[REBOL] Type conversion in Rebol?

1999-12-11 Thread lmecir
Hi, tried this: b: to-get-word 'a == :a to-word :b == a c: to-set-word 'a == a: to-word :c ** Script Error: a needs a value. ** Where: to word! value Isn't it a little bit inconsistent? BTW where can I find some documentation on the use of make error! -Ladislav

[REBOL] logical value referencing ... Re:(5)

1999-12-16 Thread lmecir
On 12/16/1999 at 12:17 AM [EMAIL PROTECTED] wrote: [...] On the other hand, I prefer to keep the vocabulary needed to describe REBOL to a minimum. I also like to exploit the similarity of principles, to keep the volume of information needed to reason about REBOL to a minimum. If we just

[REBOL] Passing by reference Re:(3)

1999-12-16 Thread lmecir
Hi Anton, Hmmm. So why doesn't: to-set-word b 1 work then? What is the difference when you assign "to-set-word b" to another word (c) and then use c? Why does your method work whereas mine doesn't? look at this code (you can copy it to Rebol): a: 0 b: 'a c: to-set-word 'a

[REBOL] Passing by reference Re:(5)

1999-12-17 Thread lmecir
So, in Gisle's example of inc: func ['i] [set i (get i) + 1] the expression reduces to i: i+1 where i is an alias for the variable passed to inc ? because the quote tells REBOL to treat i as a symbol rather than as an expression to evaluate? *** REPLY SEPARATOR ***

[REBOL] logical value referencing ... Re:(6)

1999-12-17 Thread lmecir
Hi, Elan. You said: [Offending part deleted...] I think that your terminology introduces grave mistakes in reflecting on how REBOL behaves and constitutes a source for confusion. If I'm not mistaken, the whole point of your approach in this email series ;-) is that you are trying to be able

[REBOL] logical value referencing ... Re:(11)

1999-12-18 Thread lmecir
Merry Christmas and Happy New Millenium to you, Russell, You discovered a rather special property of REDUCE: a: "" same? a reduce a insert reduce a "1" print a Results: a: "" == "" same? a reduce a == true insert reduce a "1" == "" print a 1 a: [] same? a reduce a insert reduce a "1"

[REBOL] logical value referencing ... Re:(8)

1999-12-19 Thread lmecir
Ahoj, Petre, hezke vanoce (Hi, Peter, Merry Christmas) can't resist to show you a few examples of Rebol code (just for fun, don't be afraid). Ex1: f: func [/local a][ do func [] [ a: "" ] insert a "1" ] Results: f == "" f == "" interesting, isn't it? Ex2: a: [""] b:

[REBOL] Guides from logical value referencing .... Re:

1999-12-20 Thread lmecir
Ahoj, Petre, in your previous post you suggested the KISS strategy. All, that I can offer, is a ASAICFO (As Simple As I Can Figure Out) strategy. Let's start with it: 1) meet the notion of Side-Effect Creating Function (or, Function Modifying It's Argument, if you prefer) modify: func [blk

[REBOL] Guides from logical value referencing .... Re:(2)

1999-12-20 Thread lmecir
Correcting the last sentence in my previous post: Who is guilty? (Reduce - in print's implementation, but nevermind, block is still OK) Ahoj, Petre, in your previous post you suggested the KISS strategy. All, that I can offer, is a ASAICFO (As Simple As I Can Figure Out) strategy. Let's

[REBOL] logical value referencing ... Re:(7)

1999-12-21 Thread lmecir
Hi, I had a problem to find your post and respond to it (sorry). just want to point out some errors made by you: 1) In Rebol A and B don't mean the same as you suggest: 'a and 'b, which is misleading. 2) You are inferring: "In REBOL it is a property of literal strings that they are global and

[REBOL] logical value referencing ... Re:(10)

1999-12-23 Thread lmecir
Hi, 1) Instead of saying: "the value/string/block/whatever, 'a is assigned to" I prefer shorter: "A" , simply because I don't like the waste of the (human) bandwidth. 2) You probably didn't notice, but I have proven (not only stated), that the statement: "In Rebol all the literal

[REBOL] logical value referencing ... Re:(13)

1999-12-24 Thread lmecir
Hi, trying to answer your question. (I warned you, no KISS! Let's try your example code with a slight modification - hoping it would be OK with you to do so) code: [ source code words: [ print add write open ] values: [ 1 "hi" ftp://ftp.rebol.com 2 %temp.txt ] fragment: []

[REBOL] Series essay Re:(5)

1999-12-28 Thread lmecir
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,

[REBOL] Series essay Re:(7)

1999-12-28 Thread lmecir
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

[REBOL] logical value referencing ... Re:(2)

1999-12-28 Thread lmecir
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

[REBOL] Series essay Re:(8)

1999-12-29 Thread lmecir
Hi, just a little misunderstanding: Bind modifies it's argument, while Bind/copy doesn't modify the argument and should be used like this: result: bind/copy block word Ladislav Don't know if you tried this, Joel, but here's a few more interesting lines to add to your example. a: 1

[REBOL] Evaluation/functions Re:

1999-12-29 Thread lmecir
Problem: 1) When trying code: ((func [] [print "Executed"])) with the result: ((func [] [print "Executed"])) One is immediately tempted to draw: (i) Rebol functions evaluate to themselves. What do you think about that? Ladislav

[REBOL] Evaluation/functions Re:(3)

1999-12-30 Thread lmecir
OK, I don't know the advertisement, but as far as my knowledge of english is exploited, I would probably interpret it as a funny compliment. What was I trying to underline was this: f: func [] [print "Executed"] (((:f))) with any number of parentheses yields the same result. Another example:

[REBOL] Series essay Re:(9)

1999-12-31 Thread lmecir
Hi, actually: BIND/COPY BLOCK 'C is equivalent to BIND COPY/DEEP BLOCK 'C. 8^) Ladislav Hello [EMAIL PROTECTED]! On 28-Dic-99, you wrote: n ; with the copy refinement, 'e binds to the 'c in the 'f local n context. Nope. block: [a b c] == [a b c] a: 1 b: 2 == 2 use [c]

[REBOL] Evaluation/functions Re:(7)

1999-12-31 Thread lmecir
Happy New Year 2000 to List-Eners! I intentionally started with blocks/strings as the first nontrivial case. The next were functions for me (I consider words as the most complicated datatype with respect to evaluation - because their evaluation is derived from the evaluation of less complicated

[REBOL] Evaluation/parentheses Re:(3)

2000-01-02 Thread lmecir
The word "evaluates" is surely used inconsistently (with two different meanings) throughout the doc's, so I tried to suggest the use of two notions: "evaluates" and "is interpreted (as containing Rebol code)" [EMAIL PROTECTED] wrote: ((expression)) don't force the double evaluation as

[REBOL] Evaluation/functions Re:(11)

2000-01-02 Thread lmecir
What would you choose, if I gave you two choices: a) to be free to interchange 6 and (2 + 4) b) to have some cases where you can't interchange 6 and (2 + 4)? Regards, Ladislav Yup. And this is intuitive for me: (2 + 4) shouldn't be different from 2 + 4. Regards, Gabriele. --

[REBOL] Evaluation/words

2000-01-02 Thread lmecir
From rebol22-draft-manual\expevaluation.html: {{ Words are evaluated somewhat differently than simple values. When a word is evaluated its value is looked-up, evaluated, and returned as a result. }} This statement looks oversimplified to me. It is not valid in the following example: b:

[REBOL] Evaluation Re:(2)

2000-01-03 Thread lmecir
Hi, Joel, "Your colts have been faster, sheriff!" 8^) I felt a need to write something like: "Rebol Values vs. Human Values" to point out some differences between the two notions, so I am picking up the glove. 1) Human Values are considered being the same as long as they are equal as e.g. 2 +

[REBOL] Evaluation Re:(4)

2000-01-03 Thread lmecir
Rebol Values vs. Human Values #2: let's have a look at the following example: a: [] probe a insert a 1 probe a Rebol console: a: [] == [] probe a [] == [] insert a 1 == [] probe a [1] == [1] What are we looking at? Probably everybody feels, that we are probing one Rebol Value twice and

[REBOL] Evaluation/functions Re:(13)

2000-01-03 Thread lmecir
Hi, I am not trying to argue about your personal preferences, but allow me two more questions: 1) what is the meaning of "result" in the case: (print "Hello" 1) , is it only the returned value 1? 2) What would you choose from the four choices: a) the possibility to interchange 2 + 4 and (2

[REBOL] Evaluation Re:(6)

2000-01-03 Thread lmecir
Hi, what I was trying to say, is that for integer values in Rebol you can have only one state, because they are immutable. That means, that you may say: integer value with the state 2 but this is correct too: integer value 2 , because there is no way in Rebol to change it to a different

[REBOL] [Language] functions? Re:(3)

2000-01-05 Thread lmecir
Yes, that is a solution I offered when we (me and Elan) tried to implement the method calling for objects. He didn't like it and objected, that you have to supply a block even in the case, when you do not want to supply any argument. Instead he proposed the use of Do function, which provoked my

[REBOL] Evaluation Re:(4)

2000-01-06 Thread lmecir
Mutable/immutable Rebol values. Adding a correction and examples how you can change the state of mutables. The relations: mutable = series immutable = scalar are pure coincidence, because you can have immutable series and mutable scalars. It is simply a matter of preferences of the

[REBOL] Evaluation Re:(8)

2000-01-07 Thread lmecir
Correction #2: (thx Eric, Gabriele, Joel) any-type ; undecidable any-function ; mutable action ; mutable (change third ...) function ; mutable (change first ...) native ; mutable (change third ...) op ; mutable (change third ...) any-word ;

[REBOL] Evaluation Re:(10)

2000-01-07 Thread lmecir
Hi, thanks, I forgot about it. But, see: Money: a: $100 == $100.00 poke a 2 3 == $3.00 a == $100.00 It seems immutable to me Date: a: 7/1/2000 == 7-Jan-2000 poke a 1 8 == 7-Jan-0008 a == 7-Jan-2000 Time: a: 21:21 == 21:21 type? a == time! poke a 1 22 == 22:21 a == 21:21 Tuple: a:

[REBOL] Evaluation Re:(12)

2000-01-09 Thread lmecir
Hi, Gabriele, I would like to add my $0,02. I think, that alias is another interesting example of a modifying function having some effect on words. I don't think that immutable series can be better for all applications. But, if you ask me, if immutable series are better for storing a

[REBOL] Evaluation Re:(14)

2000-01-11 Thread lmecir
Hi, Gabriele, you wrote: The point I was mainly interested in was this. Being REBOL strongly based on blocks, adding overhead could not be an option. Furthermore, once we have REBOL/View or REBOL/Media, performance can become important in some cases (as can be now with CGI, for example).

[REBOL] Evaluation Re:(14)

2000-01-11 Thread lmecir
Hello, Rebols, did anyone notice the time differences like this?: st/start a: empty-il for i 1 2 1 [a: prepend i a] st/stop == 0:00:03 st/start a: copy [] for i 1 2 1 [insert a i] st/stop == 0:01:36 NB Insert is native as opposed to Prepend written in Rebol the code follows: ; An

[REBOL] Polymorphic

2000-01-14 Thread lmecir
#1 - If I use If as a good example of polymorphism. In Rebol we have two variants- If and Either (which is better and more readable/simple than the obsolete If ... Else pair). In other languages are constructs like: if ... then ... endif if ... then ... else ... endif if ... then ... elsif ...

[REBOL] Polymorphic Re:(4)

2000-01-16 Thread lmecir
Hi, Anrew, it doesn't work in the case: ifs [ false append/only copy [print] "Hi" true [print first "hello"] ] ; Lazy evaluation of multiple 'if-s. Ifs: function [Ifs [block!] /Default Case [block!]] [Block] [ while [not empty? Ifs] [ Block: do/next Ifs if

[REBOL] Polymorphic Re:(4)

2000-01-16 Thread lmecir
Hi, I think, that a mix can easily be achieved as follows: cases-dialect: make object! [ "Dialect for do-cases" else-if: if: func [[throw] condition body [block!] ] [ system/words/if condition [body] ] else: func

[REBOL] Polymorphic Re:(3)

2000-01-23 Thread lmecir
Sorry for disappointing you, but the proposed version doesn't handle correctly the computed blocks and Break. A different approach: ; a helper function db: func [[throw] arg] [ either block? arg [do arg] [arg] ] pif: func [[throw] {polymorphic if, lazy evaluation, minimal checking}

[REBOL] Polymorphic

2000-01-24 Thread lmecir
Hi, Eric, you can never satisfy everyone ;-) Rebol [ Author: Ladislav Mecir Email: [EMAIL PROTECTED] File: %pif.r Comment: { I decided to throw out the default case for the sake of higher compatibility with If and Either. If you want a default, simply use True as

[REBOL] For

2000-01-25 Thread lmecir
Nobody uses For to traverse a series, I guess. OTOH, the implementation of For should be correct. (apologizing, if it was discussed before) My correction to the series traversing part of For is as follows: for: func [ "Repeats a block over a range of values." [catch throw] 'word [word!]

[REBOL] Printing decimal values Re:(2)

2000-01-25 Thread lmecir
Hello, Eric, excellent, although I think, that the textbooks prefer this round: round: func [n [number!] p [integer!] /local factor r] [ factor: 10 ** (- p) n: 0.5 * factor + n n - either negative? r: n // factor [factor + r] [r] ] ; where round -0,5 0 == 0 Hi Michal, Joel,

[REBOL] Patches to REBOL 2.2.0 Re:

2000-01-25 Thread lmecir
Hi, Andrew, could you put in a For patch? Ladislav Eric wrote (in State Machine): ...problem with the to- functions. They should really all be rewritten like this: source to-word to-word: func ["Converts to word value." value "Value to convert"] [to word! value] to-word

[REBOL] Polymorphic Re:(2)

2000-01-26 Thread lmecir
#3 Forward Polymorphic vs. Backward Polymorphic Well, the Solve code was meant only as an example of a more or less working approach. There is a use for something "more polymorphic" and "less polluting", IMHO. Glad to see the interesting discussion. About the C++ - like approach, where the

[REBOL] Polymorphic Re:(3)

2000-01-26 Thread lmecir
#5 Polymorphic operators, only prefix notation supported :-( Let us look at the following: ; currently alpha stage, trying to improve it, it is attached do %polymorphic.r complex: make object! [ type: 'complex! re: im: 0 ] polymorphic [minus a b] register 'minus [complex! complex!] []

[REBOL] Polymorphic Re:(2)

2000-01-27 Thread lmecir
Hi, I assume you meant: register 'minus [integer! complex!] [] [ make complex [ re: a - b/re im: - b/im ; not im: b/im ] ] Shouldn't the signatures look more like: signatures: [[integer! complex!] [complex! complex!]] Yes, thanks. I'm also a little

[REBOL] Character encoding/decoding

2000-01-20 Thread lmecir
Hi, there was a demand for a decoding/encoding program between MAC and PC. Here's the one I use for some Czech code pages: Rebol [ Title: "Code" Date: 27/10/1999 File: %code.r ] ; a function to translate coding table into a 256 character string translate-coding: func[table

[REBOL] sfun

2000-01-31 Thread lmecir
Hi, Rebols, while writing something more complicated, I came to this. You may find some use for it: Rebol [ Title: "SFun" Author: "Ladislav Mecir" Email: [EMAIL PROTECTED] Date: 31/1/2000 Purpose: { A "replacement" for a GC-proof Use } Version: 1.0.0 ] sfun:

[REBOL] [REBOL]HELP!! Inserting text problems Re:

2000-02-09 Thread lmecir
Hi, Tim, I see three issues in your code. The first one: if you want to insert something you can try: foreach txt insert_txt [ fp: insert fp txt ] Ladislav I am attempting to insert text into a file: I have a series of strings defined thus: insert_txt: ["first new line" "second new

[REBOL] static variable Re:

2000-02-09 Thread lmecir
Hi, you can use this: Rebol [ Title: "SFun" Author: "Ladislav Mecir" Email: [EMAIL PROTECTED] Date: 31/1/2000 File: %sfun.r Purpose: { A function with static variables } Version: 1.0.0 Category: [General] ] sfun: func [ {create a function with

[REBOL] Split-path correction

2000-02-26 Thread lmecir
Hi, after having some problems with split-path, here is my version: (Andrew, it may be nice to have it in your %patch.r) split-path: func [ { Splits a file or URL. Returns a block containing path and target. Overcomes some limitations of the Core split-path like strange

[REBOL] exists?

2000-02-26 Thread lmecir
Hi, Rebols, I know, that it has been discussed, but I think, that the following improvement to Core Exists? may be useful. Any suggestions are welcome. Regards, Ladislav exists?: func [ { Determines if a file or URL exists. Checks for invalid HTML pages. }

[REBOL] Split-path correction Re:(2)

2000-02-28 Thread lmecir
Hi, Andrew, split-path %file.r == [%./ "file.r"] I don't think, that this is correct, because the second element of the result has got a wrong type and, moreover, the first element is incorrect, because the identity: file = (append copy first r: split-path file second r) is not preserved,

[REBOL] exists? Re:(2)

2000-02-28 Thread lmecir
Hi, try this: exists? http://www.rebol.com/nonsense.r Regards, Ladislav - Puvodní zpráva - Od: [EMAIL PROTECTED] Komu: [EMAIL PROTECTED] Odesláno: 27. února 2000 1:52 Predmet: [REBOL] exists? Re: Hi, Ladislav. I know, that it has been discussed, but I think, that the

[REBOL] none Re:

2000-02-28 Thread lmecir
Hi, Your observation was reported to feedback by me before and it has been assigned ticket #2409. OTOH, if you check the code more thoroughly, URL! never changes to File!. Regards, Ladislav Hi folks, I was just playing around with Ladislav's fix of SPLIT-PATH. I was wondering why he

[REBOL] Split-path correction Re:(2)

2000-02-28 Thread lmecir
Hi, it isn't that bad. Have a look, please: split-path2 http://fgdfgdfg.Fgdfg/fgdfgdfg/dfgdfg == [http://fgdfgdfg.Fgdfg/fgdfgdfg/ dfgdfg] type? second split-path2 http://fgdfgdfg.Fgdfg/fgdfgdfg/dfgdfg == url! Regards, Ladislav - Puvodní zpráva - Od: [EMAIL PROTECTED] Komu:

[REBOL] Split-path correction Re:(4)

2000-02-28 Thread lmecir
Hi, you wrote: There is also others problems with the original split-path: split-path http://www.rebol.com == [http:// %www.rebol.com] split-path http://www.rebol.com/ == [http:// %www.rebol.com/] I would prefer to get == [http://www.rebol.com/ none] in both cases, as in the

[REBOL] Catching Web Site Access Errors Re:

2000-03-01 Thread lmecir
Title: Catching Web Site Access Errors Hi, you may try the following: exists?: func [ { Determines if a file or URL exists. Checks for invalid HTML pages. } target [file! url!] /local port comp ts][ if error? try [ port: make port! target query port ] [return false] if not

[REBOL] Why doesn't this work? Re:(3)

2000-03-07 Thread lmecir
Hi, Eric, you wrote: Thanks for the help. The error message I received seems pretty odd though. .:Eric Explanation: obj: make object! [a: "" b: ""] t: 'obj new-obj: make t [] ** Script Error: Expected one of: word! - not: block!. ** Where: new-obj: make t [] when Make encounters a

[REBOL] Money Trouble? Re:(2)

2000-03-08 Thread lmecir
Hi, I want to present a different point of view. My experiences are, that the binary representation is as good as the BCD for the accounting purposes. I do have an accounting program in Rebol using Decimal! as its basic type. If you want to be exact, you shall always be careful of what you are

[REBOL] Why doesn't this work? Re:

2000-03-04 Thread lmecir
Hi, two possibilities, the first looks better: 1) obj: make object! [a: "" b: ""] t: obj new-obj: make t [] 2) obj: make object! [a: "" b: ""] t: 'obj new-obj: make get t [] Ladislav obj: make object! [a: "" b: ""] t: 'obj new-obj: make t [] When I try it, I get the following

[REBOL] Getting a function body block from standard input Re:(3)

2000-03-23 Thread lmecir
Hi, AP wrote: Here is some of my code... prin y: load ask ["What is your function? y = "] yfunc: func [x] [y] I enter [2 * x + 1] Later code for x xmin xmax step [ print [x " " yfunc x] ] Then I get as output 0 2 * x + 1 5 2 * x + 1 10 ...

  1   2   3   >