Hacker News new | past | comments | ask | show | jobs | submit login

Yes, but it would be nicer if the table was stored as a table -- as data -- not as code.



Why? It'd be a mapping from "patterns" (a concept that exists only within the language's compiler/interpreter) to executable closures. How is that any different from the AST of the match-expression in the GP's comment? And what would you do with that mapping, besides using it as an AST to generate code, perhaps after adding/removing some match clauses?

In this case, the most optimal representation of the data is the code.


I would go with a "compromise"; while decision tables should be "code", I think it could be nice if there was some syntatic sugar for making these tables actually tabular. Of course semantically it would be very much the same as a pattern match.


> what would you do with that mapping

Well, I could write another tool to analyse it, eg extract some statistics; I could write another tool to generate it, eg based on data.


Why can't you do either of those things with the AST of the match-expression? And what stops you from leaving the code as code, and extracting that AST by calling into the compiler?

(Maybe I'm being unfair here. I write mostly Elixir, and it's really easy in Elixir—one or two lines—to extract the AST of the body of a function defined in a given file and then work with it. It's just as easy to hold data canonically in its AST representation, and then both analyze it, and generate code from it, at runtime.)




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

Search: