Futures
"Futures" are placeholders for the results of computation that happen 'out of sequence'. This computation is forced to happen on-demand when the actual value is required (e.g. because of a run-time type-check). Technically this makes them implicit futures. If an executing thread needs the value of a future, it will automatically block until that future has been evaluated.
There is a simple syntax for creating futures:
$( EXPRESSION ) # A future that when forced (implicitly) must yield a single value, equivalent to $( EXPRESSION:: _ )
$( EXPRESSION:: PATTERN) # A future that when forced (implicitly) must match the pattern.
PATTERN := $( EXPRESSION ) # Binds the variables of the pattern to futures, the expression must yield a matching result.
The futures created by this syntax are lazy, meaning that their evaluation is deferred as long as possible in the same execution-thread as they were created. However, Nutmeg also has concurrently evaluated futures via message sending. Messages are sent asynchronously and their results are represented by futures. These futures are filled-in when the message-handler has finished, as opposed to being evaluated lazily.
Sometimes you want to iterate over a collection of futures in the order they are available. This is made possible via the FutureCollection
.
# Create a collection of futures
val fcollection = FutureCollection( for i in L do $(f(i)) end )
# How many are ready?
val count = fcollection.countReady
# Pick the first one to be ready, removing it from the collection.
val v = fcollection.popReady
Design Principles
- Nutmeg Design Goals
- The Spirit of Nutmeg
- Syntax Design
- State Encapsulation
- List of Design Decisions
- Influences
Language Features
- $$-Syntax (Echo Expressions)
- Actors
- Allocators
- Annotations
- Assignments
- Bindings
- Blocks and Modifiers
- Brackets
- Capsules (Proposed)
- Clean Procedures
- Comments
- Copy by Snapshot
- Declarations
- Finesses
- For Syntax
- Futures
- Identifiers
- If Syntax
- Messages
- Pass Syntax
- Queries
- References
- Return Statements
- Sealing
- Semicolons
- Strings
- Switch Syntax
Built-in Libraries and Functions
Implementation
- Architecture in one page
- Autoconversion
- Bundle Files
- Code-Trees
- Compiler Pipeline
- Components of the Compiler
- Installation File Structure
- Mishaps
- Peekable Pushable Generators
- Recursive Descent Parser
- Resolver
- Walkthrough of Hello-World
How-Tos
Process