Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: About arrays of templates

About arrays of templates 15 Nov 2010 11:31 #7729

  • Ra
  • Ra's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Hi all,



At point 15.7 of core language (v. 4.2.1) it talks about matching mechanism
of templates. It includes arrays but I donÂ’t know if the Table 11 is ok, why
I donÂ’t understand if the inside values (AnyElements or AnyElementsOrNone)
and the length restriction can be apply to arrays of templates.



For example,



var template integer v_ta1[3]:={?,?,?}

var template integer v_ta2[3]:=?

var template integer v_ta3[3]:={*,1} Only 2 templates!!!



var integer v_a1[3]:={1,1,1}

var integer v_a2[2]:={1,1}



match(v_a1,v_ta1) --> Is it true? True for me.



match(v_a2,v_ta2) --> Is it false? False for me, because v_ta2 has
three elements and v_a2 has two elements.



match(v_a2,v_ta3) --> If it is false because the number of elements of
template is 3 and the number of elements of value v_a2 is 2, I think that an
array template canÂ’t have AnyElementsOrNone.



With arrays we know the numbers of elements, so I donÂ’t understand the use
of AnyElements or AnyElementsOrNone.



At point 15.7.4 says: “length: restrictions for string length of string
types and the number of elements for record of, set of and arrays”, but with
arrays we know the numbers of elements.





And another question is about point 15.6 “Referencing elements of templates
or template fields”. I think that is right get an element of array template,
but it isnÂ’t explained at this point. For example



var template integer v_t1:=v_ta1[0]; --> v_t1:=?



var template integer v_t2:=v_ta2[2]; --> v_t2:= what is the template
body?



And there are examples more complex according to the matching mechanism of
the array template and if we referencing elements at the left or right hand
side.



Thanks in advance.



BR,



Raúl Alfonso Quintana







MTP - Métodos y Tecnología

C/ Santa Leonor 65 Edificio C - Planta 4

28037 Madrid (SPAIN)

Tel.: +34 911440600

Fax: +34 913044915

<www.mtp.es> www.mtp.es
The administrator has disabled public write access.

About arrays of templates 15 Nov 2010 13:12 #7730

Hello Raúl,

Arrays are in general like record-of-s with a fixed length restriction.
Thus, all things that are true for such record-of-s are also true for
arrays.

The special case of one any-or-omit inside an array-template may not
make much sense, but
just imagine the following example:

var template integer vt1[1000] := { 1, *, 1000 };

I would not want to have to write down the 998 any symbols ;-)

Also, you could have cases where you have several any-or-omit symbols in
your template where it would not be clear which of the any-or-omit has
to match how many elements later on.

BR, Jacob Wieland
Last Edit: 06 Aug 2013 13:42 by Dirk Tepelmann. Reason: original text in reply
The administrator has disabled public write access.

About arrays of templates 15 Nov 2010 16:17 #7731

  • Ra
  • Ra's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Hello Jacob,



Thank you for your answer, but if the “record of” and array are similar with
a fixed length in array it is a great different for me. For example, if in
your example change AnyElementOrNone by AnyElement



var template integer vt1[1000]:={1,?,1000};



I donÂ’t know if that is right. Or



var template integer vt1[3]:={1,*,*,*}



it can be right or wrong. If I try to assign element by element:



vt1[0]:=1;

vt1[1]:=*;

vt1[2]:=*;

vt1[3]:=*; OUT OF INDEX.



And the situation that I put a length restriction



var template integer vt1[1000]:={1,*,1000} length(900) Is it
right?



There are a lot of situation that I canÂ’t understand and I have looked for
it in the core language, but I didn’t find it. At point 15.6 “Referencing
elements of templates or template fields”, it explain the access to element
of structured type templates, but there is nothing about array. For example,
“record” and “record of” are similar but there is an explication for each
type.



BR,



Raúl Alfonso Quintana







MTP - Métodos y Tecnología

C/ Santa Leonor 65 Edificio C - Planta 4

28037 Madrid (SPAIN)

Tel.: +34 911440600

Fax: +34 913044915

<www.mtp.es> www.mtp.es
Last Edit: 06 Aug 2013 13:42 by Dirk Tepelmann. Reason: original text in reply
The administrator has disabled public write access.

About arrays of templates 15 Nov 2010 16:41 #7732

On 11/15/2010 05:17 PM, Raúl Alfonso Quintana wrote:
>
> Hello Jacob,
>
> Thank you for your answer, but if the "record of" and array are
> similar with a fixed length in array it is a great different for me.
> For example, if in your example change AnyElementOrNone by AnyElement
>
> var template integer vt1[1000]:={1,?,1000};
>
This would leave the 997 next fields uninitialized or would be invalid
as it has the wrong length. (same as for record of length(1000)).
>
> I don't know if that is right. Or
>
> var template integer vt1[3]:={1,*,*,*}
>
Would be valid as every * can match also no element. Be careful, the
position of the star is not directly correspondent to the index of the
array.
>
> it can be right or wrong. If I try to assign element by element:
>
> vt1[0]:=1;
>
> vt1[1]:=*;
>
> vt1[2]:=*;
>
> vt1[3]:=*; OUT OF INDEX.
>
Here, the * has a different semantics (actually, it should be forbidden,
as for an element in an array only present templates are valid), meaning
actually '?'.
>
> And the situation that I put a length restriction
>
> var template integer vt1[1000]:={1,*,1000} length(900) Is
> it right?
>
This would be invalid, as the length of the template on the right has
length 902 instead of 1000.
Last Edit: 06 Aug 2013 13:43 by Dirk Tepelmann. Reason: original text in reply
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin