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

Let target be an argument instead of an option for translate #3239

Conversation

keyboardDrummer
Copy link
Member

@keyboardDrummer keyboardDrummer commented Dec 21, 2022

Changes

Changes the --target option for dafny translate into a <language> argument, so that users don't accidentally run dafny translate with a target they didn't want. Since there are many targets and only one is correct, accepting a default target likely wastes user's time by letting them wait for dafny translate to finish, inspecting the results, and then discovering it was translated to the wrong language and they should probably look at the options.

Rename --compile-verbose to --verbose

Data

New help:

Description:
  Translate Dafny sources to source and build files in a specified language.

Usage:
  Dafny translate <language> [<file>...] [options]

Arguments:
  <language>  cs - Translate to C#.
              go - Translate to Go.
              js - Translate to JavaScript.
              java - Translate to Java.
              py - Translate to Python.
              cpp - Translate to C++.
  
              Note that the C++ backend has various limitations (see Docs/Compilation/Cpp.md). This includes lack of support for BigIntegers (aka int), most higher order functions, and advanced features like traits or co-inductive types.
  <file>      input files

Options:
  -o, --output <file>                          Specify the filename and location for the generated target language files.
  --verbose                                    Print information such as files being written by the compiler to the console
  --include-runtime                            Include the Dafny runtime as source in the target language.
...

Old help:

Description:
  Generate source and build files in a specified target language.

Usage:
  Dafny translate [<file>...] [options]

Arguments:
  <file>  input files

Options:
  -o, --output <file>                          Specify the filename and location for the generated target language files.
  --compile-verbose                            Print information such as files being written by the compiler to the console
  --include-runtime                            Include the Dafny runtime as source in the target language.
  -t, --target <language>                      cs - Compile to .NET via C#.
                                               go - Compile to Go.
                                               js - Compile to JavaScript.
                                               java - Compile to Java.
                                               py - Compile to Python.
                                               cpp - Compile to C++.

...

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@keyboardDrummer keyboardDrummer enabled auto-merge (squash) December 21, 2022 16:29
@davidcok
Copy link
Collaborator

The --compile-verbose option would be better named --translate-verbose or even just --verbose

@keyboardDrummer keyboardDrummer requested review from atomb and removed request for cpitclaudel December 21, 2022 17:20
@atomb
Copy link
Member

atomb commented Dec 21, 2022

Am I right in understanding that this change is just envisioned for translate and not build or run? I believe that the latter two are most useful if the language is not required, and that there's a notion of building and running a Dafny program that doesn't require the user to care about what intermediate languages are involved. But, for translate, I can see the argument for requiring a target language, because you likely care pretty strongly what that language is (either to read the output or integrate it with some other system).

@keyboardDrummer
Copy link
Member Author

Am I right in understanding that this change is just envisioned for translate and not build or run? I believe that the latter two are most useful if the language is not required, and that there's a notion of building and running a Dafny program that doesn't require the user to care about what intermediate languages are involved. But, for translate, I can see the argument for requiring a target language, because you likely care pretty strongly what that language is (either to read the output or integrate it with some other system).

That's right!

@keyboardDrummer keyboardDrummer requested review from cpitclaudel, MikaelMayer and davidcok and removed request for davidcok and cpitclaudel December 22, 2022 11:15
@keyboardDrummer keyboardDrummer merged commit 8d7670f into dafny-lang:master Dec 22, 2022
@keyboardDrummer keyboardDrummer deleted the targetAsArgumentForTranslate2 branch December 22, 2022 12:01
@MikaelMayer
Copy link
Member

Could you please add as a follow-up PR an element in docs/dev/* so that we can announce to the world this breaking change? Even if you believe no one actually relied on this command before, we need to announce it.

Also, when we will have project files, the language option should be optional as I believe will be possible to provide it directly in the project file.

@keyboardDrummer
Copy link
Member Author

keyboardDrummer commented Dec 22, 2022

Could you please add as a follow-up PR an element in docs/dev/* so that we can announce to the world this breaking change? Even if you believe no one actually relied on this command before, we need to announce it.

Sure: #3253

Copy link
Collaborator

@davidcok davidcok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text under "New Help" still lists --compile-verbose

RustanLeino pushed a commit to RustanLeino/dafny that referenced this pull request Dec 29, 2022
…ang#3239)

### Changes

Changes the `--target` option for `dafny translate` into a `<language>`
argument, so that users don't accidentally run `dafny translate` with a
target they didn't want. Since there are many targets and only one is
correct, accepting a default target likely wastes users's time by
letting them wait for `dafny translate` to finish, inspecting the
results, and then discovering it was translated to the wrong language
and they should probably look at the options.

### Data

New help:
```
Description:
  Translate Dafny sources to source and build files in a specified language.

Usage:
  Dafny translate <language> [<file>...] [options]

Arguments:
  <language>  cs - Translate to C#.
              go - Translate to Go.
              js - Translate to JavaScript.
              java - Translate to Java.
              py - Translate to Python.
              cpp - Translate to C++.
  
              Note that the C++ backend has various limitations (see Docs/Compilation/Cpp.md). This includes lack of support for BigIntegers (aka int), most higher order functions, and advanced features like traits or co-inductive types.
  <file>      input files

Options:
  -o, --output <file>                          Specify the filename and location for the generated target language files.
  --compile-verbose                            Print information such as files being written by the compiler to the console
  --include-runtime                            Include the Dafny runtime as source in the target language.
...
```

Old help:

```
Description:
  Generate source and build files in a specified target language.

Usage:
  Dafny translate [<file>...] [options]

Arguments:
  <file>  input files

Options:
  -o, --output <file>                          Specify the filename and location for the generated target language files.
  --compile-verbose                            Print information such as files being written by the compiler to the console
  --include-runtime                            Include the Dafny runtime as source in the target language.
  -t, --target <language>                      cs - Compile to .NET via C#.
                                               go - Compile to Go.
                                               js - Compile to JavaScript.
                                               java - Compile to Java.
                                               py - Compile to Python.
                                               cpp - Compile to C++.

...
```

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants