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

Imperfection of creating operators #596

Open
flexoron opened this issue Sep 18, 2024 · 9 comments
Open

Imperfection of creating operators #596

flexoron opened this issue Sep 18, 2024 · 9 comments

Comments

@flexoron
Copy link

v2.56.12

$ tpl
?- current_op(X,Y,&).
   false. % ok, free

?- op(1,fy,&).
   true.
?- op(1,yf,&).
   throw(error(permission_error(create,operator,&),op/3)). % unexpected, see below
?- halt.

$ tpl
?- current_op(X,Y,&).
   false. % again, free

?- op(1,yf,&).  % the other way around
   true.
?- op(1,fy,&).
   true.        % hopscop, no permission_error?

?- current_op(X,Y,&).
   X = 1, Y = fy. 
?- %%% Missing  X = 1, Y = yf. %%%
infradig added a commit that referenced this issue Sep 19, 2024
@infradig
Copy link
Contributor

Logtalk iso_op_3_10 needs to be changed to add Trealla to the conditional test @pmoura

@flexoron
Copy link
Author

flexoron commented Sep 19, 2024

ECLiPSe, Who else? SWI

$ eclipse
[eclipse 1]: op(1,fy,&).
[eclipse 2]: op(1,yf,&).
[eclipse 3]: op(1,xfx,&).
[eclipse 4]: [user].
&(x).
&(x,x).

[eclipse 5]: X&, &Y, X&Y.
X = x
Y = x
[eclipse 7]: X& .
X = x
$ tpl
?- op(1,fy,&).
   true.
?- op(1,yf,&).
   true.
?- op(1,xfx,&).
   true.
?- [user].
&(x).
&(x,x).

?- current_op(X,Y,&).
   X = 1, Y = fy
;  X = 1, Y = yf
;  X = 1, Y = xfx.

?-  X&, &Y, X&Y.
Error: syntax error, quotes needed around operator ',', user:1
?-  X& .
Error: syntax error, missing operand to infix, user:1

Also

$ tpl
?- op(1,yf,&).
   true.
?- [user].
&(x).
   true.
?- X& .
   X = x.
?- X& , true.
Error: syntax error, quotes needed around operator ',', user:1 % Meaning?
?-

@infradig
Copy link
Contributor

infradig commented Sep 19, 2024 via email

infradig added a commit that referenced this issue Sep 19, 2024
@flexoron
Copy link
Author

v2.56.14 Partial Result.
Only this works (a bit):

$ tpl
?- op(1,xfx,&).
   true.
?- op(1,fy,&). % this first
   true.
?- op(1,yf,&). % then this, otherwise non-functional
   true.
?- [user]. &(x). &(x,x). end_of_file.
   true.
?- X& .
   X = x.
?- (X&),true. % brackets additionally required
   X = x.
?- &X,(Y&),X&Y.
   X = x, Y = x.
?- (Y&),&X,X&Y.
   Y = x, X = x.
?- 

@infradig
Copy link
Contributor

infradig commented Sep 19, 2024 via email

@flexoron
Copy link
Author

flexoron commented Sep 19, 2024

But not too bad. At least eclipse,swipl approached.
A question might be:
listing.
&x
or x&
or both

?- op(1,xfx,&).
   true.
?-  op(1,fy,&).
   true.
?- op(1,yf,&).
   true.
?- [user]. &(x). &(x,x). end_of_file.
   true.
?- listing.
&x.
x&x.
   true.
?- halt.

$ tpl
?- op(1,xfx,&).
   true.
?-  op(1,yf,&).
   true.
?-  op(1,fy,&).
   true.
?- [user]. &(x). &(x,x). end_of_file.
   true.
?- listing.
x&.
x&x.
   true.
?- 

@flexoron
Copy link
Author

flexoron commented Sep 19, 2024

Left in tpl's 'issue' basket:
Scryer and the others don't care about the order ...

$ scryer-prolog -f
?- op(1,yf,&).
   true.
?- op(1,fy,&).
   true.
?- [user].
&x.
x& .

?- &X.
   X = x
;  X = x.
?- X& .
   X = x
;  X = x.
?- 

%% ... and don't need brackets %%
?- X&,&X,true.
   X = x
;  X = x
;  X = x
;  X = x.
?- &X,X&,true.
   X = x
;  X = x
;  X = x
;  X = x.
?- 

@infradig
Copy link
Contributor

I think you should define the prefix op before defining it as postfix, it's the natural order of things ;-)

@flexoron
Copy link
Author

flexoron commented Sep 20, 2024

Ah this explains why C-Programmers are supranatural extraterrestrials. for(complex i=∞i;;i++)i--;-)

https://www.youtube.com/watch?v=tGXSYfFxUA4

@infradig infradig reopened this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants