Giter VIP home page Giter VIP logo

Comments (1)

jeromesimeon avatar jeromesimeon commented on August 16, 2024

@frbrkoala Thanks for the bug report / feature request.

Just a quick update:

  1. I was able to reproduce the issue. See the archive attached based on your example.
    [email protected]

  2. The $coll exception is a runtime error which comes from an inconsistency between the Ergo type checker and the compiler. I think the intended behavior is for the suggested logic to fail type checking (with an error that the emit should be a singleton object).

  3. This is a perfectly valid and useful requirement imho. I think there might be two ways to support this. First being your suggestion i.e., allow emit to take either a single item or an array (which would make it polymorphic). Second might be to keep emit over single items but generalize where emit is allowed and notably allow it use inside foreach. This would look something as follows (both options probably need work):

contract MyContractLogic over MyContract state State {
  
  //Iterate through an array of vendors and emit an event for each of them
  clause notifyVendors(request : NotifyVendorsReq) : NotifyVendorsRes emits VendorNotification[] {

    foreach vendor in contract.vendors
    return
       emit  VendorNotification {
          code: request.notificationCode,
          description: request.description,
          vendor: vendor
       };
    
    return NotifyVendorsRes{ output: "Received " ++ request.notificationCode ++ " " ++ request.description ++ " and sent notification to vendors " ++ toString(contract.vendors) }
  }
}

from ergo.

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.