-
Notifications
You must be signed in to change notification settings - Fork 121
Clean up various whitespace issues and typos in the design documents #354
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
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 |
|---|---|---|
| @@ -1,24 +1,23 @@ | ||
| > 1. Why would I want an `actor class` versus just a `class`? | ||
|
|
||
| An actor is instantiated as a separate wasm instance, with isolated state. Classes can capture (mutable) free variables state, actors class should not (but currently can because the typechecker is too liberal). | ||
| An actor is instantiated as a separate wasm instance, with isolated state. Classes can capture (mutable) free variables state, actors classes should not (but currently can because the typechecker is too liberal). | ||
|
|
||
| > 2. Where am I permitted to place `async` blocks? | ||
|
|
||
| At the moment, anywhere - they get compiled to async message sends to the enclosing (perhaps implicit) actor that return a promise. You might, however, not be able to await the result unless you are in an outer async context! But you could pass in into another async block that can await it. | ||
| At the moment, anywhere - they get compiled to async message sends to the enclosing (perhaps implicit) actor that return a promise. You might, however, not be able to await the result unless you are in an outer async context! But you could pass in into another async block that can await it. | ||
|
|
||
| > 3. What kinds of datatypes are permitted to be declared with the `share` qualifier; and why some but not others (what’s the source of the distinction, and its role in writing actorscript-based systems) | ||
|
|
||
| Shared means transmittable without losing identity, essentially. So scalars, immutable data, option of shared, shared (immutable objects), shared functions and actor references can be sent/received, but nothing else that might contain or close over mutable state. That's the idea, assuming it isn't broken. Not all restriction are currently checked (i.e. escape of shared state into actors and shared functions for instance.) Note that serialization is mostly by value, apart from actors and shared functions, which are by reference, so identity can't be preserved for most values, ruling out them containing state. | ||
| Shared means transmittable without losing identity, essentially. So scalars, immutable data, option of shared, shared (immutable objects), shared functions and actor references can be sent/received, but nothing else that might contain or close over mutable state. That's the idea, assuming it isn't broken. Not all restrictions are currently checked (i.e. escape of shared state into actors and shared functions for instance.) Note that serialization is mostly by value, apart from actors and shared functions, which are by reference, so identity can't be preserved for most values, ruling out them containing state. | ||
|
|
||
| > 4. Where would I want to define a `class` versus an `object`? (explain that distinction, if possible) | ||
|
|
||
| A class is a family of objects of the same type. There used to be support for checked down-casting (instance of) on classes but we got rid of that, so really a class is just a type def plus constructor function (that's actually what it desugars to as well). | ||
|
|
||
| > 5. Where would I want to define an `object` versus a `record` (explain that distinction, if possible) | ||
|
|
||
| I guess an object would typically encapsulate state, and fields would be private by default (eventhough they aren't currently). Records would have fields public by default. In the end, an object really is just a record of values and any state encapsulation is by virtue of the object having fields that are functions that close over state in their environments. The distinction between shared objects and non-shared ones is that we don't an object that has a mutable field, and thus isn't sharable, to become sharable just by virtue of forgetting that field through subtyping. That was the intention anyway. | ||
| I guess an object would typically encapsulate state, and fields would be private by default (eventhough they aren't currently). Records would have fields public by default. In the end, an object really is just a record of values and any state encapsulation is by virtue of the object having fields that are functions that close over state in their environments. The distinction between shared objects and non-shared ones is that we don't want an object that has a mutable field, and thus isn't sharable, to become sharable just by virtue of forgetting that field through subtyping. That was the intention anyway. | ||
|
|
||
| > 6. What types permit mutation and how is that expressed; what restrictions come with using mutable memory? | ||
|
|
||
| Just mutable arrays, mutable fields of objects and mutable locals. Mutable types can't be transmitted or received in messages (shared function calls). There's no first class ref type but one can simulate that with an object with a single mutable field. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ | |
|
|
||
| * Flattened when used as function parameter or result. | ||
|
|
||
| * Q: How avoid calling convention mismatch when instantiating polymorphic function with tuple type? | ||
| * Q: How to avoid calling convention mismatch when instantiating polymorphic function with tuple type? | ||
| - Don't make tuples subtypes of Any, thereby disallowing their use in instantiation? | ||
|
|
||
|
|
||
|
|
@@ -65,14 +65,14 @@ | |
|
|
||
| * Definitions lifted to the surrounding actor. | ||
|
|
||
| * Closed-over locals need indirection through heap if mutable or if definedness cannot be proved. | ||
| * Closed-over locals need indirection through heap if mutable or if defined-ness cannot be proven. | ||
|
Contributor
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 one needs to be reverted I think: "definedness" is a technical term; "proved" also was correct, "proven" has a different meaning (easy to confuse). |
||
|
|
||
|
|
||
| ## Actor Objects | ||
|
|
||
| * Compile to immediately instantiated modules. | ||
|
|
||
| * Private field become regular globals or functions. | ||
| * Private fields become regular globals or functions. | ||
|
|
||
| * Public methods become exported functions. | ||
| - In general, have to generate wrapper functions to forward external calls to pre-existing local closure. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,16 +52,17 @@ little endian format. | |
| payload, followed by the payload as a utf8-encoded string (no trailing `\0`). | ||
| * An `Array` is represented by 4 bytes indicating the number of entries, | ||
| followed by the concatenation of the representation of these entries. | ||
| * An `Tuple` is represented the concatenation of the representation of its | ||
| entries. (No need for a length field, as it is statically determined.) | ||
| * An `Object` is represented the concatenation of the representation of its | ||
| * A `Tuple` is represented by the concatenation of the representation of its | ||
| entries. (No need for a length field, as it can be statically determined.) | ||
| * An `Object` is represented by the concatenation of the representation of its | ||
| fields, sorted by field name. (The field names are not serialized, as they | ||
| are statically known.) | ||
| * An `Option` is represented by a single byte `0` if it is `null`, or | ||
| otherwise by a single byte `1` followed by the representation of the value | ||
| * An empty tuple, the type `Null` and the type `Shared` are represented by | ||
| zero bytes. | ||
| * A `Variant` with `n` constructors sorted by constructor name is represented | ||
| <!-- TODO What's the Word's size? --> | ||
|
Contributor
Author
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. Wasn't sure about this. where would I find out in the codebase?
Contributor
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. Probably 32 bit hash of the label, but best to ask Joachim (or look in compile.ml for serialize (I suspects) |
||
| by a single word indicating the constructor as a number `0..n-1`, followed | ||
| by the payload of the constructor. (Yes, obviously no subtyping here.) | ||
|
|
||
|
|
@@ -86,7 +87,7 @@ are represented as an `elembuf`: | |
|
|
||
| The above format is thus extended with the following case: | ||
|
|
||
| * A reference (`actor`, `shared func`) is represented as a 32 bit number (4 | ||
| * A reference (`actor`, `shared func`) is represented as a 32-bit number (4 | ||
| bytes). Thus number is an index into the surrounding `elembuf`. | ||
|
|
||
| NB: The index is never never `0`, as the first entry in the `elembuf` is the | ||
|
|
||
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.
"actor classes"?