Addons/script-engine/CCS Variables

Variable Structure

First of all, the structure of a variable:

Variable Structure

Name:

of course variables has their label to reference them in code

Socket:

basically contains the information about what value the variable has, but not the value itself!

Socket.Value:

the real value of the variable, but can be a pointer too. If you imagine variables as chests for values, pointers are portals which lead into other chests.
Of course that other chest may point towards another, but please, do not complicate the thing too much :) It wasn't made for that, altrough it does work. If you have in mind, that each of two "chests" will lead into the other, then I have to tell you: of course it will crash, but it won't leave to infinite cycle. When the first is set to point to the seconds it is all good. But when you set the second to point back to the first it will throw a CycledReferenceExcetion which will deny it.



Let's see what code lines does, and how variable values are modified:

<sub>#</sub>01| a := 5

Variable#00001
_.|_ Name = "a"
_.|_ Socket
_._._.|_ Value = 5

//value of 'a' is set

<sub>#</sub>02| b := a

Variable#00002
_.|_ Name = "b"
_.|_ Socket
_._._.|_ Value = 5


//value of 'a' is copied into variable 'b'

<sub>#</sub>03| a := <new object>

Variable#00001
_.|_ Name = "a"
_.|_ Socket
_._._.|_ Value = Object#01

//value of 'a' is now an object

<sub>#</sub>04| b := a

Variable#00002
_.|_ Name = "b"
_.|_ Socket
_._._.|_ Value = Object#01

//'b' is now the same object as 'a' (as for values)

<sub>#</sub>05| b {reference operator} a

Variable#00002
_.|_ Name = "b"
_.|_ Socket
_._._.|_ Pointer = --> a <--
_._._._._.|_ Behaviour

Behaviour of pointer depends on which reference operator do you use.
Check the reference operators here.

//variable 'b' now points to variable 'a'

Variable
_.|_ Name
_.|_ Socket
_._._.|_ Value/Pointer

Reference Types

It is important to mention, that the referenced variable does not change when a reference is created of it, altrough there are references which do modify its value when they got set. In other words, the reference does affect the value of the referenced variable, but not the other way: referenced variables do never change the socket of the references (only the referenced value will change, but the reference itself is still the same as before).

Reader

Sign: var <- x

Behaviour:

on Read:

Returns the value of the pointed variable.

on Write:

Writers the value into the socket.
Reference breaks.

Writer

Sign: var -> x

Behaviour:

on Read:

---

on Write:

---

Direct

Sign: var <-> x

Behaviour:

on Read:

---

on Write:

---

Deep Referencing

References can be created "deeply", which means, that they (may) will not reference to the variable put on the other side of the reference creator operator, but the deepest referenced accessible. This means, that if b is a reference of a, and I set deeply c to be reference of b, then c will point at a and not b; the b variable is complitely out of use for c.

How to make:

Deep Reader

Sign: var <-- x

Deep Writer

Sign: var --> x

Deep Direct

Sign: var <--> x

Blocking Deep Referencing

Making a deep reference of something makes sense, if that 'something' is a reference, elseway making a deep or a simple reference results exactly the same reference. You can set the 'deepblocking' when you create your reference. This property must be signed in the reference operator:

Base operatorDeepblocked
<-<-|
->->|
<-><->|
<--<--|
-->-->|
<--><-->|//The | character can be written by [AltGr] + [W]

Example of usage:

<sub>#</sub>01| a := 5//'a' set to 5
<sub>#</sub>02| b <-| a//'b' set to be deepblocked reader of 'a'
<sub>#</sub>03| c <--> b//'c' had access 'til 'b' in 'b' and no access to 'a'
//so became direct of b
//functions like a reader for 'b' and so as a reader of 'a' for now
//on write of 'c' it writes into 'b' (modifies socket of 'b')

Making Reference Readonly

Base operatorDeepblocked
<-|<-
->|->
<->|<->
<--|<--
-->|-->
<-->|<-->//The | character can be written by [AltGr] + [W]

Comments

Posts Quoted:
Reply
Clear All Quotes