Re: Crash or return forbidden value?

new topic     » goto parent     » topic index » view thread      » older message » newer message

We shouldn't assume anything about the system outside of EUPHORIA.  Files and 
DLLs may or may not exist.  They return dummy data (that is the 
term I learned for 'forbidden values' ).  However, when the programmer 
user tries to index data that isn't assigned(variable has no value error) or 
doesn't exist(index error) then this shows a big problem in the code 
and what happens next if we allow this is the code will crash later
continuing to do unsensible things or worse: corrupt a user's data file.

For example, we do assume that if the programmer EUPHORIA code writes 
d[D_NAME] he knows this works and under no circumstances does he want
dummy data.  Even if d is not a valid dir() entry.  Suppose you code:
d = dir("\foo") and then try to use d[D_NAME].  If you have a small number
of files you will get an error.  The programmer has not coded what he
has intended.  If there are at least D_NAME files in \foo then as soon
the programmer passes d[D_NAME] into open() the program will die.  

I know this is rather subjective, but I think the implementation of
open is a sensible balance between dummy values vs. crashing.  If
the expression is not sensible, crash.  If it is sensible but
not valid in the system outside (the OS, the Internet) return dummy.

For example: open_dll returns dummy -1.


Here is a sample program I would write demonstrating how I set things
up:

include joy.e as joy
print(1, joy:min( {5,3} ) ) -- prints 5
print(1, joy:min( 5 ) ) -- error min takes a sequence
print(1, joy:min({}) ) -- runtime error since min({}) 
-- has no mathematical meaning in real numbers.  (Don't tell me about infinity)

Some people would have a min such that min({}) returns -1000000000 but to
me min({}) shouldn't be a defined value.

Shawn Pringle

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu