mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Shorthand syntax to avoid verboseness #304
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LukasPrediger on GitHub (Apr 24, 2025).
Currently pkl is a pretty verbose language when writing simple constructs. It scales well but in the lowest regions i find myself writing a lot of extra code.
I think adding some syntax that allows for easier construction of primitive collections would already help.
Currently when i want to make a Listing of strings i have to write
It would be much nicer to be able to just write
foo = ["a", "b", "c"]I don't know if there's already a function that allows me to something similar and i missed it but for now having to write a lot of extra code is my biggest downside of using pkl (which is otherwise a very good language for its usecase)
@bioball commented on GitHub (Apr 24, 2025):
Generally, you'd define a module that just describes your schema:
Then you'd define your data:
In this case, adding
= new Listingis redundant because you are already amending an empty listing.@StefMa commented on GitHub (Apr 24, 2025):
I guess he is more asking about a syntax of creating a list in a single line. Like most programming language do.
So probably
foo = new Listing { "a", "b", "c" }would satisfy him.
But this is just not possible with pkl...
@HT154 commented on GitHub (Apr 24, 2025):
Semicolons can be used as element/entry/property separators for "inline" object bodies:
@bioball commented on GitHub (May 7, 2025):
Closing this; the syntax is already pretty short, and not likely to change.