<commit_before>\chapter{Basic Objects, Value Model}
\label{sec:tut:value}

In this section, we focus on \us values as objects, and study \us
by-reference values model. We won't study classes and actual objective
programming yet, these points will be presented in
\autoref{sec:tut:object}.

\section{Objects in \us}
\label{sec:tut:objects}
An object in \us is a rather simple concept: a list of slots. A
\dfn{slot} is a value associated to a name. So an \dfn{object} is a
list of slot names, each of which indexes a value --- just like a
dictionary.

\begin{urbiscript}[firstnumber=1]
// Create a fresh object with two slots.
class Foo
{
  var a = 42;
  var b = "foo";
};
[00000000] Foo
\end{urbiscript}

The \lstinline{localSlotNames} method lists the names of the slots of
an object (\refObject{Object}).

\begin{urbiscript}
// Inspect it.
Foo.localSlotNames;
[00000000] ["type", "a", "asFoo", "b"]
\end{urbiscript} % fix color $

You can get an object's slot value by using the dot (\lstinline{.})
operator on this object, followed by the name of the slot.

\begin{urbiscript}
// We now know the name of its slots. Let's see their value.
Foo.a;
[00000000] 42
Foo.b;
[00000000] "foo"
\end{urbiscript}

It's as simple as this.  The \lstinline|inspect| method provides a
convenient short-hand to discover an object (\refObject{Object}).

\begin{urbiscript}
Foo.inspect;
[00000009] *** Inspecting Foo
[00000010] *** ** Prototypes:
[00000011] ***   Object
[00000012] *** ** Local Slots:
[00000013] ***   type : String
[00000014] ***   a : Float
[00000015] ***   asFoo : Code
[00000016] ***   b : String
\end{urbiscript} % fix color $
<commit_msg>Doc: fix object slots print order.<commit_after>\chapter{Basic Objects, Value Model}
\label{sec:tut:value}

In this section, we focus on \us values as objects, and study \us
by-reference values model. We won't study classes and actual objective
programming yet, these points will be presented in
\autoref{sec:tut:object}.

\section{Objects in \us}
\label{sec:tut:objects}
An object in \us is a rather simple concept: a list of slots. A
\dfn{slot} is a value associated to a name. So an \dfn{object} is a
list of slot names, each of which indexes a value --- just like a
dictionary.

\begin{urbiscript}[firstnumber=1]
// Create a fresh object with two slots.
class Foo
{
  var a = 42;
  var b = "foo";
};
[00000000] Foo
\end{urbiscript}

The \lstinline{localSlotNames} method lists the names of the slots of
an object (\refObject{Object}).

\begin{urbiscript}
// Inspect it.
Foo.localSlotNames;
[00000000] ["a", "asFoo", "b", "type"]
\end{urbiscript} % fix color $

You can get an object's slot value by using the dot (\lstinline{.})
operator on this object, followed by the name of the slot.

\begin{urbiscript}
// We now know the name of its slots. Let's see their value.
Foo.a;
[00000000] 42
Foo.b;
[00000000] "foo"
\end{urbiscript}

It's as simple as this.  The \lstinline|inspect| method provides a
convenient short-hand to discover an object (\refObject{Object}).

\begin{urbiscript}
Foo.inspect;
[00000009] *** Inspecting Foo
[00000010] *** ** Prototypes:
[00000011] ***   Object
[00000012] *** ** Local Slots:
[00000014] ***   a : Float
[00000015] ***   asFoo : Code
[00000016] ***   b : String
[00000013] ***   type : String
\end{urbiscript} % fix color $

{'fraction_non_alphanumeric': 0.12881765951013002, 'fraction_numerical': 0.06108255216208044, 'mean_word_length': 4.176838810641628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 10, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2188352', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1086, 'n_words': 431}