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

[REBOL] [data type conversion] question

From: gerardcote:sympatico:ca at: 26-Mar-2004 14:10

Hi all, While continuing my work about forthcoming REBOL tutorial for youngsters, I planned some helper function to help them express maths expression using the normal infix and precedence rules - like most calculators do. May be this will not even be included at all with the tutorial but it was a good excuse for me to investigate how I could learn more about the parse word to create some translation tool. This worked for the most part and I went into some real knowledge that I will share here soon and post the final products to the official library to accompany other scripts found there about calculators and related engines. The only real question left came to me when I tried to call my calc with some real but not well formed expressions using a block instead of a string like in the following :
>> to-string [9 / 5 * 100 + 32] ; Here is the well formed version of my test expression
== "9/5*100+32"
>> to-string [9/5 * 100 + 32] ; Here is the ill-formed version of the same expression
** Syntax Error: Invalid date -- 9/5 ** Near: (line 1) to-string [9/5 * 100 + 32]
Finally my question is : Can REBOL be told to not evaluate each element of the block contents I submit him when calling my function but simply replaces the end delimiters [ ] for the appropriately ones " " ? I would simply find more natural to let the user enter the conventional brackets [ ] delimiters around the maths expression to evaluate than remember to use the quotes " ". May be I could even afford for letting the operator to use anyone of them if he desires to do so. In fact when using the quotes as delimiters I can afford the user to write his expressions without having to insert spaces everywhere since I control the expression parsing myself and this is what motivated me in the first case to use the [ ] delimiters also. Don't forget that this is not to replace the conventional expression parser as found in REBOL but to help younger people to start learning without having to bother themselves with not standard maths expressions. Thanks, Gerard