1. Re: When to use Which variable type?

> is there any rule (or logic) as to when one should use an object,
> or a sequence, or any other types over others?

Actually, it is very easy to understand when to use a sequence, atom, or
object.

Sequences are best used when you are planning to deal with a series of
variables using the same type of processing, such as raising the rent on,
say, 100 apartment units with the same percentage of increase. Sequences
are also best when you do not want to store an array of individual values
in each separate variable. Sequences are also usually the best to store
character strings meant for display, like your name or address.

If you are planning to maintain a single value like a counter, or have a
series of values that require unrelated processing, single atom variables
are best. Atom variables are used to accept single keystrokes as
well.

If you are dealing with a Euphoria function that could return either an
atom or a sequence result code but are unsure which will appear, the
object variable is great as a catch-all to accept both an atom or a
sequence return code.

Hope this helps!

David Gay
"A Beginner's Guide To Euphoria"
http://www.interlog.com/~moggie/euphoria.htm

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu