lua-users home
lua-l archive

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


It was thus said that the Great Nilson once stated:
> On Wed, Sep 29, 2010 at 8:01 PM, Tim Mensch <tim-lua-l@bitgems.com> wrote:
> >
> > I get the difference. I really do. And yet a lot of users will NEVER get it
> > -- people who I will want to be able to extend my game, or my app, or
> > whatever. You're talking about an issue that, while it's obvious to an
> > expert (i.e., almost ANYONE reading this list), it's STILL easy to make a
> > mistake (especially if your life/job/habits/whatever causes you to ever use
> > other languages), and it simply is never a good answer to tell your end
> > users that they haven't tried hard enough to learn your product. That would
> > fall under "blaming the victim."
> >
> 
> I agree with you. And if my damage English allows, I would like to say more:
> 
> I dream with Lua running in almost everywhere. Lua should have the the
> popularity of PHP on Web servers, of Javascript in Web Browsers and
> Delphi (in good times) as Desktop Client. IMO, Lua should be popular
> even as a "Database Script Language" to run triggers functions like
> Postgresql PL/Lua does.
> 
> Why it is not?
> 
> 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, program.

  No, I think the reason Lua isn't "everywhere" is partly due to marketing,
and partly due to the "batteries not included" (PHP, on the other hand,
comes with every type of battery imaginable; it doesn't hurt that it comes
with practically every installation of PHP these days [2]).  

  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).

> With the existent tools, people are used to be productive in some
> level without need to understand "how the things really works".
> Perhaps they don't wanna know - so many things to do in so little
> time. But Lua requires exactly this knowledge on each "table access" -
> should I use a colon or a dot? Is it a field or a call? Is it a module
> or an "object"?

  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):

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

	print(foo.x)	-- outputs 0
	foo.bar(3)
	print(foo.x)	-- outputs 3

Or:

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

  But what happens to bar() in this example?

	foo = { x = 0 }
	function bar(x) return 3 * x + 5 end
	foo.bar = bar

  Does bar() suddenly receive a "self" paramter?  Or is it only functions
defined in a table that receive this "self" paramter?  Now, what about
functions like math.random() or os.exit()?  How do you distinguish between
functions that require the "self" parameter or not?

  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.

 -spc (Doesn't really see a problem with the differences between ':' and
	'.')

[1]	http://www.php.net/manual/en/types.comparisons.php

[2]	Apache 2.3.x has Lua embedded in it, and once 2.4 ships, I expect
	interest in Lua to pick up over the next few years as Linux
	distributions shift to Apache 2.4.

[3]	A card game, just in case some here have not heard of it.

[4]	I knew his son while in college.

[5]	Mid to late 80s we're talking about here.