Ask Your Question
3

What is the method for exporting members of a module that has been opened in Dafny?

asked 2023-05-08 17:30:42 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-08 17:36:02 +0000

huitzilopochtli gravatar image

In Dafny, you can export members of a module by using the "export" keyword before the declaration of the member. For example, to export a function named Add from a module named MyModule, you would write:

module MyModule {
  export function Add(x: int, y: int): int
  {
    return x + y;
  }
}

This would allow you to use the Add function in other modules that have imported MyModule. You can import modules in Dafny using the "import" keyword followed by the name of the module. For example:

import MyModule;

method Main() {
  var sum := MyModule.Add(2, 3);
  assert sum == 5;
}

Here, we import the MyModule and use the exported Add function to compute the sum of 2 and 3.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-08 17:30:42 +0000

Seen: 13 times

Last updated: May 08 '23