Difference between revisions of "Array"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(3 intermediate revisions by 3 users not shown)
Line 4: Line 4:
Example for a standard array :
Example for a standard array :


array EXAMPLE = ["apple" , "banana", "strawberry"];
array FRUITS = ["apple" , "banana", "strawberry"];


here EXAMPLE[1] = "banana"
here FRUITS[1] = "banana"


Example for an associative array :
Example for an associative array :


array ASSOCIATIVE;
array EXAMPLE;


ASSOCIATIVE["fruit"] = "apple";
EXAMPLE["fruit"] = "apple";


ASSICIARIVE["beverage"] = "coffee";
EXAMPLE["beverage"] = "coffee";


ASSOCIATIVE["meat"] = "chicken";
EXAMPLE["meat"] = "chicken";




Functions:
[[llForeach]]
<!-- Lines below added by ANSI Soderstrom (2010/04/24) -->
These functions have been created and contributed by LSL users to perform operations not covered by built-in LSL functions :


Functions:
[[User:ANSI_Soderstrom/Simple_LSL_Array_(Associative)|Simple LSL Array (Associative)]]
<!-- Lines above added by ANSI Soderstrom (2010/04/24) -->
----


{{LSLG|llForeach}}
Reasons not to implement this suggestion as it is currently formulated:
#Associative Arrays would be double the memory footprint of ordinary lists. Memory limitations are a major concern.
#It would require major changes to LSL in bytecode, functions and syntax.
#*There are no LSO bytecodes currently implemented that can perform these tasks. This is not a trivial change.
#*Obviously the LSL compiler would need to be changed to support this new syntax. This is not a trivial change.
#*Since the array type is new, there are no functions that can deal with it.
#The difference between list and array syntax could be confusing to both the compiler and user, excluding associative arrays there is no meaningful reason why array style syntax can't be implemented with lists.

Latest revision as of 08:22, 24 April 2010

An array is a data structure consisting of a group of elements having a single name that are accessed by indexing. These elements can be of all other types like float, string or vector.

Example for a standard array :

array FRUITS = ["apple" , "banana", "strawberry"];

here FRUITS[1] = "banana"

Example for an associative array :

array EXAMPLE;

EXAMPLE["fruit"] = "apple";

EXAMPLE["beverage"] = "coffee";

EXAMPLE["meat"] = "chicken";


Functions:

llForeach

These functions have been created and contributed by LSL users to perform operations not covered by built-in LSL functions :

Simple LSL Array (Associative)


Reasons not to implement this suggestion as it is currently formulated:

  1. Associative Arrays would be double the memory footprint of ordinary lists. Memory limitations are a major concern.
  2. It would require major changes to LSL in bytecode, functions and syntax.
    • There are no LSO bytecodes currently implemented that can perform these tasks. This is not a trivial change.
    • Obviously the LSL compiler would need to be changed to support this new syntax. This is not a trivial change.
    • Since the array type is new, there are no functions that can deal with it.
  3. The difference between list and array syntax could be confusing to both the compiler and user, excluding associative arrays there is no meaningful reason why array style syntax can't be implemented with lists.