Skip to content
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

Semantics of #-operator #788

Open
RieksJ opened this issue Jun 3, 2018 · 3 comments
Open

Semantics of #-operator #788

RieksJ opened this issue Jun 3, 2018 · 3 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior component:parser component:type checker Syntax

Comments

@RieksJ
Copy link
Contributor

RieksJ commented Jun 3, 2018

Based on that the operator # is called the cartesian product, I would expect the following scriptlet to compile without errors:

CONTEXT Issue788
r :: A * B   REPRESENT Arg1 TYPE ALPHANUMERIC
s :: A * C
t :: A * A [PROP]

RULE "what is wrong": r;"Apotheker"#s~ |- t
ENDCONTEXT

Instead, I get a parser error:

Parsing stumbled upon operator '#'
at that point expecting keyword "META", keyword "PATTERN", keyword "PROCESS", keyword "RULE"
, keyword "CLASSIFY", keyword "RELATION", lower case identifier, keyword "CONCEPT", keyword
"REPRESENT", keyword "ROLE", keyword "SERVICE", keyword "SPEC", keyword "IDENT", keyword "VI
EW", keyword "INTERFACE", keyword "SQLPLUG", keyword "PHPPLUG", keyword "PURPOSE", keyword "
POPULATION", keyword "INCLUDE" or keyword "ENDCONTEXT"

My request is rooted in the observation that Ampersand is said to be robust. Therefore:

  • either remove the # operator (e.g. if there is no difference in implementation between # and ;V;)
  • or implement it properly (e.g. if there is a difference, e.g. in performance of created SQL).

The latter option has at least consequences for the parser (as this issue shows) and the type checker (as is shown by #785), but there may be more to it.

@hanjoosten
Copy link
Member

I have done a brief inspection of the code. There is a huge difference between the code responsible for handling # and that for ;V;. This difference is very likely to cause problems.

I fully agree with @RieksJ that we either remove the operator or implement it properly. I am in favour of removing the # operator from the language all together:

  • As @RieksJ mentions, there is a good alternative, which isn't hard to write.
  • Removal reduces the complexity of learning ADL, for there is an operator less.
  • I think this operator is hardly used at all, so no-one gets hurt by removing it
  • This operator adds unnecessary complexity to the implementation, which is proven by this bug.

@stefjoosten , please give your blessing to the removal and I'll make it so.

@hanjoosten
Copy link
Member

hanjoosten commented Jul 5, 2022

There is another argument to remove the # operator, or at least give it other operational semantics. In constructive mathematics, it is used for the (tight) Apartness relation. In terms of Ampersand, that would come down to V - I.

@hanjoosten
Copy link
Member

By the way, the problem here is that # and ; both bind equally hard. Therefor, brackets should be used in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior component:parser component:type checker Syntax
Projects
None yet
Development

No branches or pull requests

3 participants