[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Regarding elegance and beauty (Was: What's up with token filters)
- From: Robert Raschke <rrlua@...>
- Date: Mon, 16 Apr 2007 17:50:23 +0100
<slightly tongue in cheek>
Glenn Maynard wrote:
> On Fri, Apr 13, 2007 at 03:37:58PM +0100, Robert Raschke wrote:
>> My take on the "let's have more operators" is that it is so much
>> better to rethink a bit of code if you're finding it to be ugly. Real
>> beauty comes through the design of the solution, not through clever
> Are you suggesting redesigning code to avoid having to use the expression
> "ItemCount = ItemCount + 1"? That's terribly basic, and it seems like you'd
> have some contrived code if you tried to avoid it.
> (Incidentally, I'm not quick to suggest new operators, and have argued
> against operators like integer divide in the past. But when I find
> myself groaning so frequently at the lack of an operator that every other
> language I use supports, I start to think again ...)
Well, since Lua has this nice abstraction called functions, and you
find yourself writing lots of code involving the line "ItemCount =
ItemCount + 1" you might consider wrapping some of that in a function
that you can call at your leisure.
It all depends on what you're trying to achieve. I tend to use table
pairs/ipairs/next a lot where I would use "i++" et al a lot in C.
Ideally I would use table.foreach a lot more than I am. And so on.
r dot raschke at tombob dot com