Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
One thing that always irks me about the definition of Golf,
A competition to find the shortest (fewest keystrokes) Perl code to solve a given problem.is how it hinges on the length of the representation of the solution. That's an interesting challenge, obviously, but most of the time I'd be far more interrested in a different challenge: A competition to find the shortest Perl code in terms of tokens to solve a given problem. where a token is one thing that represents a single semantic entity: Obviously deciding on precise criteria is more involved - it's obvious that functions and keywords count as one token, variables are harder to grasp since $t and $$t[0]->{x} shouldn't both count as a single token. The clearest rule seems to be that you can use exactly one sigil. Every additional sigil and pair of brackets/curlies counts as another token, but arrows count for naught since they're just syntactical sugar. The index inside the brackets/curlies is an extra token by itself, too (being the simplest form of expression). Finally, all pairing symbols, like the curlies that delimit a BLOCK or the brackets that construct an anonymous array, count as a single token (you can't leave out one of them). Most parens don't count - those that belong to a function call and others are only there for disambiguation and don't alter the meaning (or, the intent) of the code. Basically, this would be a competition to say something in the fewest words possible, as opposed to the Golf challenge to say something in the fewest letters possible. What do you think? Would such a competition be interesting? Are there loopholes in the rules, are more rules needed? What should it be named? How many questions can I ask? Makeshifts last the longest. In reply to Beyond Golf - reading between the tokens by Aristotle
|
|