Daimonin
Members login
Sign Up!      problems?
N F
* Daimonin Forum
Home Help Search Calendar

Welcome Guest, you have to register to post here.
Search

News

Stats
75655 Posts in 6829 Topics by 8142 Members
Latest Member: mattj
Daimonin Forum  |  Development  |  Scripts  |  Topic: Prototype functions in LUA « previous next »
Pages: [1] Go Down Print
Topic: Prototype functions in LUA  (Read 382 times)
Torchwood
MapMaster
*
*
*


Karma: +35/-5
Posts: 968



View Profile
« on: April 20, 2008, 02:50:01 pm »


In LUA, I've found this will fail:

Code:
-- Define foo
local function foo()
    -- Execute the bar function
    bar()
end

-- Now define bar
local function bar()
    ...
end

Is it possible to 'prototype' the bar() function somehow as you do in C, or are you restricted to always defining functions before they are used?
Logged

smacky
Administrator
*
*
*
*


Karma: +120/-101
Posts: 5381



View Profile
« Reply #1 on: April 20, 2008, 03:55:53 pm »

bar() has to be defined before it is referenced (when it is local).

So swap the order of foo() and bar().
Logged

Torchwood
MapMaster
*
*
*


Karma: +35/-5
Posts: 968



View Profile
« Reply #2 on: April 20, 2008, 05:22:56 pm »


Thought as much!  Oh well, not too much of a problem ...
Logged

Pages: [1] Go Up Print 
Daimonin Forum  |  Development  |  Scripts  |  Topic: Prototype functions in LUA « previous next »
Jump to:  

Page created in 0.064 seconds with 17 queries.
Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks
Copyright 2008 Daimonin MMORPG  •  Terms of Service  •  XHTML  •  Daimonin sourceforge open source project