[zeek/spicy] 180ce9: New `Optional` implementation.

0 views
Skip to first unread message

Robin Sommer

unread,
Oct 21, 2025, 9:28:27 AM (22 hours ago) Oct 21
to spicy-...@zeek.org
Branch: refs/heads/topic/robin/runtime-types
Home: https://github.com/zeek/spicy
Commit: 180ce97cb07a5c9e33e36c5acbe71d0298227f92
https://github.com/zeek/spicy/commit/180ce97cb07a5c9e33e36c5acbe71d0298227f92
Author: Robin Sommer <ro...@corelight.com>
Date: 2025-10-21 (Tue, 21 Oct 2025)

Changed paths:
M hilti/runtime/include/types/bitfield.h
M hilti/runtime/include/types/null.h
M hilti/runtime/include/types/optional.h
M hilti/runtime/include/types/struct.h
M hilti/runtime/include/types/tuple.h
M hilti/runtime/src/tests/optional.cc
M hilti/toolchain/src/compiler/codegen/coercions.cc
M hilti/toolchain/src/compiler/codegen/ctors.cc
M hilti/toolchain/src/compiler/codegen/operators.cc
M hilti/toolchain/src/compiler/jit.cc
M spicy/runtime/src/init.cc
M spicy/runtime/src/parser.cc

Log Message:
-----------
New `Optional` implementation.

So far the runtime used `std::optional` for representing optionals.
This commit replaces that with a custom `Optional` class that
encapsulates the implementation, and directly provides the semantics
we want. That means in particular that we can now remove most of the
former free functions, and move their functionality directly into the
class. For example, the `value()` method now throws the expected HILTI
exception directly, without needing to remember to use a wrapper. We
also rename some method to follow our coding conventions.

Behind the scenes, we continue to use `std::optional` for implementing
optionals, now through protected inheritance, similar like we do for
some other types as well.

This is all similar to how we already wrap other `std` types into
custom runtime types (e.g., vector).



To unsubscribe from these emails, change your notification settings at https://github.com/zeek/spicy/settings/notifications
Reply all
Reply to author
Forward
0 new messages