György Réthy (IJ/ETH) wrote:
> We have clause 5.2 in the standard describing general
> parameterization rules. To say there that "type parameterization is
> allowed in other data types and port types only" and enforce it in
> the bnf did not seemed overcomplicated & mismatched to me. But we do
> not have parameterized constants, variables, in templates only
> template field values can be parameterized etc.
Yes, but constants have types, variables have types, etc. I understood
your previous email, that this elements should not be allowed to be of
types that are using type parametrization.
I understood Stephans initial mail that he wanted to have something like:
type record LinkedListElement(Type aType) {
aType value,
LinkedList(aType) next
};
type union LinkedList(LinkedListElementType elementType) {
DummyType empty,
elementType list
};
The would give us the possibility to write something like
type LinkedList(integer) IntegerLinkedList ;
or
type LinkedList(MyRecordType) MyRecordLinkedList ;
[NOTE: This are only quick invented code snippets and by no means meant
to be a basis for consistent definition]
But of course I would like, if I can define in such a way new types, to
use them also a type for a constant, a variable etc.
At least this is my undestanding of type parameterization.
Best regards,
Theo
> Shortly, we have a
> clear type-value-template definitions phylosophy and to change the
> phylosophy of a language seems to be much more problematic. (To be
> clear, at this point I'm not advocating for or against, just sharing
> the first thoughts)
>
> Gyorgy
>
>
>>
Original Message
From: active_ttcn3 : mts stf133 ttcn
>> version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.]On
>> Behalf Of Theofanis Vassiliou-Gioles Sent: Friday, November 21,
>> 2003 1:24 PM To: This email address is being protected from spambots. You need JavaScript enabled to view it. Subject: Re: Type
>> parameterization revisited
>>
>>
>> György Réthy (IJ/ETH) wrote:
>>
>>
>>> Hi,
>>>
>>> The real question would be, where type-parameterized types can be
>>> used. If they could be used in other data type and port type
>>> definitions only (e.g. not even in formal parameters
>>
>> lists), seems to
>>
>>> be manageable.
>>>
>>> If they could be used in constant, variable & template
>>> definitions, formal parameter lists etc., well, this would be a
>>> more tricky area, - I believe - leading to an overcomplicated &
>>> mismatched language with unclarities & lots of exception cases at
>>> the end.
>>>
>>
>> But if you would like to have (1) without having (2) this would
>> also lead to a "overcomplicated & mismatched language with
>> unclarities & lots of exception cases at the end." You would have
>> to define something like "as types of parameters only types that do
>> not make use of type parameterization shall be used". ([lots of
>> exception])
>>
>> As a user I would immediately ask why? ([unclarities])
>>
>> If there is the opinion is that we should first collect the wish
>> list, where we would like to have type parameterization and where
>> we could not imagine that it would be easy to describe and/or
>> implement, I would be in favor of leaving the TTCN-3 type concept
>> as it is.
>>
>> We already now have some "extra rules" for some types. So either
>> types are parameterizable or they aren't. I really believe it would
>> be a bad idea to search just for a few "useful" exceptions and
>> include them somehow in the language.
>>
>> Best regards,
>>
>> Theo
>>
>>
>>
>>> BR, Gyorgy
>>>
>>>
>>>
>>>>
Original Message
From: active_ttcn3 : mts stf133 ttcn
>>>> version 3 - active members only [This email address is being protected from spambots. You need JavaScript enabled to view it.]On
>>>> Behalf Of Stephan Tobies Sent: Friday, November 21, 2003 1:00
>>>> PM To: This email address is being protected from spambots. You need JavaScript enabled to view it. Subject: Type parameterization
>>>> revisited
>>>>
>>>>
>>>> Hi,
>>>>
>>>> and yet another issue that I would like to discuss:
>>>>
>>>> What I think is missing badly from TTCN-3 is real type
>>>> parameterization. This makes writing generic code in TTCN-3
>>>> unneccessarily hard. Yes, we do have the 'anytype' but that is
>>>> not a real answer. Let me give you an example that shows where
>>>> the problem lies and why the anytype is not really a solution:
>>>>
>>>> Assume that we want to implement a generic liked list. One
>>>> possible way to do this in TTCN-3 is with a recursive type
>>>> definition:
>>>>
>>>> type record LinkedListElement { integer value, LinkedList next
>>>> };
>>>>
>>>> type union LinkedList { DummyType empty, LinkedListElement list
>>>> };
>>>>
>>>> type boolean DummyType; // really any type would do
>>>>
>>>> These types allow representation of a linked list in a similar
>>>> way that, say, Java, C, or C++ allow representation of a linked
>>>> list. It is even closed to the way lists are represented in
>>>> functional languages.
>>>>
>>>> Of course there is an obvious flaw with this definition: this
>>>> list can only store integers. There is a straighforward
>>>> improvement:
>>>>
>>>> type record LinkedListElement { anytype value, LinkedList next
>>>> };
>>>>
>>>> Now we can put 'anytype' into this list. But there are still
>>>> two problems:
>>>>
>>>> a) it is not 'type safe', a lilst can mix elements of different
>>>> types and we have to be very careful when accessing elements
>>>> from that list.
>>>>
>>>> b) When we import our LinkedList module into another module,
>>>> the anytype mentioned in the type definition above is the
>>>> anytpe from the LinkedList module. I.e., no type that is not
>>>> known in the LinkedList module can be put into the list.
>>>>
>>>> Problem b) is why anytype is a strictly weaker mechanism than
>>>> real type parameterization. The same problem, for example,
>>>> occurs when definition a protocl with variable payload. What
>>>> should be used to describe the payload? Again, using anytype
>>>> will only allow values of types known in the protocol
>>>> definition module to be used as payload.
>>>>
>>>> This is a very unsatisfactory solution to type
>>>> parameterization. In the absence of generic pointers (void * in
>>>> C, C++, Object references in Java) where is not much we can do
>>>> about these problems except making all those type that shall be
>>>> used in the context of such a generic data structure or
>>>> protocol definition known in the defining module - a clear
>>>> violation of the idea of modularization in the language.
>>>>
>>>> To come to a conclusion - do also other people see this problem
>>>> and would it be worthwhile to start a discussion, how real type
>>>> parameterization could be added to TTCN-3?
>>>>
>>>> BR
>>>>
>>>> Stephan Tobies
>>>>
>>>> -- Stephan Tobies Sr. Research Engineer, Nokia Research
>>>> Center ~ Mobile Networks Lab, Protocol Engineering Group
>>>> E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it. Work Phone:
>>>> +49-234-9842262 Fax: +49-234-9843491 Address: NRC
>>>> Bochum, Meesmannstr. 103, 44807 Bochum, Germany
>>>>
>>>
>>>
>