Skip to content

Commit e4a624d

Browse files
committed
More comments on constants.
1 parent ae614a1 commit e4a624d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

hugr-core/src/import.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,17 +1147,18 @@ impl<'a> Context<'a> {
11471147
//
11481148
// This would be necessary to allow functions which take
11491149
// other functions as static parameters and then call them.
1150+
// See #2301.
11501151
return Err(error_unsupported!(
11511152
"`{}` does not yet support function variables.",
11521153
model::CORE_CALL
11531154
));
11541155
}
11551156
table::Term::Func(_) => {
1156-
// TODO: Allow importing and calling anonoymous functions.
1157+
// TODO: Allow importing and calling anonymous functions.
11571158
//
11581159
// This could be implemented in `hugr-core` by lifting the anonymous function
11591160
// into a function to be added into the containing module and then calling that
1160-
// function.
1161+
// function. See #2559.
11611162
return Err(error_unsupported!(
11621163
"`{}` does not yet support anonymous functions.",
11631164
model::CORE_CALL

hugr-model/src/v0/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//! - Some terms can not yet be represented in `hugr-core` although they should be.
5252
//! Importing such terms will result in an error that declares these terms as currently
5353
//! unsupported.
54-
//! - In particular `hugr-core` currently only allows to define custom runtime types but
54+
//! - In particular `hugr-core` (as of `v0.22.3`) only allows to define custom runtime types but
5555
//! can not represent custom term constructors for static types. Implementing support for
5656
//! static `Term`s in `hugr-core` will allow to use the term system for extensible metadata
5757
//! and constants. Once that is implemented, the hugr IR will have a unified extension mechanism.
@@ -64,6 +64,19 @@
6464
//! compatibility mechanism via the `compat.const_json` constant constructor but also allows
6565
//! to declare custom constant constructors. Import/export has hard-coded support for a small
6666
//! fixed set of these for now.
67+
//! - In `hugr-core` a constant is a `Value`, included in the hugr graph via a `Const` node.
68+
//! A `LoadConst` node connects to the `Const` node via a static edge. `Value`s are separate
69+
//! from `Term`s in `hugr-core` and can not refer to local variables or to function nodes.
70+
//! In `hugr-model` the `Const` node is not needed: The `core.load_const` operation takes
71+
//! the constant's description as a term argument. This enables `hugr-model` constants to
72+
//! depend on local variables and to refer to functions in the module (removing the need
73+
//! for a separate `LoadFunc` operation).
74+
//! - `Value`s in `hugr-core` have a single representation for every constant. The encoding
75+
//! of constants as terms in `hugr-model` can use different constructors for the same type
76+
//! of constant value. This can be useful for large constants by enabling efficient encodings.
77+
//! For example, a constant array of integers could have a constructor taking a byte string
78+
//! that consists of the integer values, which is significantly more economical than a generic
79+
//! representation of arrays that has a term for every element.
6780
//! - The model does not have types with a copy bound as `hugr-core` does, and instead uses
6881
//! a more general form of type constraints ([#1556]). Similarly, the model does not have
6982
//! bounded naturals. We perform a conversion for compatibility where possible, but this does
@@ -79,8 +92,10 @@
7992
//! - `hugr-core` only allows to define type aliases, but not aliases for other terms. The
8093
//! alias system is under-developed in both `hugr-core` and `hugr-model` and will need some
8194
//! considerable design and implementation work (or to be removed if deemed unnecessary).
95+
//! See [#2558].
8296
//!
8397
//! [#1556]: https://github.com/CQCL/hugr/discussions/1556
98+
//! [#2558]: https://github.com/CQCL/hugr/issues/2558
8499
//! [Text]: crate::v0::ast
85100
//! [Binary]: crate::v0::binary
86101
//! [Table]: crate::v0::table

0 commit comments

Comments
 (0)