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

Logical Expression Repalcement with Arithmatic Expression, Optimisation #46

Open
Woccz opened this issue Jun 14, 2021 · 2 comments
Open
Labels
backlog Good idea but bad effort to value ratio right now enhancement New feature or request optimisation Everything regarding better code

Comments

@Woccz
Copy link
Contributor

Woccz commented Jun 14, 2021

Sometimes logical expressions can be replaced by arithmatic expressions, due to YOLOL using number type variables for booleans.

Example:
image

I'm not sure of all the places these expressions can be substituted, for example, x+= a or b can result in a different output from x+= a+b.
Perhaps it is best to just replace statements used for logical evaluation, i.e. if x then ...

Thank you.

@Woccz Woccz added the enhancement New feature or request label Jun 14, 2021
@Woccz Woccz changed the title Logic Expression repalcement with Arithmetic Expression Optimisation Logic Expression Repalcement with Arithmetic Expression Optimisation Jun 14, 2021
@Woccz Woccz changed the title Logic Expression Repalcement with Arithmetic Expression Optimisation Logic Expression Repalcement with Arithmetic Expression, Optimisation Jun 14, 2021
@Woccz Woccz changed the title Logic Expression Repalcement with Arithmetic Expression, Optimisation Logical Expression Repalcement with Arithmetic Expression, Optimisation Jun 14, 2021
@dbaumgarten
Copy link
Owner

A problem here is the lack of type-information.
Replacing and/or with */+ is only safe, when you are sure that the user is only interested in the truthvalue of the computation.

You are right, if the expression is used DIRECTLY as condition for an if, that would be safe to assume. But even in cases like

if (a or b)==(c or d) then ....

this would fail in unexpected ways.

I guess if I ever find a way to implement a proper type-system, optimizations like this could become relatively simple.

@dbaumgarten dbaumgarten added the backlog Good idea but bad effort to value ratio right now label Jun 14, 2021
@dbaumgarten
Copy link
Owner

Waiting for #48

@Woccz Woccz changed the title Logical Expression Repalcement with Arithmetic Expression, Optimisation Logical Expression Repalcement with Arithmatic Expression, Optimisation Jun 15, 2021
@dbaumgarten dbaumgarten added the optimisation Everything regarding better code label Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Good idea but bad effort to value ratio right now enhancement New feature or request optimisation Everything regarding better code
Projects
None yet
Development

No branches or pull requests

2 participants