Skip to content

Conversation

@bioball
Copy link
Member

@bioball bioball commented Dec 23, 2025

Reference implementation: apple/pkl#1384

@bioball bioball force-pushed the power-asserts branch 2 times, most recently from d9e8369 to 0a6bedf Compare December 25, 2025 05:35
----

Literal values include stdlib types like IntSeq, List, Map whose members are also literal.
Here, `List(1, 2, 3)` is excluded because it's considered a literal:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also work for Map()? What about Listing of literals?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, already mentioned Map on line 127.

Didn't include this for objects, because there's a lot of sugar that can happen with object literals. But, maybe we can support this for objects that have explicitly declared types, e.g. new Listing { 1; 2; 3 }.


[source,pkl]
----
assert(1 == 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this a future direction, but would assert short circuit if it fails, like throw?
If so it has the same problem as throw, which is, it doesn't compose.
If we can solve this, we'd be able to replace throw as the way to show custom messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would be the replacement for throw, but, I'm also not sure if this should be short-circuiting or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants