Blast you Vilmos and Your Clever Cleverness!
-
I have an expression evaluator and, amongst other things, I'm extending it with function definition goodness. Each expression takes a data set as input - name value pair type thing - and uses it to return a value: Egg:
data {
a % 1
b % 2
}
expression - a + bThis would take the two values and return their sum [3 for the hard of thinking] Now I started to get clever in defining the function to allow variable arguments and it seemed to be working well until I tried to some clever re-cursiveness:
function {
~ allows the function to take unlimited arguments as it just represents the data:
arguments - ~
function "
# if item 1 is null return item 0
[isNull ~1] ?
~0 :
(
# clone the input [~ is everything]
data = [data.clone ~];
# remove item 0
[data.remove data "~0"];
# and call back... with ... a ... single ... argument
max = [max data];
~0 > max ?
~0 :
max
)
"
}So it compares a number with a data set and goes boom. Who'd have thunk it! Stupid Vilmos, very stupid Vilmos! I am now in the process or rewriting so that I must pass a fixed number of arguments, but by using a data set the arguments are variable. [edit] After fixing it, I then found that running the full test lots of previously fine tests now fail, total WTE ensues. I check the code, I check the functions in the test script, I even extend the logging to try and find what I've changed. What I did was change the block name for common functions so they wouldn't be loaded...
speramus in juniperus
-
I have an expression evaluator and, amongst other things, I'm extending it with function definition goodness. Each expression takes a data set as input - name value pair type thing - and uses it to return a value: Egg:
data {
a % 1
b % 2
}
expression - a + bThis would take the two values and return their sum [3 for the hard of thinking] Now I started to get clever in defining the function to allow variable arguments and it seemed to be working well until I tried to some clever re-cursiveness:
function {
~ allows the function to take unlimited arguments as it just represents the data:
arguments - ~
function "
# if item 1 is null return item 0
[isNull ~1] ?
~0 :
(
# clone the input [~ is everything]
data = [data.clone ~];
# remove item 0
[data.remove data "~0"];
# and call back... with ... a ... single ... argument
max = [max data];
~0 > max ?
~0 :
max
)
"
}So it compares a number with a data set and goes boom. Who'd have thunk it! Stupid Vilmos, very stupid Vilmos! I am now in the process or rewriting so that I must pass a fixed number of arguments, but by using a data set the arguments are variable. [edit] After fixing it, I then found that running the full test lots of previously fine tests now fail, total WTE ensues. I check the code, I check the functions in the test script, I even extend the logging to try and find what I've changed. What I did was change the block name for common functions so they wouldn't be loaded...
speramus in juniperus
I always try to keep these wise words in mind: "Just when you think that you've got it... it blows up in your face." -- The Leslie Spit Treeo http://www.youtube.com/watch?v=BKb_cPzpNNQ[^]