a-sit-plus / signum

Kotlin Multiplatform Crypto/PKI Library and ASN1 Parser + Encoder
https://a-sit-plus.github.io/signum/
Apache License 2.0
76 stars 6 forks source link

Provide default arguments for `Asn1TreeBuilder.() -> Unit` #145

Closed ShiinaSekiu closed 1 week ago

ShiinaSekiu commented 1 month ago

In some practices we may not use the child node builder.

Asn1.ExplicitlyTagged(34U) { }

https://github.com/a-sit-plus/signum/blob/e8f9bd4a0be5a9018e6e4ffe137b22191b06c1e1/indispensable/src/commonMain/kotlin/at/asitplus/signum/indispensable/asn1/encoding/Asn1Encoding.kt#L191 Maybe it should be changed to?

fun ExplicitlyTagged(tag: ULong, root: Asn1TreeBuilder.() -> Unit = { }): Asn1ExplicitlyTagged {
JesusMcCloud commented 1 month ago

Personally, I think the intentions are clearer, if the empty lambda needs to be spelled out. After all you are creating an empty structure. Therefore, I think the code should clearly mirror this intent.

JesusMcCloud commented 1 week ago

@ShiinaSekiu feel free to reopen, if you can present a legit use case