Giter Club home page Giter Club logo

Comments (9)

BobG1983 avatar BobG1983 commented on July 17, 2024 1

Okay. Let’s think about an example.

StairAscender
StairDescender

Compose into StairTraverser. That’s an additive composition.

For And and Or compositions I can’t think of an example off the top of my head. Both I think would require the two composited facets to take the same command though. An And/Or that takes different facets doesn’t make sense to me.

from amethyst.

BobG1983 avatar BobG1983 commented on July 17, 2024 1

from amethyst.

BobG1983 avatar BobG1983 commented on July 17, 2024

would the API be facet.compose(otherFacet)

Or would it be better to have a CompositeFacet class that is a facet and has a constructor that takes two facets?

from amethyst.

adam-arold avatar adam-arold commented on July 17, 2024

I'd do this similar to how Behaviors are composed now. The reason for this is that we can take advantage of operator overloading and we can also define boolean operations like facet0 + facet1 facet0 or facet1, things like that.

from amethyst.

BobG1983 avatar BobG1983 commented on July 17, 2024

Okay. So basically. If I’m going to implement this look at how behavior composition works.

from amethyst.

adam-arold avatar adam-arold commented on July 17, 2024

That's a good idea, yes. But first let's think about the kinds of compositions we might want to implement. + can be used to compose but what about and and or? Do you think that would make sense here?

from amethyst.

adam-arold avatar adam-arold commented on July 17, 2024

So StairAscender takes GoUp and StairDescender takes GoDown so StairTraverser takes both GoUp and GoDown so it is an additive composition. Job well done, we can go home, right? 😄

from amethyst.

BobG1983 avatar BobG1983 commented on July 17, 2024

Yeah. I mean sure. My question was, is there a case where we’d want and/or style composition . What would that be useful for if anything?

from amethyst.

adam-arold avatar adam-arold commented on July 17, 2024

or/and I think is not really meaningful here. We have it with Behaviors and it is useful because they return a Boolean value so we can determine whether it performed an action or not. or short-circuits so if the first Behavior returns true the second is not run at all.

With Facets this is a bit more fuzzy because each Facet responds to a single Command so the composite Facet we get with + is just doing dynamic dispatch. As a corollary the or/and overloads seem useless here because if we have a Command we already know which Facet responds to that so there is no point in short-circuiting.

from amethyst.

Related Issues (5)

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.