News for hackers. Stuff that matters.
Re:TypeScript Is Surprisingly OK for Compilers by paulddraper on Friday August 18, 2023 @04:49PM (#37181918)
> Are there other languages that do this so nicely? It's the perfect blend of OO and functional.

Python

  compressor = lambda x: x / 2
  compressor(5)

  helpful_compressor = lambda x: x / 2
  helpful_compressor.help = "compressor"
  helpful_compressor(5)
  helpful_compressor.help
Scala

  val compressor = (x: double) => x / 2
  compressor(5)

  object helpfulCompressor {
    def apply(x: double) = x / 2
    val help = "compressor"
  }
  helpfulCompressor(5)
  helpfulCompressor.help
Ruby also has .call...but I can't remember it well enough

There are no comments on this comment yet.