Properties of types and values

This chapter defines cross-cutting value behavior: equality, boolean contexts, string conversion, and the (deliberately minimal) set of implicit conversions.

No implicit conversion

The language performs no implicit conversion between unrelated types at run time. Operations that require a particular type assert it and raise a run-time type error on mismatch (Error conditions). In particular:

The single exception is conversion to string, which always succeeds (see String conversion) and is what makes interpolation and concatenation work on any value.

Equality

eq and ne (and ismember) compare as follows:

Type Compares equal when …
null both are null
bool same value
int same value
string same byte content
entity reference denotes the same entity
prototype same vnum
room same room
iterable never (even to itself)
block / list identity only
[eq 1 1]            # true
[eq '1' 1]          # false — string vs int
[eq true 1]         # false  — bool vs int
[eq $a $b]          # creatures: equal iff same creature

Boolean contexts

Every boolean context requires a value of type bool. There is no truthiness coercion at runtime: passing any non-bool value raises a type error and halts the script.

The boolean contexts are:

String conversion

Any value may convert to a string. This conversion is invoked by interpolation and whenever a string is required.

Type Rendering
null "" (empty)
bool "true" / "false"
int decimal digits
string itself
creature #mob:N# (NPC) or #player:N# (PC)
mob_proto #mob:N#
object #obj:N#
obj_proto #obj:N#
room #room:N# (N is the room number)
iterable elements space-joined (brace-quoting elements that contain spaces or braces); deferred iterables (from select and slice) render as <iterable>
block <block>
list <list> (elements are not rendered)

Binding and sharing

When a value is read from a variable or passed as an argument, the relationship between the original and the new binding depends on type:

A block may access its enclosing bindings for as long as the block exists (Declarations and scope).