[Libre-soc-dev] dataclasses in hdl -- was: copying from irc: you broke it

Jacob Lifshay programmerjake at gmail.com
Sat Aug 6 02:43:50 BST 2022


cc-ing mailing list as this should be discussed there, not trimming context
so others can see what was said.

On Fri, Aug 5, 2022, 17:10 lkcl <luke.leighton at gmail.com> wrote:

> as you know and have been told many times, types are not to be used in
> HDL. knowing this in advance you should not have added code which then
> depends on that, such that their removal caused the tests to break.
>

dataclasses are an exception, and have been, because type annotations are
necessary there and because dataclasses are very useful for quickly getting
==, !=, repr, hash, init, <, >, <=, >=, read-only fields, and field
introspection (via. the fields and replace functions).

they are quite easy to read/understand -- imho often more so than python's
standard init method of making instance attributes by doing `self.field =
...` because dataclasses are like structs in most other programming
languages.

also I'm not the only one using dataclasses extensively in hdl:
https://git.libre-soc.org/?p=openpower-isa.git&a=search&h=refs%2Fheads%2Fbinutils&st=grep&s=dataclass

also you were just fine with the very extensive use of dataclasses in
nmigen:
https://gitlab.com/search?page=7&project_id=32437472&search=dataclass

>
> thus i leave it with you as your responsibility to fix the tests that you
> know should not have been made to depend on types.
>

> if i see any others you know 100% without fail that i will remove them.
>
> the only exception to that is the formal correctness proofs in nmigen
> where the value is clear (and also it is not the soc HDL).
>

imho the value is just as clear in hdl as anywhere else...dataclasses are
very useful and often a code clarity improvement.

>
> l.
>
>
> On August 5, 2022 11:09:50 AM GMT+01:00, Jacob Lifshay <
> programmerjake at gmail.com> wrote:
>>
>> iirc you aren't getting irc messages due to not being at home:
>>
>> lkcl: you broke it:
>> https://salsa.debian.org/Kazan-team/mirrors/nmutil/-/pipelines/407801
>> please revert removal of dataclasses, they add eq, hash, and repr, which
>> are needed for the tests
>>
>> Jacob
>>
>


More information about the Libre-soc-dev mailing list