Repository navigation
annos blog and removal of annotation documentation #90
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7ace798
added blog on annotation removal
jurgenvinju 3a90419
Merge branch 'website-v2' into annos-blog
jurgenvinju b8e8127
removed traces of @ from documentation
jurgenvinju f0ab056
removed dead error messages
jurgenvinju f144881
added keyword
jurgenvinju 9b7ba5a
minor fix
jurgenvinju 798666e
missing quote
jurgenvinju 71c221b
removed weird file
jurgenvinju 4357dcf
feedback by @davylandman
jurgenvinju 0fd33f5
titles jurgen changed
jurgenvinju 7f19f97
fixed links
jurgenvinju bc6f683
fixed links
jurgenvinju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| title: Final step in replacing the annotations feature with the keyword field feature | ||
| authors: [jvinju] | ||
| --- | ||
|
|
||
| Over the years we have been gradually replacing the [Annotation](/docs/Rascal/Declarations/Annotation) feature with the [Keyword field](/docs/Rascal/Declarations/AlgebraicDataType) feature. | ||
| In [release 0.43.0](/release-notes/rascal-0-43-x-release-notes) the final step has been made by replacing the semantics of annotations with a "not implemented" error message with a **quick-fix** suggestion. | ||
| This feature removal went through the following stages to make for a smooth transition: | ||
|
|
||
| 1. `2009-2013` only annotations implemented (syntax and semantics). | ||
| 2. `2013-2019` both annotations and keyword fields implemented (syntax and semantics), but never at the same time on the same node. | ||
| 3. `2019-2026` annotations simulated by keyword fields (both the syntactical features use semantics of keyword fields); `Tree@\loc` is simulated by `Tree.src`. | ||
| 4. `2026-....` annotations not implemented anymore (only syntax), everything is a keyword field. `anno loc Tree@\loc` is replaced by `data Tree(loc src=|unknown:///|)` in the `ParseTree` module. | ||
|
|
||
| We are now past step 4. Every use of a syntactic construct related to annotations will produce: | ||
| 1. an error message by the checker. | ||
| 2. a quick-fix suggestion to remove any and all uses of annotation syntax _in the current project_ and replace them by the respective keyword field feature. | ||
| 3. a static error by the interpreter. | ||
|
|
||
| Note that: | ||
| * If you don't fix the code, it will not run anymore and you will get static exceptions by the interpreter. | ||
| * After you have fixed the code, it may not run properly on older versions of Rascal anymore, because older versions always come with their own version of the `ParseTree` module. | ||
|
|
||
| For your convenience we list the differences in syntax and semantics here: | ||
|
|
||
| | Feature | Annotations | Keyword fields | Note | | ||
| | --- | --- | ---- | --- | | ||
| | declaration | `anno OfType OnType@name` | `data OnType(OfType name = Default)` | annotations do not have default expressions | | ||
| | projection | `OnExpr@name` | `OnExpr.name` | annotations throw `NoSuchAnnotation` if `name` does not exist, while keyword fields return their default. Keyword fields on `node` throw `NoSuchField` exceptions and return a value of type `value` always. | | ||
| | assignment | `OnExpr@name = Expr` | `OnExpr.name = Expr` | Assigment operators like `+=` also inherit the semantics of projection | | ||
| | update | `OnExpr[@name=Expr]` | `OnExpr[name=Expr]` | field update works the same for both features, both set the field whether or not it was there before | | ||
| | equality | `Cons[@f=1] == Cons[@f=2]` is `true` | `Cons(f=1) == Cons(f=2)` is `false` | constructor equality ignores annotations while it does not ignore keyword fields, this also holds for set elements, and map/relation keys | | ||
| | matching | `Cons[@f=1] := Cons[@f=2]` is `true` | `Cons(f=1) := Cons(f=2)` is `true` | constructor matching always ignores keyword fields and annotations | | ||
|
|
||
| In stage 3, annotations took the semantics of keyword fields for _declaration_, _assignment_ and _matching_, and _equality_ while for _projection_ still the old `NoSuchAnnotation` was thrown. This is the stage you have probably been using. The hard change was between stages 2 and 3. | ||
|
|
||
| The quickfix for stage 4 produces an arbitrary default for well known types, | ||
|
jurgenvinju marked this conversation as resolved.
|
||
| i.e. `int age = 0`, while for more complex type an exception is thrown by the default expression. It is advised to review the defaults manually. | ||
|
|
||
| Finally, the quickfix may open and rewrite a large group of files for the current project. You have to save and close each of them manually to write the result to disk. This would also be a good time to review the generated defaults. | ||
|
jurgenvinju marked this conversation as resolved.
|
||
|
|
||
| If you get stuck, please contact (Jurgen Vinju)[mailto:Jurgen.Vinju@cwi.nl] or (Davy Landman)[mailto:Davy.Landman@swat.engineering] for help. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...es/Rascal/Errors/CompileTimeErrors/UndeclaredAnnotation/UndeclaredAnnotation.md
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
...cal/Errors/RunTimeErrors/RuntimeExceptions/NoSuchAnnotation/NoSuchAnnotation.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.