Code Monkey home page Code Monkey logo

Comments (6)

gallandarakhneorg avatar gallandarakhneorg commented on June 20, 2024

The generation of the correct extend type is easy to apply (done in gallandarakhneorg/sarl).
But, there is additional points to focus on if we introduce the extension mechanism for agents:

  • How to call the super's implementation for a def.
  • How to call the super's implementation for an event.

For illustrating, let take the following example:

agent AbstractAgent {

    uses Lifecycle

    on Initialize {
        System.out.println("Hello World in the super agent!")
    }

    def sayGoodBye {
        System.out.println("Goodbye World!")
    }

}

agent HelloChildAgent extends AbstractAgent{

    uses Schedules

    on Initialize {
        System.out.println("Hello World in the child agent!")
        in(2000)[killMe]
    } 

    def sayGoodBye {
        super.sayGoodBye()
    }

    on Destroy {
        sayGoodBye
    }
}

from sarl.

gallandarakhneorg avatar gallandarakhneorg commented on June 20, 2024

The FAQ or the tutorials should explain that calling an override function is possible, but not an event handler.

from sarl.

gallandarakhneorg avatar gallandarakhneorg commented on June 20, 2024

There is a problem to access to the inherited attributes.

from sarl.

ngaud avatar ngaud commented on June 20, 2024

The idea here is to change the visibility of getter/setter methods to "protected" to enable an access to parent field from a sub-class.

from sarl.

gallandarakhneorg avatar gallandarakhneorg commented on June 20, 2024

Consider the SARL code:

agent A {
   var thevar = false
}

It is not possible to generate the setter function due to a Xtext limitation. Indeed, the generated setter may be:

public void setThevar(<<INFERENCED TYPE>> thevar) {
  this.thevar = thevar;
}

Unfortunately, for generating the method setThevar Xtext needs to kwow all the properties of the formal parameters. But, the inferred type cannot be determine because the inferring engine is not reflexive. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=408323.

from sarl.

gallandarakhneorg avatar gallandarakhneorg commented on June 20, 2024

The only way to provide access to the attributes from the subclasses of agents is to make protected the attributes. The getter/setter becomes not more required.

from sarl.

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.