[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why does this work? <SOLVED>
- From: "Stuart P. Bentley" <stuart@...>
- Date: Fri, 4 Feb 2011 08:52:13 -0800
?The way I conceptually internalize it is that all functions essentially
have this signature:
function (...) end
If the declaration has any keywords inside the parentheses (like
"function(str,last)"), the function works like it starts with this:
local str, last = ...
As such, function calls never care about what arguments a function is
supposed to take, because arguments are part of the function, not part of
From: Steve Litt
Sent: Thursday, February 03, 2011 P9:26 Newsgroups:
To: Lua mailing list
Subject: Re: Why does this work?
On Friday 04 February 2011 00:04:46 Geoff Leyland wrote:
On 4/02/2011, at 5:56 PM, Steve Litt wrote:
> Thanks Geoff,
> I think it does help. So I define my new function print() as taking
> argument str, so obviously when the program is run str is "Hello World".
> Then I pass that str to oldprint(), which is a reference to print(),
> which has already been defined as taking an argument, so no further
> definition or declaration needed.
> Does that about sum it up?
Yep. "oldprint(), which is a reference to *the original* print()"
If none of these functions were called "print" or anything like it, and
there weren't languages where print was part of the language and not just
a function, I think it'd all be much simpler to understand.
OK, I think I have it. Thanks.
Recession Relief Package