Hacker Newsnew | past | comments | ask | show | jobs | submit | nikbackm's commentslogin

Why even call it in that case?


Typo in this case, but in general supporting "useless" code like this is sometimes a good idea because it makes writing generic code easier. Maybe not in this case.


The counter is useless code often is a sign of a bug. Possibly someone started implementing something and then failed to finish it. I often want my compiler to warn on useless code.


No, I mean the API should support "useless" code where it makes sense, not that you should manually write it. I don't actually think it applies in this case, but just as a general principle.

A classic example of where they didn't do this right is SystemVerilog arrays. You cannot have busses with zero wires in them. "Why would you need that?" somebody probably said... What's the point of a bus with no wires? Well imagine you write a SystemVerilog module with some memory interface like this:

  module foo (
    input var logic [31:0] i_addr,
    input var logic [7:0] i_data,
    input var logic [3:0] i_user_data,
  ...
But now you want to make it generic. No problem!

  module foo #(
    parameter A = 32,
    parameter D = 8,
    parameter U = 4
  ) (
    input var logic [(A-1):0] i_addr,
    input var logic [(D-1):0] i_data,
    input var logic [(U-1):0] i_user_data,
Now suppose you don't have any user data. You set U=0, but that gives `logic [-1:0]` which is invalid because they made the incorrect decision to use closed interval syntax. In fairness Verilog is very old so maybe it wasn't so obvious back then that you always use 0-based indexing with right-open intervals.


> I mean the API should support "useless" code where it makes sense, not that you should manually write it.

There is the conflict - if I write useless code I want the compiler to stop me. This is very different from generic code where sometimes a part simplifies to useless code in some particular context even though the whole is useful. Anytime the system can tell the difference between these two I want them treated different.

Telling the difference between useless code and generic code that has a useless form in this context is often not a solvable problem. There are also cases where if we had known better 40 years ago we would have made a different choice, but it is too late now. However I think the rules stands: the system should reject useless code when that is what someone writes even if the code otherwise parses correctly.


Yes, if they explicitly call code that appears useless than a warning makes sense. Not if you write a public API that supports it though.


If you write an API you have a responsibility to ensure it cannot be misused. This is very hard.


It's apparently a typo in the article, they probably meant to write `println()`.


Maybe related to text encodings?

I think riggrep will not search UTF-16 files by default. I had some such issue once at least.


No it’s not.


Geopolitical rivals then if you prefer that.


Clean, beautiful lead.


I can hear him saying it, shit.


I’ve been joking he’s going to try and bring back leaded gas.



Who knows?

Can't imagine anyone here using 32bit Windows and limiting themselves to 4GB of RAM.

Are there even any cheap laptops sold with that little nowadays?


No, how does that relate?


I'm pretty sure it would be something like even if a star was coming and we saw it what the fuck could we even do it would just create mass panic, hysteria and would make everyone hella religious depending on how early we detect it though we might have some time to make good memories before we die. atleast I would prefer a black hole smashing into us unbeknownst to us instead of a known star. Also no one would want to show up to jobs and stuff


Sounds like a protection racket.


So similar in that regard to Herb Sutter's experimental Cpp2 perhaps?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: