News for hackers. Stuff that matters.
Re:Can you use a class in C? by ElegantBeef on Monday August 14, 2023 @02:00AM (#37117953)
Again that's this language constraining you to that. With procedure overloading it's not required that you have to have that ugly API. For instance the following is valid Nim:

  type
    Cat = object # these are just 'struct' in a different skin
    Dog = object

  proc greet(c: Cat): string = "Meow"
  proc greet(d: Dog): string = "Bark"

  assert Dog().greet() == "Bark"
  assert Cat().greet() == "Meow"

There are no comments on this comment yet.