[erlang-questions] CORBA recursive types

Niclas Eklund nick@REDACTED
Thu Dec 23 15:56:05 CET 2010


Hello!

Yes, I agree, in your case it would be easier to use valutype. For you who 
doesn't know, but are a bit curious, valuetype is something in between 
'interface' and 'struct' types in IDL.

A limited support for valuetype (skipping functions/interfaces for now) 
would be one way forward. One should use a similar solution as oe_tc/1 
functions found in the generated stubs/skeletons. For example 
CosNaming/NamingContextExt which inherits from CosNaming/NamingContext:

%% CosNaming_NamingContextExt.erl
<CUT>
oe_tc(resolve_str) ->
 	{{tk_objref,[],"Object"},[{tk_string,0}],[]};
<CUT>
oe_tc(list) -> 'CosNaming_NamingContext':oe_tc(list);
oe_tc(_) -> undefined.

This way for example the 'CosNaming_NamingContext':list function can be 
altered without having to update CosNaming_NamingContextExt.erl.

Best Regards,

Niclas E @ Erlang/OTP

On Tue, 21 Dec 2010, Rudolph van Graan wrote:

> Hi Niclas,
>
> We use CORBA for everything... Really :) (When we have to publish APIs and build interfaces between systems). This is an example of what can't be done (easily) in CORBA:
>
> Assume this is a structure that stores an abstract type called "Party"
>
>>   struct Party {
>>     CEMCommon::Identifier division_id;
>>     CEMCommon::Identifier party_id;
>>     CEMCommon::Classifier party_class;
>>     CEMCommon::Identifier status;
>>   };
>
> now we need to "extend" it to two very different structures, but both of them have the same fields as Party:
>
>>   struct Person { //Extends Party
>>     wstring<100> lastname;
>>     wstring<100> names;
>>     wstring<50> title;
>>   };
>>
>>   struct LegalOrganisation {  //Extends Party
>>     wstring<100> name;
>>     wstring<30>  registration_nr;
>>     wstring<30>  tax_number;
>>   };
>
> (we have many API functions operating on Party, so it would be very nice to just pass Party or a derivative to it).
>
> Then I can inherit Person from Party and LegalOrganisation too. And none of the base interface functions have to change.
>
> We cheat now, and get something vaguely similar:
>
>>   struct Party {
>>     CEMCommon::Identifier division_id;
>>     CEMCommon::Identifier party_id;
>>     CEMCommon::Classifier party_class;
>>     CEMCommon::Identifier status;
>>     PartyDetail detail;
>>   };
>
>>   union PartyDetail switch(PartyClass) {
>>   case LEGAL_PERSON:       Person person;
>>   case LEGAL_ORGANISATION: LegalOrganisation legal_organisation;
>>   default:                 any unsupported_object;
>>   };
>>
>
> (technically we embed the extended information inside either an ANY type or a union). But this is nasty and it does not lead to simple code as you can imagine.
>
> I am not so much looking for the support for functions/interfaces, but certainly for the ability to (cleanly) extend structs.
>
> Thanks
>
> Rudolph van Graan
>
>
> On Dec 21, 2010, at 3:54 PM, Niclas Eklund wrote:
>
>>
>> Hi!
>>
>> I'd like to quote Mark Twain:
>>
>> - "The reports of my death are greatly exaggerated!"
>>
>> Orber/CORBA is very much alive and kicking, but you probably see it more often in Telco OaM apps (Google for - 3gpp CORBA). Since these are based on standard IDL API:s, the need for adding support for some types isn't that great.
>>
>> It should be rather straight forward to add valuetype. I.e. mimic interface inheritance. The TypeCode struct member list in the genrated Derived.erl module should contain the atom 'Base', so that that module's tc() function would be invoked/used when decoding/encoding an instance of Derived. The IFR also needs to be updated (the Light version is sufficient) since valuetype is a new data type. This means that there are some other modules that must be updated besides those in the git commit.
>>
>> It would be interesting to hear about the major obstacle you think valuetype would solve.
>>
>> Niclas E @ Erlang/OTP
>>
>>
>> On Tue, 21 Dec 2010, Rudolph van Graan wrote:
>>
>>> Ah Brilliant! I was beginning to fear that CORBA is a dying project. Any idea how one can go about supporting the valuetype construct? I am willing to help out if somebody can give me a few pointers on where what needs to be done.
>>>
>>>> valuetype Base {
>>>>  long    some_data;
>>>> };
>>>>
>>>> valuetype  Derived : Base {
>>>>  long    more_data;
>>>> };
>>>
>>> The reason for this request is that valuetype enables the re-use for structs, i.e. in some kind of inheritance scheme and that solves one major obstacle.
>>>
>>> Thanks
>>>
>>> Rudolph van Graan
>>>
>>>
>>>
>>> On Dec 21, 2010, at 11:45 AM, Niclas Eklund wrote:
>>>
>>>>
>>>> Hello!
>>>>
>>>> Since the question has been asked previously on this list, I'd like to inform that IC and Orber now support recursive types (union and struct) for the CORBA backend:
>>>>
>>>> https://github.com/erlang/otp/commit/1de445e76dee4e9473eadf7f6bd0dcb26a295a64
>>>>
>>>> For more information, see chapter "OMG IDL to Erlang Mapping" in the User's Guide.
>>>>
>>>> Happy Holidays!
>>>>
>>>> Niclas E @ Erlang/OTP
>>>>
>>>> ________________________________________________________________
>>>> erlang-questions (at) erlang.org mailing list.
>>>> See http://www.erlang.org/faq.html
>>>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>>>
>>>
>>>
>>
>>
>
>




More information about the erlang-questions mailing list