D
doolittle
Hi,
I am working on a file parser, and a program that deals with the
ouptput of the parser (i'll call that the user).
I am using Perl, although I think the issues are general.
Now the user wants to get the value of a particular thing in the file.
Currently, this value could be scalar (a string), an array, or
undefined (if the thing was not in the file). Call them type3.
Some things have to be a scalar value, or undefined (or else the parser
reports the file is incorrect). Call them type2.
(other things have to be a scalar value, although i only just realised
that, call them type1. They can be caught by the parser if undef)
(Which type a thing must be is known before the file is parsed.)
I am thinking, why not (in the parser), put everything (not type1 -
well maybe) into an array, so the user just has to deal with two
possibilities (array or undefined). ie force everything of type2 or
type3 into a new type - type2A, which is either an array or undefined.
Is this a good idea?
The other possibility is just force everything of type3 into a new
type, type3A, which is which is either an array or undefined.
Should i try to make things easier for the user, or is it up to them to
deal with the basic types correctly?
dan
I am working on a file parser, and a program that deals with the
ouptput of the parser (i'll call that the user).
I am using Perl, although I think the issues are general.
Now the user wants to get the value of a particular thing in the file.
Currently, this value could be scalar (a string), an array, or
undefined (if the thing was not in the file). Call them type3.
Some things have to be a scalar value, or undefined (or else the parser
reports the file is incorrect). Call them type2.
(other things have to be a scalar value, although i only just realised
that, call them type1. They can be caught by the parser if undef)
(Which type a thing must be is known before the file is parsed.)
I am thinking, why not (in the parser), put everything (not type1 -
well maybe) into an array, so the user just has to deal with two
possibilities (array or undefined). ie force everything of type2 or
type3 into a new type - type2A, which is either an array or undefined.
Is this a good idea?
The other possibility is just force everything of type3 into a new
type, type3A, which is which is either an array or undefined.
Should i try to make things easier for the user, or is it up to them to
deal with the basic types correctly?
dan