Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider allowing state-dependent methods in standalone state machines #1497

Open
TimLethbridge opened this issue Sep 6, 2019 · 0 comments

Comments

@TimLethbridge
Copy link
Member

commented Sep 6, 2019

Issue #1483 was fixed to prevent an infinite loop when state-dependent methods were encountered in standalone state machines. However, such methods are not, in fact, allowed. They are only allowed in embedded state machines, and can be introduced using traits.

Users, however, might want them. Thus the following code:

class TreasureChest {
  

  static void report(String message) {
System.out.println(message);
}

  static void scenarioHeader(String message) {
report("\n"+message);
report("------------------------------".substring(1,message.length()));
}

  String getDescription() {
return "The old treasure chest is " + chestStatus() + ".";
}
  
  chestStatus as chestStatus;
 
}


statemachine chestStatus{
  
  open{
    String chestStatus() {return "chest open";}
  }
  
  close{
  }
}

would generate the same as this:

chestStatus{
  
  open{
    String chestStatus() {return "chest open";}
  }
  
  close{
  }
}

Without issuing warning 1015.

This is a low-priority item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.