Re: Hi
- Posted by "Fam. Nieuwenhuijsen" <nieuwen at XS4ALL.NL> Dec 12, 2000
- 567 views
Vince wrote: > The atoms/sequences/objects thing is a bit much to understand > (I'm used to seperate vars for int, char, double, float. Anyhoo, There isn't anything to understand. You declare variables using: object my_var And then you use it. String, number, float, int, whatever you assign to it, it will work. Only to speed up the performance and to make sure your program is running correctly you could choose to be more specific about the data assigned to the variable: integer my_int However, when you declare something as an 'atom' it doesn't nessecarily mean that its stored as a floating point value internally. When integer math can do the job, it will use just that and convert the value when it 'gets out of range'. You could even write your own 'datatypes'. The purpose of this is not speed (it won't help much), but to get the right kind of error message when something goes wrong in your program. The problem will be caught where it happens, not where it makes your program crash. Example: constant TRUE = 1, FALSE = 0 type hour (object o) -- integer values from 1 to 24 are legal if integer(o) and o > 0 and o < 25 then return TRUE else return FALSE end if end type Now, would you accidently assign "this piece of text" to that variable, Euphoria will halt your program and tell you so. ("type check error"). Normally such a thing would only cause a problem when the value is used and then you have to search for hours where the mis-placed value is coming from. Good luck, Ralf N. nieuwen at xs4all.nl