Array as a list of parameters

From Lazarus wiki
Revision as of 00:13, 25 October 2006 by Mischi (talk | contribs) (typos)
Jump to navigationJump to search

Forward

This is an attempt to outline the idea behind using an array as a list of values. These values can be added as a list of parameters inside open array/array of const, instead of a variable type of variable, where the type is for example "array of string".

I will try to write the good and bad regarding this issue and to explain why I think it is a good and very important feature, which FPC could have.

This description will bring out problems, or a need to resolve something, and will try to explain how this thing can help, or where I can find problems with that feature.

I hope more people will contribute to this outline, so we could have this feature implemented in the best way we can have.

Why Do we need such feature ?

To answer that question, let me give you examples, that this feature will solve:

  • We have an array of values from an SQL result, and we wish to use that array, to add for example and output using the "format" function. At this point, in order to do so, we will have to create our own "format" function that will take the array and replace string according to the format string rules, so we could go over all of the fields that an array have.

Pros

  1. This feature will cause the already existed format function, to be valid without the need to rewrite it.
  2. This feature will give better design for how and what data types we are going to use. Instead of writing loops, and even think on different ways of design for output.
  3. Instead of rewriting "every"tm function that developers need to deal with array values, while they accept only open array/array of const,
  4. The write/writelng and read/readln procedures are pasado procedures that created on compile time by the compiler. This option allow the compiler to create such things when developers find themselves need to create their own System unit, or just create pesado procedures just like write/writeln.
  5. This feature will give us debug or just content reading and writing, without any special code written to do so.

Problems

  1. Is it really needed, or does this request just wish to create a laziness when handling array ?
  2. What happen if we need to display fields of record ?
  3. What if we wish to use array as a variable that contain list of values, rather then this idea ?
  4. In what compiler modes should we add such feature ?