Re: Check my code
On Thu, 31 Aug 2000 08:17:54 -0700, Asif Masood Baloch wrote:
>Thanks Brian, you really helped. I have another question. Since Objects
>could be both atoms and sequences, can we declare the atom_recieved &
>integer_recieved as objects also?
>
>integer atom_received, integer_rec --Could be objects as well ?
Absolutely. Every variable in your program could be declared as an
object. But the whole point of declaring variables and specifying a type
is to help track down errors in your program. This is no big deal with
such a small program but it can happen with larger ones. If you know your
variable will/should only hold an integer (not a float nor a sequence of
integers, etc.) then it's best to declare it as such. This will also speed
up execution because the interpretter doesn't have to figure out a
variable's type so that it gets stored properly (again, not such a big deal
with your program but it's a good habit to get into).
>
>object input_string --Clear like a crystal.
In my first reply I declared input_string as an object because I was
thinking of using 'gets' instead of 'get'. The second time, I changed it
back to the way you had originally written it since 'get' always returns a
2-element sequence {error status, value}.
Yes, you could declare it as an object but... (see above). On the other
hand, if you used 'gets' intead of 'get', then you *should* declare it as
an object because either a sequence or an atom (-1) might be returned. (The
atom -1 is returned on end of file.)
I hope I didn't cloud your crystal...
-- Brian
|
Not Categorized, Please Help
|
|