-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in the code generator for singletons #1475
Comments
This again seems a case of the Sinterklaas issue.
This rule can NEVER be violated. |
You might give the following rule a try:
|
DiagnosisThe compiler generates the following SQL-fragment for computing the violations: select distinct t1.src as src, t1.tgt as tgt
from (select "Module" as src, "Module" as tgt
from "Module" where "Module" = '_UNIVERSE') as t1
left join
(select "Module" as src, "Module" as tgt from "Module"
where "Module" is not null) as t2
on (t1.src = t2.src) and (t1.tgt = t2.tgt)
where (t2.src is null) or (t2.tgt is null) This explains the runtime behavior because |
An alternative way to write the fact that the universe exists might be:
@sjcjoosten , would this be a correct rule in your opinion?
|
I had a call with @stefjoosten . I mentioned the rule In Ampersand, at runtime we have our population in a database, and we check that population for violations of rules. So if we speak about a violation, we actually say that the content of the database violates that rule. Any expression may be used as the expression of a rule. So to check that "_UNIVERSE" exists in our population, we need a properly typed expression:
This must be translated into an SQL expression that checks for violations in the database. It must return nothing if "_UNIVERSE" exists in the concept Module. But what should it return if "_UNIVERSE" is missing?? |
About finding violationsTo find violations of some expression This is exactly what is returned as violations, but is not what you intended. Maybe we need a new operator for this intention? |
Or the rule should be defined something like: RULE newAttempt : V[Module] ; "_UNIVERSE" ; V[Module] |
I have done some more thinking on this issue. The Fortunately, the population must never be empty, because ONE[ONE] is there by definition. At least, a proper implementation of Ampersand must guarantee that. If we take this into account, a true way to express Stef's intention will be:
Currently, I believe it is possible to remove
|
I recently made a demo where to my surprise |
What happened
I ran the following Ampersand script for the purpose of demonstrating that the rule
UniverseExists
guarantees that the atom_UNIVERSE
of typeModule
always exists.I executed the prototype. To my surprise, I found that I can delete module
_UNIVERSE
in the most straightforward way:Screen.Recording.2024-03-29.at.07.26.14.mov
What I expected
I expected that the prototype would not let me delete module
_Universe
. Just to verify, I compiled the script without the population statement. As expected I got a compiler message that noticed the missing module:This confirms my expectation that the back end should not allow me to delete module
_UNIVERSE
.Version of ampersand that was used
I ran the prototype on ampersandtarski/prototype-framework:v1.14, which runs Ampersand-v4.6.2 [51c3de2:refs/tags/v4.6.2] with the following settings: --[no-]backend True --[no-]frontend True --[no-]metamodel False --[no-]terminal False --[no-]time-in-log True --[no-]trim-cellvalues True --build-recipe Prototype --crud-defaults CRUD --frontend-version AngularJS --ignore-invariant-violations False --interfaces False --language Nothing --namespace "" --output-dir "." --proto-dir "/var/www" --sql-bin-tables False --terminal-width Nothing --verbosity debug
The text was updated successfully, but these errors were encountered: