Giter Site home page Giter Site logo

Bad OR behaviours about pharen HOT 4 CLOSED

scriptor avatar scriptor commented on September 3, 2024
Bad OR behaviours

from pharen.

Comments (4)

jeromebaum avatar jeromebaum commented on September 3, 2024

Another case where we should be following traditional lisp semantics. Just in case: The same goes for IF, AND, COND, etc. so if we have those and they don't already to this, make sure they do (though I believe IF already follows this).

Also, check out this xkcd for some real insight: http://m.xkcd.com/870/.

from pharen.

Scriptor avatar Scriptor commented on September 3, 2024

The issue here is that PHP doesn't seem to natively support this behavior for its logical operators. I guess the solution would be to convert them to ternary statements but I'm not sure if there'd be a performance penalty. Ideally there shouldn't be, but the PHP internals can be rather messy.

from pharen.

jeromebaum avatar jeromebaum commented on September 3, 2024

Doesn't the IF implementation just assign a variable? Either way, modulo multiple evaluation (which would be solved with a LET), just translate:

(or a b)

to:

(if a a b)

from pharen.

Scriptor avatar Scriptor commented on September 3, 2024

Yep, I just wasn't sure if PHP would add some extra overhead to if statements. Some quick benchmarks show that if statements were as fast as ternary statements. I really need to stop irrationally fearing PHP internals :)

Implementing this now.

from pharen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.