1. value() misleading?
- Posted by Rolf Schroeder <schroeder at DESY.DE> Jan 18, 1999
- 435 views
-- Some time ago I asked if in certain cases value() returns -- misleading results. Run the following program and let me know -- your opinion about the results. -- Thanks, Rolf -- include get.e sequence s, sval s = {} for i = 1 to 9 do -- define 9 + 9 strings s = append(s, (48+i) & (96+i)) end for for i = 1 to 9 do s = append(s, (48+i) & (64+i)) end for puts(1,"Look at these value()-returns:\n\n") for i = 1 to 18 do sval = value(s[i]) -- call value() puts(1,"value(\""&s[i]&"\"): ") if sval[1] = GET_FAIL then -- check error condition printf(1,"{GET_FAIL,%d}", sval[2]) -- print result elsif sval[1] = GET_SUCCESS then -- check error condition printf(1,"{GET_SUCCESS,%d}", {sval[2]}) -- print result else printf(1,"{UNKNOWN,%d}", {sval[2]}) -- should never happen end if puts(1,"\n") end for puts(1,"\n\nI guess, ALL value-returns should give {GET_FAIL,0} for ALL \n") puts(1,"strings do NOT represent legaly written numbers!\n") puts(1,"Any remarks or comments?\n Rolf\n")
2. Re: value() misleading?
- Posted by Jiri Babor <J.Babor at GNS.CRI.NZ> Jan 19, 1999
- 452 views
Rolf wrote: >-- Some time ago I asked if in certain cases value() returns >-- misleading results. Run the following program <snip> I have always felt uncomfortable with this one too. But when I moaned about it, two or three years ago, Rob's answer was, more or less, that's the way he meant it to be! (A bit of irony: last time I tried to come up with something better I finished helping Rob make the existing beast go much faster...) In fact I would prefer a slightly different scheme, a function that would attempt to evaluate the whole string, and return either a sequence of converted values (objects), or just an integer, effectively the string index at which the conversion failed.