I had something similar in mind, but didn't think of reusing the group syntax back them. Reusing the group syntax for that would probably incur minimum mental and implementation overhead. It might even work without schema changes. - Kuba
On Wednesday, September 11, 2019 at 5:47:24 PM UTC-4, [email protected] wrote: > > Is there any support for strong type aliasing? I see it on the roadmap but > I'm guessing no progress has been done on that front? > > The specific use-case I'm dealing with is time & wanting to ensure the > correct units and epoch can be used (e.g. define a function taking a > monotonic_clock::timepoint and return a strongly typed 64-bit integer > nanoseconds that's typed to represent network time so that when the other > side reads it it needs to reverse convert. > > More advanced would be to be able to define a Vector3f data type that I > know will only ever have 3 floats that I can reuse in a bunch of places > without paying for the cost of it being a separate struct (.e.g it would > take an "offset" field number & use up offset + N). So something like: > > group@N Vector3f { > x @N[0] :float; > y @N[1] :float; > z @N[2] :float; > } > > struct MyAwesomeStruct { > ... > vec3 @10 :Vector3f@10; > vec3 @12 :Vector3f@12; > } > > The actual syntax that would make sense I have no opinion on. This is > intended to just communicate what I would like the behaviour to look like. > It would ideally actually be typed in C++ too rather than purely a > convenience schema syntax. > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/11a8aede-ef6c-4854-8787-6af9116e1c3d%40googlegroups.com.
