-
Notifications
You must be signed in to change notification settings - Fork 82
Automatically generating dependent type messages #85
Comments
I'm not certain how to define the type of a variable, based on the value contained in another value. I assumed I would need to implement it using something similar to the following, which does not compile.
I have defined the complex-data message-structure and its codec here. |
In the following Quic Script quic_serdes_test.ivy
Is this a suitable way to handle this? I dont' understand the syntax that's being used, and I'd really appreciate some help in interpreting these commands. Further, in quic_connection.ivy, we notice the following description
I have tried to use these two references, to guide my code development. However, I constantly obtain the error statement
I have updated the gists with the information I have identified above. Please do help in this regard. |
Sorry it took me a while to get to this. Ivy doesn't have dependent types. It does have a form of subtyping, however, that might be helpful. In QUIC, this is used to represent the various frame types. Below, you can see an example using subtyping. There is an abstract type 'message' that has two subtypes called 'request' and 'response'. In Ivy these are called 'variants'.
There is an object called
Here
Here, if My apologies that this is not yet in the language documentation.
|
Thank you for the above example, in which we manually generate messages of only one subtype The code for I am however, having challenges in understanding how to automatically generate messages which may be of either subtype. I'm trying to build an encoder/decoder for the example you've described above. And I have difficulty in determining, how to describe the decoder, where different codecs need to be used, depending on the nature of the bit-stream.
I obtain the following error while compiling it:
|
Here's a simple example. We have two types of message with different payload types. Instead of using downcasts in the encoder, I've given each subtype its own encode method. Notice the abstract type Now if you run this, you'll see that Ivy's constrained randomization of bit vectors is not very good!
Output of this program:
|
Thank you for your guidance on this part. I have tried to write a decoder for the same, to test the decoding/encoding function and I prepared the following script, which however, leads to some compilation errors. Could you please help me debug the issue, to determine what I might have misunderstood about IvY? Thank you.
The test-script that I have written is as follows:
The compilation error obtained when compiling the test-script is as follows:
|
I'm not seeing that error. Perhaps we have a different versions of g++, or different versions of Ivy. Can you do the following and post the output:
where $IVYDIR is the Ivy source directory. Thanks. |
I apologize for the delay. I didn't see the updated notification in my mail.
|
Looks like we have the same versions of Ivy and g++. Can you attach a zip with the files |
I have zipped the two files you've requested for. Please do let me know if you can unzip these files. Else, I'll try to share the files via email. |
I feel uncertain about the following lines of code that I have included in the test-script. I'd appreciate it if you could provide some criticism about the following lines, as it'll help me understand what's the right way of specifying the requirements
Thank you for your help in this issue. |
It's fine, but I think you could simplify a bit:
I was able to repro the compile error above. I'll try to get that resolve soon. |
I tried to modify the above message-structure, to represent enumerated data-types, and the code doesn't compile in Ivy.
The above script generates the following compilation error
So, I guess the sub-typing feature is not supported for enumerated types. |
I attempted to handle enum-types in the below format and obtained the following compilation error for the test-script
where I have used the following scripts |
Please do help with any advice/suggestions on this topic. I really appreciate your guidance on this. Thank you. |
As per the implementation in QUIC, I understand that it's possible to send messages with dependent types. I would like to get some help in implementing this approach. The usecase I have is as follows:
I wish to generate message packets that are of this basic structure, where the load4 may or may not exist at all times.
Further, if
control
is the following enumerated-typeand
family
is a collection of data-types defined as followsI would like to select the type of
datagram.load4
based on the value ofdatagram.load3
.i.e in the scenario where we haveIf the above two situations do not exist, then
datagram.load4 = Not Defined
.i.e the datagram shall only consist of 3 components{load1, load2, load3}
How should one define these structures, to ensure that the messages are _generated() based on the above criteria?
Further, how should the encoder, decoder be designed for the same?
I am currently trying to explore Ivy to figure out how to achieve this functionality based on the Networking Branch defined
encoder/decoder architecture
. I would really appreciate some guidance in this regard.The text was updated successfully, but these errors were encountered: