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

lkcl luke.leighton at gmail.com
Sat Aug 6 03:59:29 BST 2022


On Sat, Aug 6, 2022 at 2:44 AM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> 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.

i'm going to be blunt: tough.   python != "most other programming languages".

please get it into your head that python's strength is its use of
the liskov substitution principle.

types destroy that and i have gone beyond getting irritated that
you keep a disdain and disrespect in your mind for the use of
LSP in python by continuing to complain year after year that
it is "not like rust, rust is better better better better better in
every conceivable way in every conceivable circumstance".

structs poison python with the type-restricting of those other
languages that you consider are superior in every way conceivable
to python.

i have also just removed all of the type-assertions that you
had added to the same module for exactly the same underlying
reason.

in *all* code that is directly related to the HDL being developed
i am *going* to remove - 100% without fail - every "assert type(x) == int"
that you add and i am *going* to remove every use of type-declarations
until you get the damn message finally that python is based on the
Liskov Substitution Princple.


> 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

added recently i will ask him to remove it and find another way.

> 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

read - again:
"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).
"

l.



More information about the Libre-soc-dev mailing list