Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -0,0 +1,13 @@
|
|||
# function names are global, the must be
|
||||
# implemented or declared before usage
|
||||
#
|
||||
func foo1 a .
|
||||
return a + 1
|
||||
.
|
||||
print foo1 2
|
||||
#
|
||||
funcdecl foo2 a .
|
||||
print foo2 2
|
||||
func foo2 a .
|
||||
return a + 2
|
||||
.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//func.call() /* invalid, can't call func before its declared */
|
||||
// func.call() /* invalid, can't call func before its defined */
|
||||
|
||||
var func = Fn.new { System.print("func has been called.") }
|
||||
|
||||
|
|
@ -7,8 +7,17 @@ func.call() // fine
|
|||
//C.init() /* not OK, as C is null at this point */
|
||||
|
||||
class C {
|
||||
static init() { method() } // fine even though 'method' not yet declared
|
||||
static init() { method() } // fine even though 'method' not yet defined
|
||||
static method() { System.print("method has been called.") }
|
||||
}
|
||||
|
||||
C.init() // fine
|
||||
|
||||
/* Although this function is recursive, there is no need for a forward
|
||||
declaration as it is top-level and begins with a capital letter. */
|
||||
var Fib = Fn.new { |n|
|
||||
if (n < 2) return n
|
||||
return Fib.call(n-1) + Fib.call(n-2) // Fib already visible here
|
||||
}
|
||||
|
||||
System.print(Fib.call(8)) // fine
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue