On Mon, 19 Apr 2010 16:36:06 +0100
Howard Page-Clark <h...@talktalk.net> wrote:

> On 19/4/10 3:50, spir ☣ wrote:
> > Hello,
> >
> > Total Pascal newbie here. Looked for answers in various references and 
> > tutorials, but cannot find.
> >
> > Fore-question: Is there a (free)pascal teaching/learning mailing list? 
> > (Like python's "tutor" list.) If not, is this one a proper place?
> >
> > * How does one declare the type of set items?
> >     numbers : Set of Integer        // error
> >
> type
>       Tbyteset = set of byte;
> 
> > * How does one define the _value_ of a Set or Array?
> >     numbers := (1,2,3)      // error
> >     numbers := [1,2,3]      // error
> 
> var
>       byteset : Tbyteset;
> 
> begin
>       byteset := []; // empty set
>       byteset := [0, 3, 101]; // puts literal values into the set
>       Include(byteset, 27]; // or byteset := byteset + [27];
>       Exclude(byteset, 3); // or byteset := byteset - [3];
> end;
> 
> Note that set types are limited to 256 elements of ordinal types 
> (integer, char or enumeration).
> 
> Howard

Thank you.
Does this mean that to be able to define a literal value like "byteset := [0, 
3, 101]" for a set (and probably for an array) I must have defined a custom 
type for it; correct? (It's the only difference I see with my trials: numbers 
in my code is not of a custom type but simply a var of type "Set of Integer".)
What I mean is, if the value is a literal, instead of only declaring the var 
then defining its value, one must first make a custom type for it? I don't 
understand the need & purpose of custom types except for records & enums; but 
this may be caused by the fact I come from dynamic languages.

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to