Giter VIP home page Giter VIP logo

Comments (7)

graphitemaster avatar graphitemaster commented on August 19, 2024

I was wondering how a short circut XOR would work considering that each operand needs to be evaluated inorder for the xor semantics require an evaluation. The semantics of SCL logic dictate that only sub-expressions of a full expression be evaluated to some extent to short the logic, if they dont evaluate to a truth value to simply stop the evaluation. If we added a short-circut XOR operator, perhaps "^^". How would you implement SCL logic on it. I'm certian it isn't possible at all, the evaluation would need to take place, which means it cannot map 1:1 with operator logic. Any thoughts? I really want a SCL XOR :P

from gmqcc.

Blub avatar Blub commented on August 19, 2024

Simply not possible, because the result always depends on both operands. (False and X) = False, (True or X) = True, but (False xor X) = X and (True xor X) = Not(X), there's always a dependency here.

What WOULD make sense however is when we want perl-like results of logical operations. div0 mentioned he'd like that: x && b would result in a ? b : a, in other words, if a is true, it yields b, which doesn't necessarily have to be a boolean value. Eg. (1 && 5) doesn't yield 1 but 5, or (ent_a && ent_b) yields the entity ent_b if ent_a != world. In this case, the XOR operator could work like described above: (a ? !b : b), however this could become a bit uncomfortable since !b is always a boolean (ie. float in QC), but b itself could be an entity, so we'd need to implicitly cast false to world in such a construct.

from gmqcc.

graphitemaster avatar graphitemaster commented on August 19, 2024

since short circut evaluation cannot be implement on a logical XOR, we should still implement an operator for it, something along the lines of ^^, I cannot digress how much I despise the idea of !a != !b, which when truncated for whitespace looks insane "!a!=!b". I'd only allow this operator for -std=gmqcc, since I don't suspect another standard of the language implements it, but I know div would generally agree with I suspect; his perl-likeness of perl-like operators is insane, fteqcc even implements a backwards bitwise assignment operator, with negation, In C you'd use something like a&=b, in fteqcc it's a&=b, which is just insane. I suspect -std=fteqcc will need to implement this operator for fteqcc conformancy. Please open a ticket on this matter

from gmqcc.

Blub avatar Blub commented on August 19, 2024

Nice catch, I completely forgot about div's &~= operator...
We now need 2 sets of tests: one for -fshort-logic, and one for this with an additional -fperl-logic.

from gmqcc.

graphitemaster avatar graphitemaster commented on August 19, 2024

I feel as if we should call -fperl-logic, f-omgwtfiswrongwithyou-logic

from gmqcc.

Blub avatar Blub commented on August 19, 2024

It's perfectly natural, many languages use it. shells, LUA, python, ...

from gmqcc.

Blub avatar Blub commented on August 19, 2024

added tests

from gmqcc.

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.