Example 1:
> s = "Hello";
> objectname("Hello");
s
Example 2:
> f = exp(x);
> g = sin(x);
> [| objectname(exp(x)), objectname(sin(x)), objectname(cos(x)) |];
[|"f", "g", "cos(x)"|]
Example 3:
> o = { .f = exp(x), .I = [-1;1] };
> s1 = o@""; s1;
{ .f = exp(x), .I = [-1;1] }
> s2 = objectname({ .I = [-1;1], .f = exp(x)}); s2;
o
> parse(s1) == parse(s2);
true
> write("s2 = \"", s2, "\" parses to ", parse(s2), "\n");
s2 = "o" parses to { .f = exp(x), .I = [-1;1] }
Example 4:
> n = 1664;
> objectname(n);
n
Example 5:
> f = exp(x);
> g = sin(x);
> procedure test() {
var f;
var h;
f = tan(x);
h = cos(x);
[| objectname(exp(x)), objectname(sin(x)), objectname(cos(x)), objectname(tan(x)) |];
};
> test();
[|"exp(x)", "g", "h", "f"|]
Example 6:
> procedure apply_proc(p, a, b) {
return p(a, b);
};
> procedure show_trace_and_add(n, m) {
var i, bt;
bt = getbacktrace();
write("Procedure stack:\n");
for i from 0 to length(bt) - 1 do {
write(" Procedure ", objectname((bt[i]).called_proc), " called with ", length((bt[i]).passed_args), " arguments\n");
};
write("\n");
return n + m;
};
> procedure show_and_succ(u) {
return apply_proc(show_trace_and_add, u, 1);
};
> show_and_succ(16);
Procedure stack:
Procedure show_trace_and_add called with 2 arguments
Procedure apply_proc called with 3 arguments
Procedure show_and_succ called with 1 arguments
17
Example 7:
> f = exp(three_decker_sauerkraut_and_toadstool_sandwich_with_arsenic_sauce);
> g = sin(_x_);
> h = f(g);
> h;
exp(sin(three_decker_sauerkraut_and_toadstool_sandwich_with_arsenic_sauce))
> objectname(_x_);
three_decker_sauerkraut_and_toadstool_sandwich_with_arsenic_sauce