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

TOPIC: AnyElement with length restriction

AnyElement with length restriction 21 Nov 2012 15:41 #7809

Hello all,
in the core language specification (v4.4.1) paragraph B1.4.1 it is
specified that the length field can be attached to an '?' in AnyElement
context.
In my opinion this is ambiguous.

Given the following example:

type record of integer RoI;
type record of RoI RoRoI;

var template RoI t_roi := ? length(2);
var template RoRoI t_roroi1 := { {3, 4, 5}, ? length(2)};
var template RoRoI t_roroi2 := { {3, 4, 5}, t_roi};

It could be interpreted as
a) AnyElement restricted to the specified length
b) AnyValue containing itself a restricted number of elements

So my question is what kind of value t_roroi1 and t_roroi2 would match.

a) Does t_roroi1 match
var RoRoI vroroi := {{3,4,5}, {1}, {0}}

b) Does t_roroi2 match
var RoRoI vroroi := {{3,4,5}, {1,2}}

or do both templates match the same value. If yes which one of the
alternatives.


Any suggestions are welcome.

BR.,
Uwe
The administrator has disabled public write access.

AnyElement with length restriction 22 Nov 2012 08:31 #7810

Hello Uwe,

Both, t_roroi1 and t_roroi2 match the same values, i.e. all values of the
form { {3,4,5}, {?, ?} }

I think you confuse this with * length(2) inside values (AnyElementsOrNone
with length restriction).

There, a template of the form { {3,4,5}, * length(2) } would match all
elements of the form { {3,4,5}, ?, ? }, where both ? would again match
records of integers (i.e. this is equivalent to { {3,4,5}, {*}, {*} }).

Since this construct is only allowed inside values, it does not make sense
to use it as the top-level template right-hand-side.

BR,

Jacob Wieland
Last Edit: 05 Jul 2013 13:25 by Silvia Almagia.
The administrator has disabled public write access.

AnyElement with length restriction 22 Nov 2012 09:24 #7811

Hi Uwe,

I don't think that it is ambiguous, just the whole picture has to be considered, instead of a partial one. Anyway, once the question has been raised, it may worth to clarify the point by an example in the standard. If, on reading my mail, you still think that a clarification by example would be necessary, pls. submit a CR.

The length _attribute_ modifies the meaning of the matching mechanism it is attached to.

Let us forget about the length(2) for a while. Clause B.1.3.1 Any element says: " The matching symbol "?" (AnyElement) is used to indicate that it replaces SINGLE elements of ... a record of, a set of or an array."
Therefore t_roroi1 in your example cannot match vroroi, as it can mach values with two elements only, where the first one shall be {3, 4, 5}.

Lets see what shall be the second element of a value matching t_roroi1; Clause B.1.4.1 Length restrictions says that " length restriction attribute is used to restrict the length of ... the number of elements in a set of, record of or array structure." Therefore, due to length(2), the second element shall be a record of integer, containing exactly two integer elements. Actually, this is the meaning of t_roi as well. Therefore, t_roroi1 and t_roroi2 shall match the same subset of values, for example, your solution b).


BR, Gyorgy
Last Edit: 05 Jul 2013 13:28 by Silvia Almagia.
The administrator has disabled public write access.

AnyElement with length restriction 22 Nov 2012 12:38 #7812

Hello György, hello Jacob,
thanks for pointing me to the right behaviour. Nevertheless the Note in
B1.3.1:

' The "?" in field4 can be interpreted as AnyValue as an integer value,
or AnyElement inside a record of, set of or array. Since both
interpretations lead to the same match no problem arises.'

was misleading me.
Thus in my case one interpretation could be:
a) "?" is AnyValue and length(2) tells me that this AnyValue is of type
RoI and would expand to RoI:{?, ?}
b) "?" is AnyElement and length(2) tells me that there must be exactly 2
elements of type RoI each of it containing AnyValue (i.e. equivalent to
* length(2)) -> RoRoI:{{3, 4, 5}, RoI:?, RoI:?}

So in my opinion we really need an example (either in B1.3.1 or B1.4.1)
and maybe some change in this NOTE from B1.3.1 as "both interpretation"
does not always lead to the same match.

BR.,
Uwe
Last Edit: 15 Jul 2013 08:02 by Silvia Almagia.
The administrator has disabled public write access.

AnyElement with length restriction 22 Nov 2012 13:37 #7813

Hi Uwe,

Actually, the logic of b) is incorrect; you cannot separate the meanings of ? and length, as length only restricts the ? preceding it; the whole "? length(2)" shall be considered either to be a (RoI) AnyValue or to be a (RoRoi) AnyElement. If you consider "? length(2)" as AnyValue-for-RoI-with-restricted-length, you have exactly what Jacob wrote: {?,?}.

But pls., could you submit a CR on this issue that we could review the text of the note and consider including an example?

BR, Gyorgy
Last Edit: 15 Jul 2013 08:03 by Silvia Almagia.
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin