# Can we use extract() function to write varbit data in other data types such as bit\<32\>? If yes, how?

**URL:** <https://forum.p4.org/t/can-we-use-extract-function-to-write-varbit-data-in-other-data-types-such-as-bit-32-if-yes-how/990>\
**Category:** Uncategorized\
**Created:** [October 11, 2023, 6:55pm UTC](https://forum.p4.org/t/can-we-use-extract-function-to-write-varbit-data-in-other-data-types-such-as-bit-32-if-yes-how/990 "2023-10-11T18:55:58Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![p4prof](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/p4prof/32/251_2.png) [@p4prof](https://forum.p4.org/u/p4prof)\
**Post date:** [October 11, 2023, 10:14pm UTC](https://forum.p4.org/t/can-we-use-extract-function-to-write-varbit-data-in-other-data-types-such-as-bit-32-if-yes-how/990/3 "2023-10-11T22:14:20Z")

</div>

Hello Sandeep,

There is an [enhancement request](https://github.com/p4lang/p4-spec/pull/883) for the P4 specification, but it has not been approved or implemented.

Obviously, this does not prohibit individual architectures to define their own extern methods that would do the same thing (and in certain cases they would be relatively straightforward to implement), but I haven’t heard of any that would actually implement such a functionality.

As of today, the rule is very simple: use `varbit` only if you intend to carry a variable-length field from ingress to egress without doing any “real” processing. If you want to do any processing (lookup, modification, etc, etc.) use multiple fixed-length chunks instead, as described in @andyfingerhut’s guide or as was clearly suggested in [my previous post](https://forum.p4.org/t/implementing-checksum-for-ipv4-headers-with-options-in-p4-without-extern-functions/985/2).

Happy hacking,  
Vladimir

---

_[View the full topic](https://forum.p4.org/t/can-we-use-extract-function-to-write-varbit-data-in-other-data-types-such-as-bit-32-if-yes-how/990)._
