Hacker News new | ask | show | jobs
by ppog 3278 days ago
"Scanning a cond for me is almost instantaneous." This is a very subjective concern though. Consider the subtype example. For me, reading that 3x3 table, especially with the grouping of blocks, was a lot easier than mentally parsing a big pile of 'and/or' expressions, or nested switches, etc. And my impression is that a lot of programmers do initially visualise some parts of their work as tables or diagrams.

Our tools on the other hand are indeed 'so finely attuned and specialised to text' that other methods of representation have and will struggle to get traction...

1 comments

I feel like most of these complicated if else statements can generally be written much better for example.

    SUPERTYPES = {'Real': ['Integer'],
                  'Complex': ['Real'],
                  'Integer': []}
            
    def is_subtype(a, b):
        if a == b:
            return True
        return any(is_subtype(x, b) for x in SUPERTYPES[a])
Which better expresses the intention of the code and is more flexible.