0

General

I don't understand why there are like 2 generating_type kinds, the one with exclamation point, and the other not.

My case

I have a function returning a DB_SERVICE[G] from a given instance from a collection of db_services so that from another service I can retrieve it and call it. When I pass an instance generating_type to that function, the conforms_to returns True, as when I give ({ENUMERATE}).generating_type it doesn't.

Why is that so?

-- Humanly unreadable
if attached {ENUMERATE_DB_SERVICE} {SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type (item_prototype.charge_unit_relationship.secondary_prototype.an_index_relationship.secondary_prototype.generating_type) as l_enum_dbs then

-- Humanly readable but not working
if attached {ENUMERATE_DB_SERVICE} {SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type (({ENUMERATE}).generating_type) as l_enum_dbs then

My function

db_service_from_entity_type (an_entity_type: TYPE[detachable DB_ENTITY]): detachable like db_services.item
    do
        across
            db_services as l_dbs
        until
            Result /= Void
        loop
            if l_dbs.item.item_prototype.generating_type.conforms_to (an_entity_type) then
                Result := l_dbs.item
            end
        end
    ensure
        service_found: attached Result
    end

Edit (20190405-11:26 UTC)

As the screenshot shows, giving {ENUMERATE} instead of ({ENUMERATE}).generating_type doesn't work either

enter image description here

Pipo
  • 4,653
  • 38
  • 47
  • What is the type of `...secondary_prototype`? – Alexander Kogtenkov Apr 05 '19 at 11:12
  • @AlexanderKogtenkov `{SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type (item_prototype.charge_unit_relationship.secondary_prototype.an_index_relationship.secondary_prototype` is `ENUMERATE` (`an_index_relationship: IDENTIFIABLE_MANY_TO_ONE[like Current, ENUMERATE]`) – Pipo Apr 05 '19 at 11:29
  • @AlexanderKogtenkov if you need some more Info, I can provide you debugger screenshots of both versions – Pipo Apr 05 '19 at 11:35

1 Answers1

1

generating_type returns a dynamic type of an object. Therefore, ({ENUMERATE}).generating_type produces TYPE [!TYPE [!ENUMERATE]]. But you need just TYPE [ENUMERATE]. This can be achieved by removing the call to generating_type and using a detachable version of the type: {detachable ENUMERATE}.

The corresponding object test would look like

if attached {ENUMERATE_DB_SERVICE} {SIT_ENVIRONMENT}.app_instance.db_service_from_entity_type
    ({detachable ENUMERATE}) as l_enum_dbs then
Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35
  • Thx but I tried and it gave me the same result... see my edit – Pipo Apr 05 '19 at 12:30
  • @Pipo I've update the code to take attachment status of the type into account. – Alexander Kogtenkov Apr 05 '19 at 13:25
  • Thx, so does the `!` before a type mean detachable? that is part of the answer I'm looking for... – Pipo Apr 05 '19 at 13:33
  • `!` means `attached`. It comes from the old syntax used to denote attached types. – Alexander Kogtenkov Apr 05 '19 at 13:52
  • sorry but now I'm confused, so the execution was comparing `{!ENUMERATE}` and `{ENUMERATE}` and this was not conform. When you give `{detachable ENUMERATE}` this is traduced into `{!ENUMERATE}`??? and all that because my secondary_prototype is ENUMERATE but not detachable (the reason of a prototype on my semantic)!!! – Pipo Apr 05 '19 at 14:34
  • `TYPE [ENUMERATE]` stands for `detachable ENUMERATE` and `TYPE [!ENUMERATE]` stands for `attached ENUMERATE`. And the former does not conform to the latter. – Alexander Kogtenkov Apr 05 '19 at 14:51