OK, I admit it: it'd be convenient if #JavaScript classes could have decorators on methods. Memoization of async methods would be so much cleaner and more reusable if we had them.
@mauve I recently switched from TypeScript to Java and I am such a fan of Java’s annotations. IMO metaprogramming is Good Actually, and full annotations (like the JavaScript decorators were initially proposed as) are a way to get it that’s sometimes more palatable than full macros.
@mauve I have seen people productively do stuff involving higher-order classes for things like this but I think it’s a bit fraught. Like you can absolutely make a function that takes a class and an array of method names to modify and gives you back a modified class, but I’ve been bit hard by how incomprehensible the results can be when I didn’t know the secret.
@mauve I have seen people productively do stuff involving higher-order classes for things like this but I think it’s a bit fraught. Like you can absolutely make a function that takes a class and an array of method names to modify and gives you back a modified class, but I’ve been bit hard by how incomprehensible the results can be when I didn’t know the secret.