lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

 On 9/29/2010 8:36 PM, Sean Conner wrote:

 I don't know exactly why, but I would bet a nickel that the "colon
  call" is part of the equation.

 I doubt that.  Look at PHP and all the horrible inconsistencies it
 has (equality testing [1], inconsistent function naming and
 parameter order, single name space for the longest time, the use of
 '\' to denote name spaces in contrast to every other langauge out
 there) and yet people who otherwise wouldn't (or shouldn't) program,

PHP sucks; no question. Your point of "batteries included" is a big part of it, along with the fact that it's distributed with Apache (you said "distributed with PHP," but I knew what you meant ;).

Unfortunately, I think the C-like (and therefore Java- and Javascript-like) syntax of PHP is the other piece of the puzzle of its extreme popularity. As Steve Yegge said, the "next big language" is going to have a C-style syntax. [1] And I agree with him, as much as I like (and will continue to use and promote) Lua.

 I also don't buy the "newbies will be confused by this" argument;
 anyone can get used to anything if they work at it.  I knew of a
 professional Bridge player [3][4] who wrote a Bridge program in 8088
 assembly [5] because that's all he had at the time (and frankly, I
 don't know any programmers who *like* 8088 Assembly (that is, if
 they're familiar with it) because it's all special cases).

I'm not talking about newbies. At 13 I figured out Z-80 assembly language and wrote a game on the TRS-80. So what?

I'm talking about handing my game to a producer/designer and saying, "OK, go script me a dozen more levels like this." Peter points out that a purpose-build mini language would be the thing to use, and I agree. But I hate to slow down my whole game by using one of the dot syntax forms (__call or coroutines) to access objects, so I need to go to the other extreme and make sure that everything that's a call uses a colon.

And you know what? I can guarantee that producer/designer is STILL going to make mistakes and use a dot, if anything in the game, ever, uses a dot for access (to get values, for example). And then it's going to crash, and he's not going to know why.

 So, if I understand this, what you would like is that any function
 defined in a table automatically receives its table as the "self"
 argument when called.  So, in OOLua (for lack of a better name):

No, you didn't understand. At least you missed an important point:

 foo = { bar = function(x) self.x = x return x end , x = 0 }
 print(foo.x) print(foo.x)

Defined this way, would fail with "attempt to index a number," because it's being defined with "function" instead of "method" or whatever the other keyword is supposed to be. The other ambiguities were things that he presented, and are worth discussing.

 The other half of this argument is changing the ":" to some other
 character or sequence of characters to make it visually distinctive
 from the ".".  I personally don't mind the ':', and would prefer it
 remain the ':' but I guess I could get used to it being '->' but I
 wouldn't like it.

The OP was mostly concerned with "just making dot work," and I feel that's the most elegant solution. Some folks objected to "->", and frankly it's not pretty -- and though it does satisfy the "make it different" criteria, I don't know that it would satisfy the "make it easier for non-experts" criteria, since they still have to understand the underlying semantics of when to use it.