Advanced Computing Environment
Hosted by SourceForge
brix-os project page

Previous: Scoping ----- Up: Contents ----- Next: Default Parameters


show notes
Features that need to be added to the page or ideas that haven't been thought out.
  • a flag to make the symbolic key a string variable from which the real key name is acquired
    	`key foo::value // get key name from variable foo
  • a flag for array indices to pull a key name from a variable
    	a[`key foo] // get key name from variable foo

The compiler has an internal type that it uses to hold sequences represented with parentheses, braces or brackets, and may have optional symbolic keys bound to each element.

	// calling a function using parameter labels
	foo := def (text:String, size:Int) ...;
	foo(text:: "some text", size:: 14)

	// prototype object
	foo := {x::0, y::0}
	x := foo.x

	// associative array
	foo := [a::1, b::2, "with space"::3]
	b := foo["b"] // returns 2

The :: operator is used to bind symbolic or double quoted keys to values and may be surrounded by whitespace. The usage of symbolic or quoted keys depends on how the receiver uses them. Prototypes use the keys as slot names and do not support quoted keys. Associative arrays accept symbolic or quoted keys but require them to be quoted when used as indices to distinguish them from numeric indices.

Previous: Scoping ----- Up: Contents ----- Next: Default Parameters