Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » How to declare type of empty collection in OCL?
|
Re: How to declare type of empty collection in OCL? [message #61256 is a reply to message #61231] |
Tue, 14 November 2006 11:21 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Tord,
I'll forward your question to the new OCL newsgroup.
Tord Alenljung wrote:
> How can I declare that for example a Set contains objects of some type
> and then initialize it to be empty. Neither I or II below works, but
> III does.
>
> (I) Not OK
> let a:Set(Integer)=Set{} in a
>
> 'Init expression type does not conform to type of variable (a).'
>
> (II) Not OK
> let a:Set(Integer)=Set(Integer){} in a
>
> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
> "Set(Integer)"'
>
> (III) OK
> let a:Set(Integer)=Set{1,3,2} in a
>
> 2
> 1
> 3
>
> Regards
> Tord
|
|
|
Re: How to declare type of empty collection in OCL? [message #61376 is a reply to message #61256] |
Tue, 14 November 2006 14:12 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Tord,
The element type of a collection literal is inferred from its contents (as
the common supertype of its elements, which may be OclAny or
Collection(OclAny) in mixed cases). The inferred element type of an empty
collection literal is OclVoid, which conforms to all other types, so your
expression (I) should work.
This is a bug. Would you mind raising it? (on the MDT UML2 OCL component):
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MDT& version=1.0.1&component=UML2%20OCL&bug_severity=norm al&form_name=enter_bug
Thanks,
Christian
Ed Merks wrote:
> Tord,
>
> I'll forward your question to the new OCL newsgroup.
>
>
> Tord Alenljung wrote:
>> How can I declare that for example a Set contains objects of some type
>> and then initialize it to be empty. Neither I or II below works, but
>> III does.
>>
>> (I) Not OK
>> let a:Set(Integer)=Set{} in a
>>
>> 'Init expression type does not conform to type of variable (a).'
>>
>> (II) Not OK
>> let a:Set(Integer)=Set(Integer){} in a
>>
>> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
>> "Set(Integer)"'
>>
>> (III) OK
>> let a:Set(Integer)=Set{1,3,2} in a
>>
>> 2
>> 1
>> 3
>>
>> Regards
>> Tord
|
|
|
Re: How to declare type of empty collection in OCL? [message #61449 is a reply to message #61376] |
Wed, 15 November 2006 12:11 |
Tord Alenljung Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Bug report at https://bugs.eclipse.org/bugs/show_bug.cgi?id=164614
Thanks
Tord
Christian W. Damus wrote:
> Hi, Tord,
>
> The element type of a collection literal is inferred from its contents (as
> the common supertype of its elements, which may be OclAny or
> Collection(OclAny) in mixed cases). The inferred element type of an empty
> collection literal is OclVoid, which conforms to all other types, so your
> expression (I) should work.
>
> This is a bug. Would you mind raising it? (on the MDT UML2 OCL component):
>
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MDT& version=1.0.1&component=UML2%20OCL&bug_severity=norm al&form_name=enter_bug
>
> Thanks,
>
> Christian
>
>
> Ed Merks wrote:
>
>> Tord,
>>
>> I'll forward your question to the new OCL newsgroup.
>>
>>
>> Tord Alenljung wrote:
>>> How can I declare that for example a Set contains objects of some type
>>> and then initialize it to be empty. Neither I or II below works, but
>>> III does.
>>>
>>> (I) Not OK
>>> let a:Set(Integer)=Set{} in a
>>>
>>> 'Init expression type does not conform to type of variable (a).'
>>>
>>> (II) Not OK
>>> let a:Set(Integer)=Set(Integer){} in a
>>>
>>> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
>>> "Set(Integer)"'
>>>
>>> (III) OK
>>> let a:Set(Integer)=Set{1,3,2} in a
>>>
>>> 2
>>> 1
>>> 3
>>>
>>> Regards
>>> Tord
>
|
|
|
Re: How to declare type of empty collection in OCL? [message #595597 is a reply to message #61231] |
Tue, 14 November 2006 11:21 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Tord,
I'll forward your question to the new OCL newsgroup.
Tord Alenljung wrote:
> How can I declare that for example a Set contains objects of some type
> and then initialize it to be empty. Neither I or II below works, but
> III does.
>
> (I) Not OK
> let a:Set(Integer)=Set{} in a
>
> 'Init expression type does not conform to type of variable (a).'
>
> (II) Not OK
> let a:Set(Integer)=Set(Integer){} in a
>
> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
> "Set(Integer)"'
>
> (III) OK
> let a:Set(Integer)=Set{1,3,2} in a
>
> 2
> 1
> 3
>
> Regards
> Tord
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to declare type of empty collection in OCL? [message #595643 is a reply to message #61256] |
Tue, 14 November 2006 14:12 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Tord,
The element type of a collection literal is inferred from its contents (as
the common supertype of its elements, which may be OclAny or
Collection(OclAny) in mixed cases). The inferred element type of an empty
collection literal is OclVoid, which conforms to all other types, so your
expression (I) should work.
This is a bug. Would you mind raising it? (on the MDT UML2 OCL component):
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MDT& version=1.0.1&component=UML2%20OCL&bug_severity=norm al&form_name=enter_bug
Thanks,
Christian
Ed Merks wrote:
> Tord,
>
> I'll forward your question to the new OCL newsgroup.
>
>
> Tord Alenljung wrote:
>> How can I declare that for example a Set contains objects of some type
>> and then initialize it to be empty. Neither I or II below works, but
>> III does.
>>
>> (I) Not OK
>> let a:Set(Integer)=Set{} in a
>>
>> 'Init expression type does not conform to type of variable (a).'
>>
>> (II) Not OK
>> let a:Set(Integer)=Set(Integer){} in a
>>
>> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
>> "Set(Integer)"'
>>
>> (III) OK
>> let a:Set(Integer)=Set{1,3,2} in a
>>
>> 2
>> 1
>> 3
>>
>> Regards
>> Tord
|
|
|
Re: How to declare type of empty collection in OCL? [message #595666 is a reply to message #61376] |
Wed, 15 November 2006 12:11 |
Tord Alenljung Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Bug report at https://bugs.eclipse.org/bugs/show_bug.cgi?id=164614
Thanks
Tord
Christian W. Damus wrote:
> Hi, Tord,
>
> The element type of a collection literal is inferred from its contents (as
> the common supertype of its elements, which may be OclAny or
> Collection(OclAny) in mixed cases). The inferred element type of an empty
> collection literal is OclVoid, which conforms to all other types, so your
> expression (I) should work.
>
> This is a bug. Would you mind raising it? (on the MDT UML2 OCL component):
>
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MDT& version=1.0.1&component=UML2%20OCL&bug_severity=norm al&form_name=enter_bug
>
> Thanks,
>
> Christian
>
>
> Ed Merks wrote:
>
>> Tord,
>>
>> I'll forward your question to the new OCL newsgroup.
>>
>>
>> Tord Alenljung wrote:
>>> How can I declare that for example a Set contains objects of some type
>>> and then initialize it to be empty. Neither I or II below works, but
>>> III does.
>>>
>>> (I) Not OK
>>> let a:Set(Integer)=Set{} in a
>>>
>>> 'Init expression type does not conform to type of variable (a).'
>>>
>>> (II) Not OK
>>> let a:Set(Integer)=Set(Integer){} in a
>>>
>>> '1:20:1:31 "collectionTypeIdentifierCS" expected instead of
>>> "Set(Integer)"'
>>>
>>> (III) OK
>>> let a:Set(Integer)=Set{1,3,2} in a
>>>
>>> 2
>>> 1
>>> 3
>>>
>>> Regards
>>> Tord
>
|
|
|
Goto Forum:
Current Time: Wed Sep 25 19:26:54 GMT 2024
Powered by FUDForum. Page generated in 0.30194 seconds
|