ridgeworks / clpBNR

CLP(BNR) module for SWI-Prolog
MIT License
38 stars 5 forks source link

Single / double colon syntax #10

Closed jacobfriedman closed 2 years ago

jacobfriedman commented 2 years ago

The "Older" syntax gives single-colons for attributed numbers e.g. where [_Y: real(1.732..., 1.732...)]., which clashes with Prolog's module declaration (colon).

Rather than a double-colon, would it be ideal to write interval/R e.g. real(L,H) declarations as a module (i.e. an interface), rather than with the double colon?

As an aside, I'm also considering using syntax such as Y⟦L,H⟧ (yes, UTF-8) to express interval notation in Prolog.

ridgeworks commented 2 years ago

... which clashes with Prolog's module declaration (colon).

That's correct.

Rather than a double-colon, would it be ideal to write interval/R e.g. real(L,H) declarations as a module (i.e. an interface), rather than with the double colon?

I don't understand the suggestion. clpBNR is a module and :: is part of its interface. Can you be more specific?

As an aside, I'm also considering using syntax such as Y⟦L,H⟧ (yes, UTF-8) to express interval notation in Prolog.

Go for it. Prolog is an excellent environment for developing new domain specific languages and mapping them to underlying infrastructure. But I'm not going to modify, or add, to the existing clpBNR interface without reasonable justification. (Just remember that users have to type any characters that are part of any new syntax on their existing keyboards.)

jacobfriedman commented 2 years ago

Referring to syntax such as Type:integer(1,3) or [Red,Green,Blue]:boolean, I was wondering if there was any historical correlation to the module system in ISO Prolog.

jacobfriedman commented 2 years ago

That is, if it were ever intended to be used as a mixed-in interface with the module system.

ridgeworks commented 2 years ago

Referring to syntax such as Type:integer(1,3) or [Red,Green,Blue]:boolean, I was wondering if there was any historical correlation to the module system in ISO Prolog.

Ah, no. The original BNR Prolog system predates ISO and had a different modularity model which didn't use ":", so it was available for use in CLP(BNR). In targeting SWI-Prolog, the single colon used by CLP(BNR) was changed to double colon for library(clpBNR). (In fact the whole implementation is new, as I mentioned previously.)

jacobfriedman commented 2 years ago

Great, thank you for the clarification.