Duplicated Members And Functions in Structure Definitions

In versions prior to 3ds Max 2014, both duplicated Members and Function definitions were allowed.

EXAMPLE PRIOR TO 3DS MAX 2014:
struct test 
(
test = 1,
test = 2
)
a = test()
a.test
OUTPUT:
2

Starting with 3ds Max 2014, duplicated Member definitions are disallowed and a Compile-time error is generated:

EXAMPLE IN 3DS MAX 2014:
struct test 
(
test = 1,
test = 2
)
a = test()
a.test
OUTPUT:
-- Error occurred in anonymous codeblock; filename: ; position: 32; line: 4
-- Compile error: Duplicate struct member name:  test
--  In line: test=

The same applies to duplicated names in Members and Functions.

Prior to 3ds Max 2014, an error is caused by the member test being undefined and the function call test() attempting to access the member test due to the duplicated name:

EXAMPLE PRIOR TO 3DS MAX 2014:
struct test 
(
test,
fn test2 = test(),
fn test = print "hello!"
)
a = test()
a.test2()
OUTPUT:
#Struct:Test(
  Test:<fn>; Public,
  test2:<fn>; Public)
(Test)
-- Error occurred in test2(); filename: C:\Program Files\Autodesk\3ds Max 2013\scripts\; position: 40; line: 4
--  Frame:
-- Type error: Call needs function or class, got: undefined

Starting with 3ds Max 2014, a Compile-time error is caused by the name duplication of Member test and the Function test:

EXAMPLE IN 3DS MAX 2014:
struct test 
(
test,
fn test2 = test(),
fn test = print "hello!"
)
a = test()
a.test2()
OUTPUT:
-- Error occurred in anonymous codeblock; filename: ; position: 52; line: 5
-- Compile error: Duplicate struct member name:  test
--  In line: fn test =

   

Duplicated Function definitions are allowed both prior and after 3ds Max 2014 - the last defined function will be used.

This provides a way to perform forward declarations of Functions.

TEST WITHOUT FORWARD DECLARATION:
struct test 
(
fn test2 = test(),
fn test = print "hello!"
)
a = test()
a.test2()
OUTPUT:
#Struct:test(
  test2:<fn>; Public,
  test:<fn>; Public)
(test)
(test)

   

TEST WITH FORWARD DECLARATION:
struct test 
(
fn test = (), -- Pre-declare test to allow test2 to "see" it
fn test2 = test(), -- Point at the pre-declared function
fn test = print "hello!" -- Replace existing test definition, test2 now sees the new definition
)
a = test()
a.test2()
OUTPUT:
#Struct:test(
  test2:<fn>; Public,
  test:<fn>; Public)
(test)
"hello!"
"hello!"

In this case, the Function test2 first points at the first occurrence of test, then as test is redefined, test2 starts pointing at the latest definition of test.