Support public key literals and tidy up handling of Raw vs PodId#319
Support public key literals and tidy up handling of Raw vs PodId#319
Conversation
src/middleware/basetypes.rs
Outdated
| } | ||
| write!(f, "…") | ||
| } else { | ||
| write!(f, "0x{}", self.encode_hex::<String>()) |
There was a problem hiding this comment.
It's more convenient (for me!) if the default is printing the full string, and the alternate version prints the truncated form.
See the test of inserting literals into Podlang code in lang/mod.rs for an example.
There was a problem hiding this comment.
We don't have github actions to run the examples. Could you remove the :# in
pod2/examples/main_pod_points.rs
Line 75 in 3306f36
There was a problem hiding this comment.
In the MockMainPod we use alternate for Display to print the padding None statements and arguments.
So in MockMainPod alternate leads to more verbosity.
With this change the PublicKey becomes less verbose with alternate.
Maybe we should swap the usage of alternate in the MainMockPod to be consistent? So that alternate always means less verbose by showing less data.
There was a problem hiding this comment.
I've reverted this change.
I think the long-term solution here might be a "to_podlang_string" function, so that we don't have to overload Display with lots of variants for different use-cases. In the meantime I'll stick to the existing convention of using # for more verbosity.
d31aef8 to
63bae41
Compare
63bae41 to
dba645a
Compare
ed255
left a comment
There was a problem hiding this comment.
LGTM overall! Please take a look at my comments and suggestions.
src/middleware/basetypes.rs
Outdated
| } | ||
| write!(f, "…") | ||
| } else { | ||
| write!(f, "0x{}", self.encode_hex::<String>()) |
There was a problem hiding this comment.
We don't have github actions to run the examples. Could you remove the :# in
pod2/examples/main_pod_points.rs
Line 75 in 3306f36
src/middleware/basetypes.rs
Outdated
| } | ||
| write!(f, "…") | ||
| } else { | ||
| write!(f, "0x{}", self.encode_hex::<String>()) |
There was a problem hiding this comment.
In the MockMainPod we use alternate for Display to print the padding None statements and arguments.
So in MockMainPod alternate leads to more verbosity.
With this change the PublicKey becomes less verbose with alternate.
Maybe we should swap the usage of alternate in the MainMockPod to be consistent? So that alternate always means less verbose by showing less data.
Closes #299
PublicKeys can now be expressed as Podlang literals:
I've also tidied up the handling of PodId vs Raw. Now, any bare hex string (0x-prefixed) is interpreted as a PodId, unless wrapped in
Raw(), in which case it will be interpreted as aRawValue.I'm open to changing these if the wrappers seem too verbose. For instance, maybe we could use a special character prefix for public keys, like
+or@, but I thought that it would be better to start with something verbose and then introduce shortcuts if the verbose version is too annoying.