-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
53 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
app/gui/view/graph-editor/src/builtin/visualization/native/inc/error_preprocessor.enso
This file contains 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
x -> | ||
result = Builtins.Ref.new '{ message: ""}' | ||
result = Ref.new '{ message: ""}' | ||
x.catch err-> | ||
message = err.to_display_text | ||
Builtins.Ref.put result ('{ "kind": "Dataflow", "message": ' + message.to_json.to_text + '}') | ||
Builtins.Ref.get result | ||
Ref.put result ('{ "kind": "Dataflow", "message": ' + message.to_json.to_text + '}') | ||
Ref.get result | ||
|
45 changes: 45 additions & 0 deletions
45
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ref.enso
This file contains 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,45 @@ | ||
## Utilities for working with mutable references. | ||
type Ref | ||
|
||
## A mutable reference type. | ||
@Builtin_Type | ||
type Ref | ||
|
||
## FIXME consider moving this as methods of Ref, currently a lot of stuff depends | ||
## on the current design | ||
## Gets the contents of the mutable reference ref. | ||
|
||
Arguments: | ||
- ref: The reference to get the contents of. | ||
|
||
> Example | ||
Getting the contents of a reference. | ||
|
||
Ref.get (Ref.new 0) | ||
get : Ref -> Any | ||
get ref = @Builtin_Method "Ref.get" | ||
|
||
## Puts a new value into the reference, returning the old value. | ||
|
||
Arguments: | ||
- ref: The reference in which to store the value. | ||
- new_value: The new value to store in ref. | ||
|
||
> Example | ||
Storing the value 10 in a reference. | ||
|
||
Ref.put (Ref.new 0) 10 | ||
put : Ref -> Any -> Any | ||
put ref new_value = @Builtin_Method "Ref.put" | ||
|
||
## Creates a new reference containing the provided value. | ||
|
||
Arguments: | ||
- value: The value to be contained in the ref. | ||
|
||
> Example | ||
Creating a new reference containing the value 7. | ||
|
||
Ref.new 7 | ||
new : Any -> Ref | ||
new value = @Builtin_Method "Ref.new" |
This file contains 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 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 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 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,12 @@ | ||
from Standard.Base import all | ||
|
||
import Standard.Test | ||
|
||
spec = Test.group "Refs" <| | ||
Test.specify "should be able to store and retrieve value in references" <| | ||
r = Ref.new 'foo' | ||
Ref.put r 'bar' | ||
v = Ref.get r | ||
v.should_equal 'bar' | ||
|
||
main = Test.Suite.run_main here.spec |