AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

PrototypeContext.adl does not compile #1461

Open stefjoosten opened 5 months ago

stefjoosten commented 5 months ago

What happened

I tried to compile the AmpersandData/PrototypeContext/PrototypeContext.adl` code with the Ampersand-v5.0.0 compiler, expecting it to compile stand-alone. This code is used to generate prototypes, so I know apriori that it is correct. However, I got compiler errors:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:82 error:
  A relation is used that is not defined: pf_ifcRoles ==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:97 error:
  A relation is used that is not defined: pf_navItemRoles ==============================

Surprisingly, I could not find declarations of the missing relations anywhere in the entire Ampersand repo. So, I speculated that maybe these are "magical declarations" and decided to add these declaratioins in PrototypeContext.adl. An unlikely speculation, but then, a second declaration of the same thing doesn't hurt in Ampersand.

  RELATION pf_ifcRoles[Interface*Role] 
  RELATION pf_navItemRoles[NavMenuItem*Role]

Now I got type conflicts:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:132 error:
  Type error, cannot match:
    the concept PF_NavMenuItem (Src of I[PF_NavMenuItem ])
    and concept NavMenuItem (Src of isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Interfaces.adl:24:82 error:
  Type error, cannot match:
    the concept Interface (Tgt of isPublic [Interface *Interface ])
    and concept PF_Interface (Src of V [PF_Interface *Role ])==============================

I figured that maybe there is more magic in this thing. So, I added

  CLASSIFY Interface IS PF_Interface
  CLASSIFY NavMenuItem IS PF_NavMenuItem

But the search wasn't over. I now got stuck with four compiler errors, the first of which reads:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:111 error:
  Type error, cannot match:
    the concept NavMenuItem (Src of I[PF_NavMenuItem ]-isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)
    and concept PF_NavMenu (Src of I[PF_NavMenu ])==============================

Now I'm really puzzled because this is code that runs correctly when I use it to generate prototypes. I inspected the code of the prototype framework to see which part of the metamodel it uses. This appears to be

    const
        REL_IFC_ROLES               = 'pf_ifcRoles[PF_Interface*Role]',
        REL_IFC_IS_PUBLIC           = 'isPublic[PF_Interface*PF_Interface]',
        REL_IFC_IS_API              = 'isAPI[PF_Interface*PF_Interface]',
        REL_IFC_LABEL               = 'label[PF_Interface*PF_Label]',
        REL_ROLE_LABEL              = 'label[Role*PF_Label]',
        REL_SESSION_ALLOWED_ROLES   = 'sessionAllowedRoles[SESSION*Role]',
        REL_SESSION_ACTIVE_ROLES    = 'sessionActiveRoles[SESSION*Role]',
        REL_NAV_LABEL               = 'label[PF_NavMenuItem*PF_Label]',
        REL_NAV_IS_VISIBLE          = 'isVisible[PF_NavMenuItem*PF_NavMenuItem]',
        REL_NAV_IS_PART_OF          = 'isPartOf[PF_NavMenuItem*PF_NavMenu]',
        REL_NAV_IFC                 = 'ifc[PF_NavMenuItem*PF_Interface]',
        REL_NAV_SEQ_NR              = 'seqNr[PF_NavMenuItem*PF_SeqNr]',
        REL_NAV_SUB_OF              = 'isSubItemOf[PF_NavMenuItem*PF_NavMenuItem]';

@Michiel-s, can you explain to me what I cannot explain?

What I expected

Version of ampersand that was used

Steps to reproduce

1. 2. 3. 4.

Screenshot / Video

Context / Source of ampersand script

hanjoosten commented 5 months ago

Ah, this makes sence to me. Let me try to explain. Initially, I made modifications to all ADL files in FormalAmpersand as well as in PrototypeContext. One of the changes I made was to remove the prefix pf_ from everything. The prefix has no more use, for a namespace is generated automatically for the FormalAmpersand files as well as the PrototypeContext files. I also changes everything else so all these files abide to the new 5.0 syntax (Mostly Name and Label stuff).

Because at the time I did these changes there was no such thing as LABEL, the original names were not preserved as LABEL. This is where you came in. As we discussed previously, you started all over again with the files in AmpersandData. I forgot to inform you that I had removed the prefixes in PrototypeContext files. So please go on with your effort, and don't forget to remove the pf_ prefixes. Sorry for not telling you this before.