-
Notifications
You must be signed in to change notification settings - Fork 323
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
Add Meta.engine_version
#11320
Add Meta.engine_version
#11320
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.enso.interpreter.node.expression.builtin.meta; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import org.enso.interpreter.dsl.BuiltinMethod; | ||
import org.enso.interpreter.runtime.data.text.Text; | ||
import org.enso.version.BuildVersion; | ||
|
||
@BuiltinMethod( | ||
type = "Meta", | ||
name = "engine_version", | ||
description = "Returns the version of the currently running Enso engine.", | ||
autoRegister = false) | ||
public class CurrentEngineVersionNode extends Node { | ||
|
||
public Text execute() { | ||
return getCurrentVersion(); | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
private Text getCurrentVersion() { | ||
StringBuilder sb = new StringBuilder(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not really an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exposing text messages as an API is a well known antipattern which has bitten many. See for example Practical API Design, Chapter 3: "Determining what makes a good API", page 31:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will you be ok if I rename this method to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole point of this method is to have a single method to get a quick glance of the currently running version. Just If I split this up into separate methods, it will be tedious to reconstruct - the whole rationale is to easily get a debug overview. This method is not meant to be used or parsed by users, if anyone uses it like that - I guess the usage is the anti-pattern. Is the ability for users to abuse a helper debug method enough reason not to have it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it is! By exposing a text API like this either of:
constitutes an incompatible change and it is a potential threat to existing Enso users. In addition to that. In its current form this change doesn't meet requirements for an API change. There is a checkbox:
Where else shall there be tests then when doing an API change? |
||
sb.append("Enso Engine Version: "); | ||
sb.append(BuildVersion.ensoVersion()); | ||
sb.append("\nDefault Edition: "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised that on your Windows this displays newlines? Shouldn't you rather use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works fine with |
||
sb.append(BuildVersion.currentEdition()); | ||
|
||
sb.append("\nCompiled with GraalVM "); | ||
sb.append(BuildVersion.graalVersion()); | ||
sb.append(", Scalac "); | ||
sb.append(BuildVersion.scalacVersion()); | ||
|
||
sb.append("\nBased on commit "); | ||
sb.append(BuildVersion.commit()); | ||
sb.append(" (at "); | ||
sb.append(BuildVersion.latestCommitDate()); | ||
sb.append(")\non ref "); | ||
sb.append(BuildVersion.ref()); | ||
if (BuildVersion.isDirty()) { | ||
sb.append("\n(with uncommitted changes)"); | ||
} | ||
|
||
return Text.create(sb.toString()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the
@Builltin_Method
into aprivate
module to be ready for to get ready fordelegate the builtin method here, if you want to expose it to users (even just with
## PRIVATE
comment).