coldmud-0.10.doc.ps.gz

snippets · 73.0 KB · 2010-03-30

ColdMUD manual in PostScript (generated Jan 1994).

Download   « Back to the snippets list

%!PS-Adobe-2.0
%%Creator: dvips 5.495 Copyright 1986, 1992 Radical Eye Software
%%Title: coldmud.dvi
%%CreationDate: Mon Jan  3 22:18:06 1994
%%Pages: 90
%%PageOrder: Ascend
%%BoundingBox: 0 0 612 792
%%DocumentFonts: NewCenturySchlbk-Bold NewCenturySchlbk-Roman Courier
%%+ NewCenturySchlbk-Italic
%%EndComments
%DVIPSCommandLine: dvips -o coldmud.ps coldmud.dvi
%DVIPSSource:  TeX output 1994.01.03:2215
%%BeginProcSet: tex.pro
%!
/TeXDict 250 dict def TeXDict begin /N{def}def /B{bind def}N /S{exch}N /X{S N}
B /TR{translate}N /isls false N /vsize 11 72 mul N /@rigin{isls{[0 -1 1 0 0 0]
concat}if 72 Resolution div 72 VResolution div neg scale isls{Resolution hsize
-72 div mul 0 TR}if Resolution VResolution vsize -72 div 1 add mul TR matrix
currentmatrix dup dup 4 get round 4 exch put dup dup 5 get round 5 exch put
setmatrix}N /@landscape{/isls true N}B /@manualfeed{statusdict /manualfeed
true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0 0]N /FBB[0 0 0 0]N /nn 0 N
/IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn begin /FontType 3 N /FontMatrix
fntrx N /FontBBox FBB N string /base X array /BitMaps X /BuildChar{
CharBuilder}N /Encoding IE N end dup{/foo setfont}2 array copy cvx N load 0 nn
put /ctr 0 N[}B /df{/sf 1 N /fntrx FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0
0 sf neg 0 0]N df-tail}B /E{pop nn dup definefont setfont}B /ch-width{ch-data
dup length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128
ch-data dup length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub get 127
sub}B /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data dup type
/stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N /rc 0 N /gp 0 N
/cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup /base get 2 index get
S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff ch-yoff ch-height
sub ch-xoff ch-width add ch-yoff setcachedevice ch-width ch-height true[1 0 0
-1 -.1 ch-xoff sub ch-yoff .1 add]{ch-image}imagemask restore}B /D{/cc X dup
type /stringtype ne{]}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1
ne{dup dup length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}
B /I{cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin
0 0 moveto /V matrix currentmatrix dup 1 get dup mul exch 0 get dup mul add
.99 lt{/QV}{/RV}ifelse load def pop pop}N /eop{SI restore showpage userdict
/eop-hook known{eop-hook}if}N /@start{userdict /start-hook known{start-hook}
if pop /VResolution X /Resolution X 1000 div /DVImag X /IE 256 array N 0 1 255
{IE S 1 string dup 0 3 index put cvn put}for 65781.76 div /vsize X 65781.76
div /hsize X}N /p{show}N /RMat[1 0 0 -1 0 0]N /BDot 260 string N /rulex 0 N
/ruley 0 N /v{/ruley X /rulex X V}B /V{}B /RV statusdict begin /product where{
pop product dup length 7 ge{0 7 getinterval dup(Display)eq exch 0 4
getinterval(NeXT)eq or}{pop false}ifelse}{false}ifelse end{{gsave TR -.1 -.1
TR 1 1 scale rulex ruley false RMat{BDot}imagemask grestore}}{{gsave TR -.1
-.1 TR rulex ruley scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /QV{
gsave transform round exch round exch itransform moveto rulex 0 rlineto 0
ruley neg rlineto rulex neg 0 rlineto fill grestore}B /a{moveto}B /delta 0 N
/tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}B /c{-4 M}
B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{3 M}B /k{4 M}B
/w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w}B /q{p 1 w}B /r{
p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{3 2 roll p a}B /bos{/SS save
N}B /eos{SS restore}B end
%%EndProcSet
%%BeginProcSet: texps.pro
%!
TeXDict begin /rf{findfont dup length 1 add dict begin{1 index /FID ne 2 index
/UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll exec 0 exch 5
-1 roll VResolution Resolution div mul neg 0 0]/Metrics exch def dict begin
Encoding{exch dup type /integertype ne{pop pop 1 sub dup 0 le{pop}{[}ifelse}{
FontMatrix 0 get div Metrics 0 get div def}ifelse}forall Metrics /Metrics
currentdict end def[2 index currentdict end definefont 3 -1 roll makefont
/setfont load]cvx def}def /ObliqueSlant{dup sin S cos div neg}B /SlantFont{4
index mul add}def /ExtendFont{3 -1 roll mul exch}def /ReEncodeFont{/Encoding
exch def}def end
%%EndProcSet
TeXDict begin 40258431 52099146 1000 600 600
(/afs/sipb.mit.edu/project/coldmud/dev-0.10/doc/coldmud.dvi)
@start /Fa 1 59 df<1E007F807F80FFC0FFC0FFC0FFC07F807F801E000A0A798919>58
D E /Fb 1 59 df<0F003FC07FE0FFF0FFF0FFF0FFF0FFF0FFF07FE03FC00F000C0C768B21>58
D E /Fc 81[61 53[53 78 53 61 39 46 44 1[57 50 61 89 31 1[29
31 61 53 1[50 57 44 55 55 14[72 2[78 1[94 3[41 2[66 72 78 72
9[55 1[55 55 55 55 55 55 55 49[{}38 100.000000 /NewCenturySchlbk-Roman
rf /Fd 81[46 52[40 40 58 40 46 29 35 33 42 43 37 46 66 24 44
22 24 46 40 25 37 43 33 42 42 9[73 54 61 50 47 54 1[50 58 61
71 50 2[30 62 58 50 54 58 54 54 54 7[42 42 42 42 42 42 42 42
42 42 21 1[25 21 2[25 25 40[{}61 75.000000 /NewCenturySchlbk-Roman
rf /Fe 1 59 df<3C7EFFFFFFFF7E3C08087A8715>58 D E /Ff 134[45
45 45 45 45 45 45 45 45 45 45 45 45 45 45 1[45 45 45 45 45
45 45 45 45 29[45 21[45 45[{}26 75.000000 /Courier rf /Fg 134[67
67 2[75 47 55 57 1[73 67 75 105 38 2[40 75 67 42 63 73 61 71
67 10[83 1[79 73 2[83 91 91 107 79 3[95 1[79 83 91 85 85 83
7[63 63 63 63 63 63 63 63 51 63 1[30 36 45[{}47 109.583275
/NewCenturySchlbk-Bold rf /Fh 1 50 df<00380000780001F8001FF800FEF800E0F80000F8
0000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F8
0000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F8
0000F80000F80001FC00FFFFF8FFFFF815267BA521>49 D E /Fi 80[56
56 51[42 45 45 71 47 56 32 40 40 51 52 45 56 81 30 51 29 30
56 49 30 40 56 40 51 52 11[74 1[61 2[61 71 2[61 9[66 64 14[51
51 2[25 30 45[{}39 91.249977 /NewCenturySchlbk-Italic rf /Fj
59[55 55 69[55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55
55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 1[55 55 55 1[55
4[55 55 55 55 55 55 2[55 55 55 55 55 55 55 1[55 55 55 55 55
55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55
55 55 55 55 55 55 55 55 55 55 55 33[{}86 91.249977 /Courier
rf /Fk 81[98 53[88 128 88 98 61 72 74 1[96 88 98 138 50 1[50
53 98 88 56 82 96 80 93 88 12[104 96 117 2[120 1[141 3[64 2[104
109 120 112 12[82 82 82 82 82 66 49[{}39 144.000000 /NewCenturySchlbk-Bold
rf /Fl 3 42 df<000000003FFC0000000000000007FFFFE00000000000003FFFFFFC00000000
0000FFFFFFFF000000000003FFE007FFC0000000000FFC00003FF0000000001FE0000007F80000
00003F80000001FC00000000FE000000007F00000001F8000000001F80000003F0000000000FC0
000007E00000000007E000000F800000000001F000001F000000000000F800003E000000000000
7C00007C0000000000003E0000F80000000000001F0000F00000000000000F0001F00000000000
000F8003E000000000000007C003C000000000000003C007C000000000000003E0078000000000
000001E00F8000000000000001F00F0000000000000000F01F0000000000000000F81E00000000
00000000783E00000000000000007C3C00000000000000003C3C00000000000000003C7C000000
00000000003E7800000000000000001E7800000000000000001E7800000000000000001E780000
0000000000001EF800000000000000001FF000000000000000000FF000000000000000000FF000
000000000000000FF000000000000000000FF000000000000000000FF000000000000000000FF0
00000000000000000FF000000000000000000FF000000000000000000FF000000000000000000F
F000000000000000000FF800000000000000001F7800000000000000001E780000000000000000
1E7800000000000000001E7800000000000000001E7C00000000000000003E3C00000000000000
003C3C00000000000000003C3E00000000000000007C1E0000000000000000781F000000000000
0000F80F0000000000000000F00F8000000000000001F0078000000000000001E007C000000000
000003E003C000000000000003C003E000000000000007C001F00000000000000F8000F0000000
0000000F0000F80000000000001F00007C0000000000003E00003E0000000000007C00001F0000
00000000F800000F800000000001F0000007E00000000007E0000003F0000000000FC0000001F8
000000001F80000000FE000000007F000000003F80000001FC000000001FE0000007F800000000
0FFC00003FF00000000003FFE007FFC00000000000FFFFFFFF0000000000003FFFFFFC00000000
000007FFFFE0000000000000003FFC0000000050537BBF5B>13 D<0007F80000003FFF000000FF
FFC00001FFFFE00003FFFFF00007FFFFF8000FFFFFFC001FFFFFFE003FFFFFFF003FFFFFFF007F
FFFFFF807FFFFFFF807FFFFFFF80FFFFFFFFC0FFFFFFFFC0FFFFFFFFC0FFFFFFFFC0FFFFFFFFC0
FFFFFFFFC0FFFFFFFFC0FFFFFFFFC07FFFFFFF807FFFFFFF807FFFFFFF803FFFFFFF003FFFFFFF
001FFFFFFE000FFFFFFC0007FFFFF80003FFFFF00001FFFFE00000FFFFC000003FFF00000007F8
000022227BA72D>15 D<000000000001E0000000000000000001F0000000000000000000F00000
00000000000000F8000000000000000000780000000000000000007C0000000000000000003E00
00000000000000003E0000000000000000001F0000000000000000000F80000000000000000007
C0000000000000000007E0000000000000000003E0000000000000000001F000007FFFFFFFFFFF
FFFC0000FFFFFFFFFFFFFFFE0000FFFFFFFFFFFFFFFF00007FFFFFFFFFFFFFFF80000000000000
000007E0000000000000000003F0000000000000000001FC0000000000000000007F0000000000
000000001FC000000000000000000FF8000000000000000003FF000000000000000003FF000000
00000000000FF800000000000000001FC000000000000000007F000000000000000001FC000000
000000000003F0000000000000000007E0007FFFFFFFFFFFFFFF8000FFFFFFFFFFFFFFFF0000FF
FFFFFFFFFFFFFE00007FFFFFFFFFFFFFFC000000000000000001F0000000000000000003E00000
00000000000007E0000000000000000007C000000000000000000F8000000000000000001F0000
000000000000003E0000000000000000003E0000000000000000007C0000000000000000007800
0000000000000000F8000000000000000000F0000000000000000001F0000000000000000001E0
00000050327BAF5B>41 D E /Fm 81[82 52[73 73 106 73 82 51 60
62 77 80 73 82 115 42 80 42 44 82 73 47 69 80 66 77 73 9[117
91 100 86 80 97 1[91 100 100 117 86 2[53 104 100 86 91 100
93 93 91 7[69 69 69 69 69 69 69 69 55 69 1[33 40 45[{}58 119.999947
/NewCenturySchlbk-Bold rf /Fn 47[91 21[35 10[56 56 3[35 47[44
49 49 71 49 56 35 42 40 51 52 45 56 81 29 54 27 29 56 49 30
45 52 40 51 51 19 45 1[30 1[30 1[64 1[89 66 74 61 57 66 1[61
71 74 86 61 1[51 37 76 71 61 66 71 66 66 66 5[25 25 51 51 51
51 51 51 51 51 51 51 25 25 30 25 2[30 30 19 39[{}76 91.249977
/NewCenturySchlbk-Roman rf /Fo 138[118 1[86 89 2[105 118 166
61 4[105 67 99 115 96 1[105 14[140 1[131 12[134 27[41 39[{}17
172.833252 /NewCenturySchlbk-Bold rf end
%%EndProlog
%%BeginSetup
%%Feature: *Resolution 600dpi
TeXDict begin

%%EndSetup
%%Page: 1 1
1 0 bop 0 1120 a Fo(Coldmud)49 b(Programmer)9 b(')-6 b(s)51
b(Reference)p 0 1222 3900 34 v 2814 1323 a Fn(For)26 b(Coldmud)e(version)i
(0.10)3464 1431 y(Revision)e(1)0 5066 y Fm(Greg)34 b(Hudson)p
0 5141 3900 17 v eop
%%Page: 2 2
2 1 bop 0 4940 a Fn(Copyright)471 4937 y(c)446 4940 y Fl(\015)25
b Fn(1993)f(Greg)h(Hudson.)0 5214 y(Permission)31 b(is)f(granted)i(with)e(no)
h(restrictions)i(to)e(produce)i(and)d(distribute)h(this)g(\256le)g(in)f
(verbatim)g(or)0 5339 y(modi\256ed)c(form.)p eop
%%Page: 1 3
1 2 bop 0 -116 a Fn(Chapter)25 b(1:)36 b(Overview)2968 b(1)0
366 y Fk(1)72 b(Overview)125 740 y Fn(Coldmud)26 b(is)g(an)g(object-oriented)
k(multi-user)c(network)i(database)e(server)i(with)f(a)f Fj(C)p
Fn(-like)g(program-)0 865 y(ming)e(language)f(for)k(de\256ning)d(object)i
(behavior)-7 b(.)125 1139 y(The)38 b(components)j(of)f(Coldmud')m(s)d
(database)i(are)g Fi(objects)p Fn(,)44 b(which)38 b(together)j(comprise)f
(the)g Fi(object)0 1263 y(hierarchy)p Fn(.)64 b(Objects)35
b(have)f Fi(variables)p Fn(,)k(which)c(determine)h(their)g(state,)j
Fi(methods)p Fn(,)f(which)c(determine)0 1388 y(their)j(behavior)f(in)g
(response)i(to)f Fi(messages)i Fn(from)e(other)h(objects,)i(and)c
Fi(parameters)p Fn(,)41 b(which)34 b(give)i(the)0 1512 y(names)25
b(of)h(the)f(variables)f(used)i(by)e(the)i(object')m(s)g(methods.)125
1786 y(Coldmud)h(objects)i(also)e(have)g Fi(parents)p Fn(,)j(which)d(are)h
(other)h(objects.)44 b(An)27 b(object')m(s)h(behavior)f(is)h(deter)n(-)0
1911 y(mined)j(by)f(its)h Fi(inherited)g Fn(methods,)i(which)d(it)h(gets)h
(from)g(its)f(parents,)i(and)d(its)h Fi(overridden)h Fn(methods,)0
2035 y(which)f(it)i(de\256nes)g(itself.)57 b(One)32 b(object,)k(the)d
Fi(root)h(object)p Fn(,)h(has)c(no)i(parents;)k(all)31 b(other)j(objects)f
(have)f(at)0 2160 y(least)25 b(one)h(parent.)125 2434 y(Methods)d(determine)i
(objects')e(responses)i(to)f(messages)f(using)f(a)h Fj(C)p
Fn(-like)f(language)f(called)i Fj(C--)p Fn(.)33 b(The)0 2558
y(philosophy)25 b(of)h Fj(C--)e Fn(stresses)j(simplicity)-10
b(,)25 b(readability)-10 b(,)24 b(and)g(vertical)i(code)h(organization.)125
2832 y(Encapsulation)15 b(is)h(an)h(important)g(feature)h(of)g(Coldmud')m(s)d
(object)j(system.)34 b(An)16 b(object)i(cannot)f(directly)0
2957 y(access)22 b(another)f(object')m(s)h(data;)g(it)f(must)g(send)g(a)g
(message)g(to)h(perform)h(the)f(required)f(action.)34 b(Moreover)-7
b(,)0 3081 y(an)24 b(object)j(cannot)e(directly)h(access)g(the)g(data)f(used)
g(by)g(its)g(parents')h(or)g(its)f(children')m(s)f(methods.)125
3355 y(Coldmud)34 b(uses)i(a)f(disk-based)g(database;)40 b(only)34
b(a)h(limited)g(number)g(of)h(objects)g(exist)g(in)e(memory)0
3480 y(at)c(any)f(time.)51 b(As)30 b(long)g(as)g(the)g(bulk)f(of)i(the)g
(object)g(database)f(is)g(not)g(concentrated)j(in)c(a)h(few)h(objects,)0
3604 y(Coldmud')m(s)25 b(process)i(size)f(should)g(not)g(grow)g(beyond)g(a)f
(certain)i(point)f(even)g(if)g(the)g(database)f(gets)i(very)0
3729 y(large.)125 4003 y(This)h(manual)f(is)j(intended)g(as)f(a)h(reference)i
(for)f(programmers)g(and)e(administrators.)49 b(It)30 b(does)h(not)0
4127 y(document)26 b(any)f(object)h(database,)g(and)e(may)h(not)h(be)g
(appropriate)g(as)g(a)f(tutorial.)36 b(The)25 b(best)h(way)f(to)h(get)0
4252 y(started)k(learning)c Fj(C--)h Fn(is)h(to)h(look)g(at)f(existing)f
(code,)k(such)d(as)g(code)h(in)f(a)f(core)j(database,)f(and)e(refer)j(to)0
4376 y(this)25 b(manual)e(when)h(you)h(don')n(t)h(understand)f(how)g(a)g
(piece)h(of)g(code)h(works.)p eop
%%Page: 2 4
2 3 bop 0 -116 a Fn(2)2408 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)p eop
%%Page: 3 5
3 4 bop 0 -116 a Fn(Chapter)25 b(2:)36 b(Objects)3056 b(3)0
366 y Fk(2)72 b(Objects)125 773 y Fn(Objects)28 b(in)g(Coldmud)g(have)g(four)
h(characteristics:)43 b(a)28 b Fi(database)h(reference)h Fn(\(called)f(a)f
Fi(dbref)12 b Fn(\))29 b(which)0 898 y(identi\256es)e(the)g(object,)h(a)f
(list)f(of)h Fi(parent)h Fn(dbrefs)f(which)f(determine)i(what)e(default)h
(behavior)f(the)h(object)0 1022 y(inherits,)42 b Fi(variables)f
Fn(which)d(store)j(information,)i(and)38 b Fi(methods)h Fn(which)f(determine)
j(how)d(the)i(object)0 1147 y(responds)29 b(to)f(messages.)43
b(Objects)28 b(refer)i(to)e(each)g(other)h(using)d(dbrefs,)j(and)e(interact)h
(with)f(each)h(other)0 1271 y(by)40 b(sending)g(messages.)82
b(The)40 b(objects)i(which)e(a)g(Coldmud)g(server)i(has)e(to)i(work)f(with)f
(are)h(known)0 1396 y(collectively)26 b(as)f(the)g Fi(object)h(database)p
Fn(.)125 1676 y(Coldmud)36 b(gives)h(special)f(status)h(to)h(two)g(objects,)j
(the)c Fi(system)h(object)g Fn(and)e(the)h Fi(root)h(object)p
Fn(.)71 b(The)0 1801 y(system)17 b(object)h(is)f(allowed)f(to)i(call)e
(administrative)g(functions)h(and)f(receives)i Fj(startup)c
Fn(and)i Fj(heartbeat)0 1925 y Fn(messages)30 b(from)g(the)g(server)-7
b(.)49 b(The)29 b(root)i(object)g(is)e(the)h(only)f(object)h(without)f
(parents,)i(and)e(is)g(thus)g(an)0 2050 y(ancestor)d(of)g(every)h(object.)0
2558 y Fm(2.1)60 b(Database)30 b(References)125 2838 y Fn(Database)g
(references)k(are)d(numbers)g(which)f(refer)j(to)f(objects.)55
b(When)31 b(an)f(object)i(is)f(created,)k(it)c(is)0 2963 y(assigned)23
b(a)g(unique)f(database)h(reference.)38 b(Database)23 b(references)j(cannot)e
(be)f(changed)g(after)i(an)e(object)0 3087 y(is)i(created.)125
3368 y(In)k Fj(C--)p Fn(,)i(you)f(indicate)g(a)g(database)g(reference)j(by)c
(preceding)j(a)d(number)h(with)g(a)g(hash)f(mark)h(\(`)p Fj(#)p
Fn('\).)0 3492 y(For)c(instance,)f Fj(#126)e Fn(refers)28 b(to)e(the)f
(object)i(with)d(the)i(dbref)g(126.)125 3773 y(In)k(general,)i(programmers)g
(should)e(not)h(have)f(to)h(be)g(concerned)h(with)e(database)g(references.)55
b(See)0 3898 y(Section)26 b(3.6.2)f([Names],)h(page)f(20)g(for)h(information)
f(on)g(naming)e(objects.)0 4405 y Fm(2.2)59 b(Inheritance)125
4686 y Fn(In)29 b(addition)h(to)i(the)e(methods)i(an)d(object)j(de\256nes)e
(for)i(itself,)g(objects)g(inherit)e(methods)h(from)h(their)0
4810 y Fi(parents)p Fn(.)k(An)24 b(object)i(can)e(override)i(a)f(parent')m(s)
f(method)h(by)f(de\256ning)g(its)g(own)h(methods)g(with)f(the)h(same)0
4935 y(name.)125 5215 y(The)i(root)j(object)f(has)e(no)h(parents.)44
b(All)27 b(other)i(objects)g(have)e(at)h(least)g(one)h(parent,)g(and)e
(eventually)0 5340 y(inherit)e(from)h(the)g(root)h(object.)36
b(The)25 b(root)i(object)f(has)f(the)h(dbref)g Fj(1)p Fn(.)p
eop
%%Page: 4 6
4 5 bop 0 -116 a Fn(4)2408 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(It)31 b(is)g(easy)f(to)i(determine)h(how)d(an)g(object)
i(with)f(one)g(parent)g(will)f(react)i(to)g(a)e(message;)35
b(either)d(the)0 491 y(object)21 b(de\256nes)e(its)h(own)f(method)h(for)h
(that)e(message,)i(or)g(it)e(uses)h(the)f(inherited)h(method)g(from)h(its)e
(parent.)125 771 y(Objects)24 b(with)f(more)j(than)d(one)h(parent)h(are)f
(more)h(complicated.)37 b(Ancestors)25 b(of)g(such)e(an)h(object)h(take)0
896 y(precedence)j(over)e(each)g(other)g(according)g(to)g(the)f(following)g
(rules:)44 1176 y(1.)60 b(Any)24 b(ancestor)j(object)f(has)f(higher)f
(precedence)k(than)d(its)g(own)g(ancestors.)44 1332 y(2.)60
b(The)24 b(\256rst)h(parent)g(of)g(an)f(object)h(and)f(the)h(\256rst)g
(parent')m(s)f(ancestors)i(have)e(higher)g(precedence)j(than)180
1456 y(the)c(second)g(parent)g(and)f(the)h(second)h(parent')m(s)e(ancestors,)
i(and)e(so)h(on,)h(except)g(when)e(this)g(con\257icts)180 1581
y(with)j(the)g(\256rst)h(rule.)125 1892 y(Normally)-10 b(,)39
b(an)e(object')m(s)g(response)i(to)f(a)f(message)h(is)f(determined)h(by)f
(checking)g(its)g(own)g(method)0 2017 y(de\256nitions,)e(and)e(then)g(those)h
(of)g(its)g(ancestors)g(in)f(order)i(of)f(decreasing)g(precedence)3285
1984 y Fh(1)3325 2017 y Fn(.)60 b(However)-7 b(,)37 b(it)0
2141 y(is)d(possible)h(for)h(a)e(method)h(to)h(disallow)d(overrides.)65
b(If)35 b(one)g(or)h(more)f(ancestors)h(of)f(an)f(object)i(de\256ne)0
2266 y(non-overridable)21 b(methods,)i(then)e(Coldmud)f(will)f(select)k(the)e
(non-overridable)g(method)h(de\256ned)f(on)g(the)0 2390 y(ancestor)26
b(with)f(the)h(least)f(precedence.)0 2895 y Fm(2.3)59 b(Messages)30
b(and)f(Methods)125 3175 y Fn(Objects)g(interact)g(with)f(each)h(other)h(by)e
(sending)g Fi(messages)p Fn(.)48 b(Messages)29 b(have)f(two)h(components,)i
(a)0 3300 y(name)17 b(and)g(a)g(list)g(of)i(arguments.)32 b(T)-8
b(o)18 b(see)g(how)g(to)g(send)g(a)f(message)h(in)f(a)g Fj(C--)g
Fn(method,)j(see)f(Section)f(3.6.10)0 3424 y([Sending)25 b(Messages],)h(page)
f(29.)125 3704 y(Coldmud)35 b(processes)k(a)d(message)g(by)f(looking)h(on)g
(the)h(recipient)g(object)g(and)f(its)g(ancestors)h(for)g(a)0
3829 y(method)24 b(with)e(the)h(same)g(name)f(as)g(the)h(message,)h
(following)e(the)h(rules)g(given)f(in)g(the)h(previous)h(section.)0
3953 y(The)f(recipient')m(s)g(method)h(processes)i(the)d(message)g(according)
h(to)g(its)f Fj(C--)f Fn(instructions,)h(and)g(returns)g(a)0
4078 y(value)h(to)i(the)g(calling)d(object.)125 4358 y(While)32
b(a)h(message)h(is)f(being)f(processed,)39 b(the)33 b(object)i(which)d
(received)j(the)f(message)f(is)g(called)h(the)0 4483 y Fi(current)29
b(object)p Fn(.)44 b(Only)26 b(the)j(current)g(object')m(s)f(variables)e(can)
i(be)g(accessed)h(or)g(changed)f(by)f(the)h(method)0 4607 y(which)h
(processes)j(the)e(message;)j(to)d(examine)f(or)i(modify)f(another)g(object,)
i(the)e(method)h(must)e(send)h(a)0 4732 y(message)c(to)g(that)f(object.)p
0 4853 1200 4 v 42 4930 a Fh(1)125 4963 y Fn(Because)k(of)h(Coldmud')m(s)e
(precedence)k(rules,)f(its)e(multiple-inheritance)g(scheme)h(can)e(be)i
(described)125 5088 y(loosely)i(as)f(\252left-to-right,)k(up-to-join\272.)56
b(That)31 b(is,)i(Coldmud)e(performs)i(a)f(depth-\256rst)h(traversal)e(of)125
5212 y(the)26 b(ancestors)h(digraph,)f(ordering)h(the)g(parents)f(from)h
(left)g(to)g(right,)f(stopping)h(at)f(an)f(ancestor)i(if)f(it)125
5337 y(will)d(reach)j(the)g(ancestor)g(again)d(later)j(in)f(the)g(traversal.)
p eop
%%Page: 5 7
5 6 bop 0 -116 a Fn(Chapter)25 b(2:)36 b(Objects)3056 b(5)125
366 y(If)23 b(a)g(method)g(de\256nition)g(overrides)i(a)d(de\256nition)h(on)g
(an)f(ancestor)i(of)g(the)g(current)g(object)g(with)e(lower)0
491 y(precedence,)36 b(the)c(overriding)f(method)h(can)f Fi(pass)i
Fn(the)e(message)h(to)g(the)g(ancestor;)k(see)c(Section)g(3.6.11)0
616 y([Passing)24 b(Messages],)i(page)f(30)g(for)h(details.)125
916 y(Methods)18 b(can)f(use)g(the)h(functions)f Fj(this\(\))e
Fn(and)i Fj(sender\(\))d Fn(to)k(determine)h(the)f(dbrefs)g(of)g(the)g
(current)0 1040 y(object)26 b(and)e(the)h(object)g(which)f(sent)h(the)g
(message)g(to)g(the)g(current)h(object.)36 b(The)25 b(functions)f
Fj(definer\(\))0 1165 y Fn(and)h Fj(caller\(\))e Fn(allow)i(methods)i(to)g
(determine)g(the)f(dbrefs)h(of)g(the)f(objects)i(which)c(de\256ne)j(the)f
(current)0 1289 y(method)g(and)f(the)g(calling)f(method.)125
1589 y(Messages)39 b(to)h(an)e(object)j(are)e(not)h(always)d(sent)j(by)f
(another)g(object;)48 b(they)39 b(can)g(also)g(come)h(from)0
1714 y(the)31 b(server)-7 b(.)54 b(Coldmud)31 b(sends)g Fj(parse)p
Fn(,)f Fj(connect)p Fn(,)f(and)i Fj(disconnect)26 b Fn(messages)31
b(to)h(handler)e(objects)0 1838 y(of)k(connections,)i Fj(startup)30
b Fn(and)i Fj(heartbeat)d Fn(messages)34 b(to)g(the)f(system)h(object,)i(and)
d Fj(connect)d Fn(and)0 1963 y Fj(failed)36 b Fn(messages)j(to)g(receiver)h
(objects)g(of)f(pending)f(connections)i(generated)f(by)f(the)h
Fj(connect\(\))0 2087 y Fn(function.)h(When)27 b(Coldmud)f(sends)h(a)f
(message)i(to)f(an)f(object,)j Fj(sender\(\))23 b Fn(and)j
Fj(caller\(\))d Fn(return)28 b(the)0 2212 y(integer)e Fj(0)p
Fn(.)0 2895 y Fm(2.4)59 b(V)-11 b(ariables)31 b(and)f(Parameters)125
3195 y Fn(An)j(object')m(s)i Fi(parameters)h Fn(gives)e(the)h(names)f(of)g
(the)h(variables)e(its)h(methods)i(have)d(access)i(to.)64 b(An)0
3319 y(object')m(s)26 b Fi(variables)h Fn(correspond)g(to)f(parameters)h(on)e
(that)g(object)i(or)f(one)f(of)h(its)g(ancestors.)125 3619
y(The)h(function)h Fj(add_parameter\(\))21 b Fn(adds)29 b(a)e(parameter)i(to)
g(an)f(object.)45 b(Once)28 b(you)g(have)g(created)h(a)0 3744
y(parameter)k(on)f(an)f(object,)k(the)e(methods)g(on)f(that)g(object)h(can)e
(use)h(it)g(to)h(refer)h(to)f(a)f(variable)e(on)i(that)0 3868
y(object)20 b(or)f(any)f(of)h(its)g(descendents,)i(using)d(the)h
Fj(C--)e Fn(constructs)j(described)g(in)e(Section)h(3.6.7)f([V)-8
b(ariables],)0 3993 y(page)25 b(24.)125 4293 y(T)-6 b(wo)21
b(objects)i(can)e(have)g(parameters)i(of)f(the)g(same)g(name;)h(a)e(third)h
(object)h(which)d(inherits)h(from)i(both)0 4417 y(of)k(them)f(will)e(contain)
i(two)g(separate)h(variables)e(for)i(those)g(parameters.)39
b(Methods)26 b(on)g(the)h(\256rst)f(object)0 4542 y(will)g(refer)j(to)f(one)g
(variable,)e(and)h(methods)h(on)f(the)h(second)g(object)g(will)e(refer)k(to)e
(the)f(other)-7 b(.)43 b(Likewise,)0 4666 y(variables)31 b(on)i(separate)g
(objects)h(are)f(distinct,)i(even)e(though)f(the)g(methods)i(which)d(can)h
(access)i(them)0 4791 y(and)25 b(the)g(parameter)i(used)e(by)g(the)g(method)h
(are)g(the)g(same.)125 5091 y(Note)34 b(that)e(this)h(system)g(does)h(not)f
(permit)g(children)g(to)g(access)h(the)f(variables)e(used)i(by)g(their)g(an-)
0 5215 y(cestors)i(directly)-10 b(.)60 b(Objects)34 b(can)e(build)g(on)h(the)
g(abstractions)g(of)h(their)g(parent)f(objects,)k(but)32 b(not)i(their)0
5340 y(internal)24 b(representations.)p eop
%%Page: 6 8
6 7 bop 0 -116 a Fn(6)2408 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(2.5)59 b(The)30 b(System)g(Object)125
640 y Fn(The)36 b(system)h(object)h(is)e(a)g(special)h(object)h(for)g
(communicating)d(with)h(the)h(Coldmud)f(server)-7 b(.)71 b(The)0
765 y(system)26 b(object)g(has)f(the)g(dbref)h Fj(0)p Fn(.)125
1039 y(At)42 b(startup)h(time,)48 b(the)43 b(server)h(sends)f(a)f
Fj(startup)e Fn(message)j(to)g(the)g(system)g(object,)49 b(with)42
b(one)0 1163 y(argument,)23 b(a)g(list)g(of)g(strings)g(giving)f(the)h
(arguments)g(passed)g(on)g(the)h(command)e(line)h(when)f(the)h(server)0
1288 y(was)i(invoked.)125 1562 y(If)i(you)f(use)h(the)g Fj(set_heartbeat_fr)o
(eq)o(\(\))20 b Fn(function)27 b(to)h(enable)e(the)h(heartbeat,)g(then)g(the)
g(server)0 1687 y(will)d(send)h(a)g Fj(heartbeat)c Fn(message)26
b(to)g(the)g(system)g(object)g(periodically)-10 b(.)125 1961
y(Methods)21 b(on)g(the)g(system)g(object)h(can)e(call)g(administrative)g
(functions)g(such)h(as)f Fj(shutdown\(\))c Fn(which)0 2085
y(ordinary)32 b(objects)i(are)f(not)g(permitted)h(to)g(call.)56
b(In)33 b(most)g(databases,)h(the)f(system)g(object)h(will)d(de\256ne)0
2210 y(methods)26 b(which)e(allow)h(certain)g(authorized)g(objects)i(to)f
(access)g(these)g(functions.)p eop
%%Page: 7 9
7 8 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2626
b(7)0 366 y Fk(3)72 b(De\256ning)31 b(methods)125 770 y Fn(A)g(method)i(in)e
(Coldmud)h(is)g(an)f(object')m(s)h(de\256nition)g(of)g(how)g(to)h(handle)e(a)
g(message.)57 b(Methods)33 b(are)0 895 y(written)22 b(in)f(a)g(language)f
(called)h Fj(C--)p Fn(,)h(which)e(resembles)j Fj(C)e Fn(at)h(\256rst)g
(glance.)34 b(However)-7 b(,)24 b Fj(C--)c Fn(is)i(a)f(simpler)0
1019 y(language,)i(and)i(it)g(stresses)j(readability)c(instead)h(of)h
(conciseness.)125 1299 y(The)h(building)e(blocks)j(of)h(methods)g(are)f
(character)h(sequences)f(called)g Fi(tokens)p Fn(.)43 b(From)28
b(these)h(tokens)0 1424 y(you)c(can)f(assemble)h(a)g(sequence)g(of)h
(instructions)f(to)h(the)f(interpreter)j(called)d Fi(statements)p
Fn(.)37 b(Y)-10 b(ou)25 b(express)0 1548 y(values)f(in)h(statements)h(using)e
Fi(expressions)p Fn(.)125 1828 y(Methods)38 b(can)f(return)h(values)f(using)f
(a)i Fj(return)c Fn(statement.)74 b(If)38 b(a)f(method)i(does)f(not)g
(explicitly)0 1953 y(return)26 b(a)f(value,)f(its)i(return)g(value)e(is)h
(the)g(dbref)i(of)f(the)f(current)h(object.)125 2233 y(Methods)19
b(have)e(a)h(limited)g(amount)g(of)h(running)d(time;)21 b(if)e(a)e(method)j
(executes)f(too)h(many)d(instructions)0 2357 y(before)38 b(returning,)h(it)d
(will)f(abort)h(with)g(a)g Fj(\304ticks)d Fn(error)-7 b(,)42
b(which)35 b(it)h(cannot)g(catch.)69 b(See)37 b(Chapter)f(4)0
2482 y([Errors],)27 b(page)f(33)0 2984 y Fm(3.1)60 b(Example)30
b(Method)125 3264 y Fn(Here)23 b(is)g(an)f(example)h(of)g(a)g(simple)f
Fj(C--)g Fn(method.)35 b(This)22 b(method)i(might)e(be)h(used)g(in)f(a)g(mud)
h(server)h(to)0 3389 y(handle)c(a)h Fj(tell_contents)15 b Fn(message)22
b(sent)f(to)h(a)f(container)g(object.)36 b(Here)22 b(is)f(the)g(code)i(for)f
(the)g(method:)240 3669 y Fj(arg)53 b(str;)240 3794 y(var)g(obj;)240
4043 y(for)g(obj)g(in)h(\(contents\))c({)458 4167 y(//)k(Tell)f(the)g(string)
f(to)h(the)g(object.)458 4292 y(\(|)h(obj.tell\(str\))48 b(|\);)240
4416 y(})125 4842 y Fn(This)32 b(method)h(takes)h(one)g(argument,)g
Fj(str)p Fn(,)g(a)f(string)g(to)h(send)f(to)h(each)f(object)h(in)f(the)g
(room.)60 b(The)0 4966 y(method)29 b(uses)f(a)f(local)h(variable)e
Fj(obj)g Fn(to)j(traverse)g(the)g(list)e(stored)j(in)d(the)h(object)h
(variable)d Fj(contents)p Fn(.)0 5091 y(The)21 b(body)g(of)g(the)h(method)f
(is)g(a)g(for)h(loop,)h(which)c(traverses)k(the)e(contents)h(list.)34
b(For)22 b(each)f(element)g(in)g(the)0 5215 y(for)28 b(list,)e(this)h(method)
g(sends)g(a)f Fj(tell)f Fn(message)h(with)g(the)h(string.)39
b(The)26 b(parenthesis)h(and)f(vertical)h(bar)0 5340 y(delimiters)e(\(`)p
Fj(\(|)p Fn(')e(and)h(`)p Fj(|\))p Fn('\))f(surrounding)g(the)i(message)g
(expression)h(mark)e(it)g(as)g(a)g Fi(critical)j(expression)p
Fn(.)p eop
%%Page: 8 10
8 9 bop 0 -116 a Fn(8)2408 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y(Errors)33 b(which)d(occur)i(inside)f(a)g(critical)g
(expression)h(are)g(ignored;)j(thus,)d(errors)i(which)c(occur)i(during)0
491 y(the)26 b(processing)g(of)g(the)g Fj(tell)d Fn(messages)j(won')n(t)f
(cause)g(the)h Fj(tell_contents)19 b Fn(method)26 b(to)g(abort.)0
956 y Fm(3.2)59 b(T)-11 b(okens)125 1231 y Fn(The)21 b(building)e(blocks)j
(of)g Fj(C--)f Fn(methods)i(are)f(character)g(sequences)h(called)e
Fi(tokens)p Fn(.)35 b(There)22 b(are)g(many)0 1356 y(different)36
b(types)g(of)f(tokens,)j(ranging)32 b(from)k(single)e(characters)h(to)g
(lines)f(of)i(text.)64 b Fj(C--)33 b Fn(methods)j(are)0 1480
y(assembled)25 b(from)h(sequences)g(of)g(tokens.)125 1756 y(The)e(following)h
(characters)h(and)f(pairs)g(of)h(characters)g(are)g(tokens:)240
2007 y Fj({)54 b(})g([)g(])g(#[)g(\045[)g(\()g(\))g(\(|)f(|\))h(\(>)g(<\))f
(..)h(;)g(,)g(=)g(!)240 2107 y(-)g(+)g(*)g(/)g(\045)g(==)g(!=)g(>)g(>=)f(<)i
(<=)e(.)h(||)g(&&)g(?)g(|)g(:)g(@)0 2382 y Fn(These)25 b(tokens)i(are)e(used)
h(as)f(operators)i(and)e(as)g(punctuation)f(in)g(various)h(types)h(of)g
(expressions.)125 2658 y(Y)-10 b(ou)35 b(can)g(use)h Fi(identi\256ers)h
Fn(as)e(tokens)i(and)e(as)g(parts)i(of)f(tokens.)68 b(An)35
b(identi\256er)h(is)g(a)f(sequence)h(of)0 2783 y(alphabetical)25
b(and)i(numeric)g(characters)h(or)g(underlines)e(beginning)f(with)i(an)f
(alphabetical)f(character)0 2907 y(or)k(an)e(underline.)43
b(Identi\256ers)29 b(in)e Fj(C--)f Fn(are)j(case-sensitive,)h(so)e(the)g
(identi\256ers)h Fj(car)d Fn(and)i Fj(CAr)e Fn(are)j(not)0
3032 y(equivalent.)34 b(The)25 b(following)g(are)g(valid)f(identi\256ers:)240
3300 y Fj(we_3_kings)240 3425 y(obj)240 3549 y(a)0 3815 y Fn(By)41
b(themselves,)46 b(identi\256ers)c(usually)d(represent)k(variables.)83
b(However)-7 b(,)46 b(certain)c(identi\256ers)g(have)0 3940
y(special)35 b(meanings)f(to)i(the)f(parser)-7 b(.)67 b(These)36
b Fi(reserved)h(words)e Fn(are)h(used)f(in)g(writing)f(certain)i(kinds)e(of)0
4064 y(statements)26 b(and)f(expressions.)37 b(They)24 b(are:)240
4315 y Fj(var)53 b(if)h(else)f(while)f(for)h(switch)f(case)h(default)e(break)
h(continue)f(return)240 4415 y(catch)h(any)h(with)g(handler)f(pass)g(to)i(in)
g(fork)e(atomic)g(non_atomic)125 4691 y Fn(\()p Fj(fork)p Fn(,)22
b Fj(atomic)p Fn(,)f(and)i Fj(non_atomic)18 b Fn(are)24 b(not)f(actually)f
(used)h(by)g(the)h(current)g(version)f(of)h(Coldmud,)0 4815
y(but)h(are)g(reserved)j(for)e(future)g(use.\))125 5091 y(There)35
b(are)g(several)g(kinds)f(of)h(tokens)h(for)f(denoting)g(literal)f
(expressions)i(of)f(various)g(data)f(types.)0 5215 y(These)18
b(are)g Fi(integers)p Fn(,)i(denoted)g(by)d(a)g(sequence)h(of)h(digits;)h
Fi(strings)p Fn(,)g(denoted)f(by)e(a)g(sequence)i(of)f(characters)0
5340 y(enclosed)34 b(in)e(double)h(quotes;)38 b Fi(dbrefs)p
Fn(,)d(denoted)g(by)d(a)h(sharp)g(\(`)p Fj(#)p Fn('\))f(and)g(a)h(number;)j
Fi(symbols)p Fn(,)g(denoted)p eop
%%Page: 9 11
9 10 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2626
b(9)0 366 y(by)28 b(a)g(single)g(forward)h(quote)g(\(`)p Fj(')p
Fn('\))f(and)g(an)g(identi\256er)g(or)i(string;)g(and)e Fi(error)j(codes)p
Fn(,)f(denoted)h(by)d(a)g(tilde)0 491 y(\(`)p Fj(\304)p Fn('\))e(and)g(an)g
(identi\256er)h(or)h(string.)40 b(These)27 b(literals)g(are)g(described)h
(more)g(fully)e(in)g(Section)i(3.6.1)e([Data)0 616 y(T)-5 b(ypes],)26
b(page)g(18,)e(along)g(with)h(the)h(data)f(types)h(they)f(represent.)125
890 y(A)d Fi(name)h(token)f Fn(is)h(a)f(dollar)h(sign)f(\(`)p
Fj($)p Fn('\))g(followed)h(by)g(an)e(identi\256er)i(or)h(string.)35
b(Names)22 b(refer)j(to)f(objects)0 1015 y(indirectly;)i(see)g(Section)g
(3.6.2)f([Names],)h(page)f(20.)125 1289 y(T)-8 b(okens)22 b(which)g(contain)g
(identi\256ers)h(but)f(begin)g(with)g(a)g(distinguishing)e(character)k
(\(that)e(is,)i(symbol)0 1414 y(tokens,)37 b(error)e(code)g(tokens,)i(and)c
(name)g(tokens\))h(relax)g(the)g(restriction)h(that)e(identi\256ers)h(not)g
(begin)0 1538 y(with)25 b(an)f(integer)-7 b(.)36 b(Thus,)25
b Fj($23a)e Fn(is)i(a)g(valid)f(name)h(token,)h(even)g(though)e
Fj(23a)g Fn(is)h(not)h(an)e(identi\256er)-7 b(.)125 1813 y(Finally)d(,)20
b(a)h Fi(comment)h(token)g Fn(is)f(any)g(text)i(on)e(a)h(line)f(after)i(a)e
(pair)g(of)i(slashes)e(\(`)p Fj(//)p Fn('\).)33 b(Comment)22
b(tokens)0 1937 y(can)j(be)g(used)h(as)e(statements)j(in)d(methods;)j(such)e
(statements)h(are)g(ignored)f(by)g(the)h(interpreter)-7 b(.)0
2391 y Fm(3.3)59 b(Method)30 b(Structure)125 2665 y Fn(A)24
b Fj(C--)g Fn(method)i(has)f(the)h(following)e(structure:)240
2933 y Fj(disallow_overri)o(de)o(s;)240 3057 y(arg)53 b Fi(arg1)p
Fj(,)h Fi(arg2)p Fj(,)g Fi(...)p Fj(,)h([)p Fi(rest)p Fj(];)240
3182 y(var)e Fi(var1)p Fj(,)i Fi(var2)p Fj(,)f Fi(...)p Fj(;)240
3431 y Fi(statement1)240 3555 y(statement2)240 3680 y(.)240
3804 y(.)240 3929 y(.)0 4194 y Fn(The)24 b Fj(disallow_overrid)o(es)o(;)19
b Fn(declaration)25 b(indicates)f(a)h(non-overridable)g(method)h(\(see)g
(Section)g(2.2)0 4318 y([Inheritance],)g(page)f(3\).)36 b(Normally)-10
b(,)24 b(you)i(should)e(omit)i(this)f(declaration.)125 4593
y(The)d Fj(arg)f Fn(declaration)h(gives)h(a)f(list)g(of)h(argument)f
(variables,)g(whose)h(values)e(will)g(correspond)k(to)f(the)0
4717 y(arguments)31 b(passed)h(with)e(the)i(message.)54 b(Y)-10
b(ou)31 b(may)f(omit)i(the)g Fj(arg)e Fn(declaration)h(if)g(the)h(method)g
(does)0 4842 y(not)25 b(take)g(any)f(arguments.)35 b(If)25
b(the)g(\256nal)e(argument)h(variable)f(is)i(given)f(in)g(square)g(brackets)h
(\(that)g(is,)g(if)0 4966 y(you)f(specify)g Fi(rest)p Fn(\),)i(then)d(the)h
(method)h(can)e(accept)i(a)e(variable)g(number)f(of)j(argments;)f
Fi(rest)h Fn(will)e(contain)0 5091 y(a)30 b(list)g(of)h(the)g(arguments)f
(beyond)h(the)g(ones)g(corresponding)g(to)h(the)f(argument)e(variables.)50
b(If)31 b(you)f(do)0 5215 y(not)i(specify)g Fi(rest)p Fn(,)i(then)e(the)f
(method)i(can)d(accept)j(only)e(the)h(number)e(of)j(arguments)e(speci\256ed)h
(by)f(the)0 5340 y(argument)25 b(variables,)f(no)h(more.)p
eop
%%Page: 10 12
10 11 bop 0 -116 a Fn(10)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(The)h Fj(var)f Fn(declaration)h(tells)h(the)f(compiler)
i(that)e(the)h(listed)f(identi\256ers)h(should)f(refer)i(to)f(local)f(vari-)0
491 y(ables.)35 b(Y)-10 b(ou)25 b(may)g(omit)g(the)h Fj(var)e
Fn(declaration)h(if)g(you)g(do)h(not)g(wish)e(to)i(declare)g(any)f(local)g
(variables.)125 768 y(The)39 b(statements)i Fi(statement1)p
Fn(,)i Fi(statement2)p Fn(,)h Fi(...)79 b Fn(are)40 b(the)g(body)g(of)g(the)g
(method.)80 b(They)39 b(tell)h(the)0 892 y(interpreter)28 b(what)c(the)i
(method)g(does.)0 1366 y Fm(3.4)59 b(Statements)125 1642 y
Fi(Statements)26 b Fn(are)h(instructions)f(to)h(the)g(interpreter)-7
b(.)41 b(Statements)28 b(can)e(be)g(as)g(simple)g(as)g(comments,)0
1767 y(or)31 b(they)g(can)f(be)g(complex)h(loops)g(and)f(conditionals.)50
b(However)-7 b(,)33 b(most)e(statement)h(types)f(in)f Fj(C--)f
Fn(have)0 1892 y(simple)19 b(structures.)35 b(Because)19 b(statements)h(can)e
(include)g(other)i(statements,)i(you)c(can)h(use)f(these)i(simple)0
2016 y(statement)26 b(types)g(to)h(build)c(complex)j(directives.)125
2293 y(The)20 b(following)h(sections)h(describe)g(simple)f(statements,)j
(which)c(perform)j(simple)e(actions)g(once,)i(con-)0 2417 y(ditional)f
(statements,)j(which)d(perform)j(different)g(actions)e(depending)g(on)h(the)f
(value)f(of)i(an)f(expression,)0 2542 y(looping)k(statements,)i(which)d
(perform)j(an)e(action)g(multiple)f(times,)j(and)d(error)n(-handling)i
(statements,)0 2666 y(which)c(affect)j(how)e(the)g(interpreter)j(handles)c
(error)k(conditions.)0 3107 y Fg(3.4.1)54 b(Simple)31 b(Statements)125
3383 y Fn(The)20 b Fi(comment)h(statement)g Fn(does)h(nothing)e(at)g(all.)33
b(A)20 b(comment)i(statement)f(is)g(just)f(a)h(comment)g(token,)0
3508 y(which)j(is)g(a)h(sequence)g(of)h(two)g(slashes)e(\(`)p
Fj(//)p Fn('\))g(followed)h(by)g(any)f(characters)h(up)g(to)h(the)f(end)g(of)
h(the)f(lines.)0 3632 y(For)h(instance:)240 3884 y Fj(//)54
b(This)e(is)i(a)g(comment.)0 4161 y Fn(The)33 b(interpreter)j(ignores)d
(comment)i(statements)f(completely;)39 b(they)33 b(are)h(for)g(the)g
(bene\256t)f(of)h(human)0 4286 y(readers.)39 b(Note)27 b(that)e(comments)i
(in)e Fj(C--)f Fn(are)i(actual)f(statements,)i(unlike)e(comments)h(in)f
Fj(C)p Fn(,)h(which)f(are)0 4410 y(\256ltered)h(out)g(by)f(the)g
(preprocessor)-7 b(.)125 4687 y(The)21 b Fi(expression)k(statement)e
Fn(evaluates)f(an)f(expression)i(and)f(discards)h(its)f(value.)33
b(The)22 b(syntax)g(of)h(the)0 4811 y(expression)j(statement)h(is:)240
5063 y Fi(expression)p Fj(;)0 5340 y Fn(The)e(following)f(are)i(expression)g
(statements:)p eop
%%Page: 11 13
11 12 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(11)240 366 y Fj(3;)240 466 y(sender\(\).tell\($)o(sy)o(s.)o(wh)o(o\(\))o
(\);)125 821 y Fn(The)20 b Fi(assignment)h(statement)g Fn(evaluates)f(an)g
(expression)i(and)e(assigns)f(the)i(value)f(to)h(a)g(variable.)32
b(The)0 945 y(syntax)24 b(of)i(the)g(assignment)e(statement)j(is:)240
1275 y Fi(variable)56 b Fj(=)e Fi(expression)p Fj(;)0 1629
y Fn(The)28 b(interpreter)k(assigns)c(the)h(value)f(of)h Fi(expression)j
Fn(to)d Fi(variable)p Fn(,)j(which)27 b(is)i(a)f(local)h(variable)e(if)i(it)g
(has)0 1753 y(been)i(declared)h(as)e(one,)j(or)f(an)d(object)j(variable)e(on)
g(the)i(current)f(object)h(if)f(it)g(has)f(not)h(been)g(declared.)0
1878 y(See)26 b(Section)h(3.6.7)d([V)-8 b(ariables],)24 b(page)i(24.)125
2232 y(The)c Fi(compound)g(statement)i Fn(allows)d(you)i(to)g(treat)h(one)f
(or)h(more)g(statements)f(as)g(a)f(single)g(statement.)0 2357
y(The)j(compound)h(statement)g(has)e(the)i(following)f(syntax:)240
2704 y Fj({)458 2829 y Fi(statement1)458 2953 y(statement2)458
3078 y(.)458 3202 y(.)458 3327 y(.)240 3451 y Fj(})0 3796 y
Fn(The)g(interpreter)j(executes)f(each)e(of)h Fi(statement1)p
Fn(,)f Fi(statement2)p Fn(,)h Fi(...)36 b Fn(in)25 b(turn.)125
4150 y(The)30 b Fi(return)h(statement)h Fn(allows)e(a)g(method)i(to)g(stop)g
(exeuting)f(statements)h(and)e(to)i(return)f(a)g(value)0 4275
y(other)f(than)d(the)i(default)g(return)g(value)f(of)h Fj(this\(\))p
Fn(.)43 b(The)29 b(return)g(statement)h(can)e(have)g(either)h(of)h(the)0
4399 y(following)24 b(two)i(forms:)240 4746 y Fj(return)52
b Fi(expression)p Fj(;)240 4871 y(return;)0 5215 y Fn(The)21
b(interpreter)j(stops)f(executing)e(statements)i(in)d(the)i(method)h(and)d
(returns)j(the)e(value)g(of)h Fi(expression)p Fn(,)0 5340 y(or)k(the)g(dbref)
g(of)g(the)f(current)i(object)f(if)f Fi(expression)j Fn(is)d(not)h(given.)p
eop
%%Page: 12 14
12 13 bop 0 -116 a Fn(12)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fg(3.4.2)54 b(Conditional)30 b(Statements)125
717 y Fn(There)25 b(are)h(three)h(types)f(of)h(conditional)e(statements)h(in)
f Fj(C--)p Fn(.)35 b(The)25 b Fi(if)h(statement)g Fn(has)f(the)h(following)0
842 y(syntax:)240 1185 y Fj(if)54 b(\()p Fi(expression)p Fj(\))458
1310 y Fi(statement)0 1651 y Fn(The)21 b(interpreter)k(evaluates)c
Fi(expression)p Fn(.)37 b(If)22 b(the)h(value)d(of)j Fi(expression)h
Fn(is)e(true)h(\(see)g(Section)g(3.6.1)e([Data)0 1775 y(T)-5
b(ypes],)26 b(page)g(18\),)e(then)i(the)f(interpreter)j(executes)f
Fi(statement)p Fn(.)125 2126 y(The)d Fi(if-else)k(statement)e
Fn(is)f(similar)e(to)j(the)g(if)f(statement.)37 b(The)25 b(if-else)h
(statement)g(has)e(the)i(following)0 2251 y(syntax:)240 2594
y Fj(if)54 b(\()p Fi(expression)p Fj(\))458 2719 y Fi(true-statement)240
2843 y Fj(else)458 2968 y Fi(false-statement)0 3309 y Fn(The)33
b(interpreter)j(evaluates)d Fi(expression)p Fn(,)39 b(as)33
b(before.)62 b(If)34 b(the)f(value)g(of)h Fi(expression)i Fn(is)e(true,)i
(then)e(the)0 3433 y(interpreter)28 b(executes)f Fi(true-statement)p
Fn(;)f(otherwise,)h(it)e(executes)i Fi(false-statement)p Fn(.)125
3784 y(Because)39 b(the)g(if)g(statement)h(and)e(the)h(if-else)h(statement)g
(are)f(similar)-7 b(,)41 b(they)f(can)e(sometimes)i(be)0 3908
y(ambiguous.)34 b(The)25 b(following)f(code)j(will)d(produce)i(unexpected)h
(results:)240 4252 y Fj(if)54 b(\(a\))458 4376 y(if)g(\(b\))f(c;)240
4501 y(else)458 4625 y(d;)125 4966 y Fn(The)29 b(indentation)g(suggests)h
(that)f(the)h Fj(else)e Fn(clause)h(should)h(apply)f(to)h(the)g(\256rst)g
Fj(if)f Fn(clause,)i(but)e(in)0 5091 y(fact)g(it)f(applies)g(to)h(the)g(more)
g(recent)h(one.)45 b(Y)-10 b(ou)28 b(can)f(avoid)h(ambiguities)e(like)i(this)
g(by)g(using)f(braces)h(to)0 5215 y(create)j(compound)f(statements)h(out)f
(of)g(conditional)f(and)g(looping)h(statements,)i(even)e(if)f(there)i(is)f
(only)0 5340 y(one)c(of)g(them.)36 b(In)24 b(this)h(case,)h(you)f(might)g
(write:)p eop
%%Page: 13 15
13 14 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(13)240 366 y Fj(if)54 b(\(a\))f({)458 491 y(if)h(\(b\))676
616 y(c;)240 740 y(})g(else)f({)458 865 y(d;)240 989 y(})125
1358 y Fn(The)16 b(third)i(type)g(of)f(conditional)g(statement)h(is)f(the)h
Fi(switch)f(statement)p Fn(,)j(which)c(allows)g(you)h(to)h(compare)0
1482 y(one)38 b(value)e(against)f(a)i(series)h(of)g(other)g(values.)70
b(The)37 b(switch)g(statement)h(is)f(the)g(most)h(complicated)0
1607 y(statement)26 b(type)g(in)f Fj(C--)p Fn(,)f(so)i(we'll)e(start)i(with)f
(an)f(example:)240 1978 y Fj(switch)52 b(\(val\))g({)458 2102
y(case)h(0:)676 2227 y(echo\("The)e(value)h(is)i(zero."\);)458
2351 y(case)f(1)h(..)g(10:)676 2476 y(echo\("The)d(value)h(is)i(between)d
(one)i(and)g(ten)h(inclusive."\);)458 2601 y(case)f(11)h(..)f(a:)676
2725 y(echo\("The)e(value)h(is)i(between)d(eleven)h(and)h(a)h(inclusive."\);)
458 2850 y(case)f("foo",)f("bar".."baz":)240 2974 y(echo\("The)e(value)j(is)g
(\\"foo\\")f(or)h(between)f(\\"bar\\")f(and)i(\\"baz\\""\);)458
3099 y(case)g(a)h(..)g(b,)f(c)h(..)g(d,)g(42:)676 3223 y(count)f(=)h(count)e
(+)i(1;)676 3348 y(echo\("The)d(value)h(is)i(in)f(the)h(counted)d(area."\);)
458 3472 y(case)i(\304perm:)676 3597 y(echo\("Permission)48
b(denied)j(while)i(getting)e(the)i(value."\);)458 3721 y(default:)676
3846 y(echo\("Did)e(not)i(recognize)d(value."\);)240 3970 y(})0
4339 y Fn(This)25 b(example)i(illustrates)f(all)f(of)i(the)g(capabilities)e
(of)i(the)g(switch)f(statement.)40 b(The)26 b(expression)i(given)0
4463 y(by)23 b Fj(val)f Fn(in)g(the)i(example)f(is)h(the)f
Fi(controlling)i(expression)p Fn(,)i(and)22 b(is)i(compared)g(against)e(each)
i(of)g(the)f(cases)0 4588 y(inside)h(the)h(switch)f(body)-10
b(.)35 b(Each)23 b(case)i(has)f(a)f(value)h(or)h(list)f(of)h(values)e(to)j
(compare)f(against.)34 b(The)24 b(values)0 4713 y(can)j(be)h(of)h(any)e
(type,)i(and)e(need)i(not)f(be)g(constant)g(expressions.)44
b(Y)-10 b(ou)28 b(can)g(also)f(specify)i(ranges,)f(using)0
4837 y(two)k(dots)h(\(`)p Fj(..)p Fn('\))e(to)h(separate)h(the)f(lower)h(and)
e(upper)h(bounds.)55 b(The)31 b(keyword)i Fj(default)28 b Fn(speci\256es)33
b(an)0 4962 y(action)25 b(to)h(perform)h(if)f(no)f(cases)h(were)g(matched)g
(by)e(the)i(controlling)f(expression.)125 5340 y(Here)h(is)f(a)g(more)h
(formal)f(description)i(of)f(the)g(syntax)e(of)i(the)g(switch)f(statement:)p
eop
%%Page: 14 16
14 15 bop 0 -116 a Fn(14)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)240 366 y Fj(switch)52 b(\()p Fi(controlling-expression)p
Fj(\))58 b({)458 491 y(case)53 b Fi(expr-or-range)p Fj(,)k
Fi(expr-or-range)p Fj(,)g Fi(...)p Fj(:)676 616 y Fi(statements)458
740 y Fj(case)c Fi(expr-or-range)p Fj(,)k Fi(expr-or-range)p
Fj(,)g Fi(...)p Fj(:)676 865 y Fi(statements)458 989 y(.)458
1114 y(.)458 1238 y(.)458 1363 y Fj(default:)676 1487 y Fi(default-statement)
240 1612 y Fj(})0 1882 y Fn(When)27 b(executing)h(a)f(switch)g(statement,)i
(the)f(interpreter)i(scans)d(through)g(the)h(list)f(of)h(cases)g(and)f(com-)0
2007 y(pares)36 b Fi(controlling-expression)k Fn(against)34
b(each)h(of)i(the)f(lists)f(of)h(values)f(in)f(the)i(cases,)j(evaluating)34
b(the)0 2131 y(value)d(lists)i(from)g(left)g(to)h(right)e(until)f(there)j(is)
e(a)g(match.)57 b(The)32 b(lower)h(and)f(upper)h(bounds)f(of)h(ranges)0
2256 y(must)25 b(be)f(of)i(the)f(same)g(type)h(and)e(must)g(be)h(either)h
(integers)f(or)h(strings,)f(or)h(the)f(interpreter)i(will)d(throw)0
2380 y(a)d Fj(\304type)f Fn(error)-7 b(.)36 b(When)22 b(the)g(interpreter)i
(\256nds)d(a)g(match,)h(it)g(will)e(execute)j(the)f(statement)h(for)g(that)e
(case.)0 2505 y(The)k(interpreter)j(will)c(not)h(continue)g(checking)g(cases)
h(after)g(a)f(match.)125 2785 y(If)32 b(the)h(interpreter)i(does)f(not)f
(\256nd)f(a)g(match,)i(it)f(will)e(execute)j Fi(default-statement)p
Fn(,)i(the)d(statement)0 2909 y(corresponding)25 b(to)g(the)f(default)g
(case.)36 b(Y)-10 b(ou)23 b(do)i(not)f(need)h(to)f(provide)h(a)f(default)g
(case)g(if)g(you)f(do)i(not)f(wish)0 3034 y(to)i(provide)g(a)f(default)h
(action.)125 3314 y Fj(C)j Fn(programmers)j(should)d(note)i(that)f(switch)g
(statements)h(in)f Fj(C--)f Fn(differ)i(from)g(switch)f(statements)0
3438 y(in)22 b Fj(C)g Fn(in)g(several)h(respects.)37 b(Because)23
b(case)g(values)e(do)j(not)f(have)f(to)h(be)g(constants,)h(they)e(may)g
(con\257ict,)i(in)0 3563 y(which)j(case)i(the)g(\256rst)f(match)g(will)f
(take)i(precedence.)47 b(Also,)30 b(there)f(is)f(no)g(fall-through)g(in)f
Fj(C--)g Fn(switch)0 3687 y(statements;)c(only)c(the)g(statements)i
(corresponding)g(to)f(the)f(matching)f(case)i(will)e(be)i(executed.)35
b(Because)0 3812 y(there)d(is)f(no)f(fall-through,)i(the)f
Fj(break)e Fn(statement)i(does)h(not)g(apply)e(to)h(switch)g(statements.)53
b(Finally)-10 b(,)0 3937 y(the)26 b(default)f(case)h(must)f(be)g(placed)h
(last)f(in)f(the)i(list)f(of)h(cases)f(if)h(it)f(is)g(given.)0
4406 y Fg(3.4.3)54 b(Looping)30 b(Statements)125 4686 y Fj(C--)g
Fn(provides)j(three)h(kinds)d(of)i(looping)f(statements.)57
b(These)32 b(statements)h(allow)e(you)h(to)h(traverse)0 4811
y(a)28 b(list)g(or)h(a)e(range)h(of)h(numbers,)g(or)g(to)g(execute)g(a)f
(statement)h(as)f(long)g(as)g(a)f(certain)i(condition)f(is)g(true.)0
4935 y Fj(C--)g Fn(also)h(provides)h(two)g(kinds)e(of)i(jump)e(statements)j
(which)c(allow)i(you)f(to)i(prematurely)g(exit)f(from)h(a)0
5060 y(loop)c(or)g(continue)f(onto)h(the)g(next)f(iteration.)125
5340 y(The)f Fi(for-list)k(statement)e Fn(allows)e(you)h(to)h(traverse)h(a)e
(list.)35 b(It)26 b(has)e(the)i(following)f(syntax:)p eop
%%Page: 15 17
15 16 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(15)240 366 y Fj(for)53 b Fi(variable)j Fj(in)e(\()p Fi(list)p
Fj(\))458 491 y Fi(statement)0 764 y(variable)26 b Fn(must)f(be)g(the)g(name)
f(of)h(a)g(local)f(variable,)g(and)g Fi(list)i Fn(must)e(be)h(an)f
(expression)i(of)g(list)e(type.)36 b(The)0 889 y(interpreter)25
b(executes)f Fi(statement)e Fn(once)h(for)h(each)e(element)h(of)g
Fi(list)p Fn(.)35 b Fi(variable)24 b Fn(contains)e(the)g(list)g(element)0
1013 y(that)j(the)h(interpreter)i(is)d(at.)35 b(Here)26 b(is)f(an)g(example)g
(of)h(a)f(method)h(using)e(a)h(for)n(-list)h(statement:)240
1289 y Fj(var)53 b(a,)h(s;)240 1538 y(a)g(=)g(["foo",)e("bar",)f("baz"];)240
1663 y(for)i(s)h(in)g(\(a\))458 1787 y(.tell\(s\);)125 2061
y Fn(Y)-10 b(ou)31 b(can)h(also)g(iterate)h(over)g(the)f(associations)g(in)g
(a)f(dictionary)h(with)f(the)i(for)n(-list)g(statement;)k(see)0
2185 y(Section)26 b(3.6.4)f([Dictionaries],)h(page)f(22.)125
2468 y(The)33 b Fi(for-range)j(statement)f Fn(allows)e(you)h(to)h(traverse)h
(a)e(range)f(of)i(integers.)63 b(It)35 b(has)e(the)i(following)0
2593 y(syntax:)240 2869 y Fj(for)53 b Fi(variable)j Fj(in)e([)p
Fi(lower)h Fj(..)f Fi(upper)p Fj(])458 2993 y Fi(statement)125
3267 y Fn(As)26 b(before,)i Fi(variable)g Fn(must)e(be)g(the)h(name)f(of)h(a)
e(local)h(variable.)38 b Fi(lower)27 b Fn(and)f Fi(upper)h
Fn(must)f(be)g(expres-)0 3391 y(sions)g(of)i(integer)f(type.)41
b(The)26 b(interpreter)j(executes)f Fi(statement)f Fn(once)h(for)f(each)g
(number)f(from)h Fi(lower)h Fn(to)0 3516 y Fi(upper)22 b Fn(inclusive.)33
b Fi(variable)22 b Fn(contains)f(the)g(number)f(that)h(the)g(interpreter)j
(is)d(at.)34 b(Assigning)19 b(to)j Fi(variable)0 3640 y Fn(within)28
b(the)h(loop)h(body)f(will)f(not)i(change)e(the)i(status)f(of)h(the)g(loop;)i
(the)d(interpreter)j(remembers)f(what)0 3765 y(number)36 b(it)g(is)g(at)h
(independently)f(of)h(the)g(loop)g(index.)69 b(Here)38 b(is)e(an)f(example)i
(of)g(a)f(method)h(using)e(a)0 3889 y(for)n(-range)27 b(statement:)240
4165 y Fj(var)53 b(i;)240 4414 y(for)g(i)h(in)g([1)g(..)f(10])458
4539 y(.tell\(tostr\(i\)\))o(;)125 4812 y Fn(The)30 b Fi(while)h(statement)h
Fn(allows)e(you)h(to)g(execute)i(code)f(as)f(long)f(as)h(a)f(condition)h
(expression)h(is)f(true.)0 4937 y(The)25 b(while)f(statement)i(has)f(the)h
(following)e(syntax:)240 5212 y Fj(while)52 b(\()p Fi(expression)p
Fj(\))458 5337 y Fi(statement)p eop
%%Page: 16 18
16 17 bop 0 -116 a Fn(16)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y(The)36 b(interpreter)j(continually)34 b(evaluates)i
Fi(expression)j Fn(and)d(executes)i Fi(statement)f Fn(until)e(the)i(value)e
(of)0 491 y Fi(expression)e Fn(is)d(false,)i(according)e(to)h(the)g(rules)f
(in)f(Section)j(3.6.1)d([Data)h(T)-5 b(ypes],)32 b(page)e(18.)50
b(Here)31 b(is)f(an)0 616 y(example)25 b(of)h(a)f(method)h(using)e(a)h(while)
f(statement:)240 890 y Fj(var)53 b(a;)240 1139 y(a)h(=)g(1;)240
1263 y(while)e(\(a)i(<)g(35\))458 1388 y(a)g(=)g(a)g(*)h(2;)240
1512 y(.tell\(tostr\(a\)\))o(;)125 1784 y Fn(The)30 b Fi(break)g(statement)h
Fn(allows)e(you)h(to)i(exit)e(a)g(loop)h(prematurely)-10 b(.)52
b(The)30 b(break)g(statement)h(has)f(the)0 1908 y(following)24
b(syntax:)240 2165 y Fj(break;)125 2446 y Fn(The)g(interpreter)k(jumps)d(to)h
(the)g(end)f(of)h(the)g(innermost)f(for)n(-list,)i(for)n(-range,)g(or)g
(while)d(statement.)125 2728 y(The)33 b Fi(continue)g(statement)h
Fn(allows)e(you)i(to)g(jump)e(to)j(the)e(next)h(iteration)g(of)g(a)f(loop.)60
b(The)33 b(continue)0 2852 y(statement)26 b(has)f(the)g(following)g(syntax:)
240 3109 y Fj(continue;)125 3390 y Fn(The)31 b(interpreter)i(skips)f(the)f
(remainder)h(of)g(the)g(loop)g(body)f(and)g(begins)f(another)i(iteration)g
(of)g(the)0 3515 y(innermost)26 b(for)n(-list,)h(for)n(-range,)g(or)f(while)e
(statement.)125 3796 y(The)f(break)h(and)f(continue)g(statements)i(do)g(not)f
(allow)f(you)h(to)g(break)g(out)g(of)h(two)f(loops)h(at)e(once.)36
b Fj(C--)0 3921 y Fn(does)26 b(not)g(provide)g(any)d(general)i(jump)g
(mechanism.)34 b(If)25 b(you)g(\256nd)f(that)h(you)g(require)g(jumps)g(other)
h(than)0 4045 y(break)f(or)h(continue)f(statements,)i(then)e(you)g(probably)g
(need)h(to)g(reorganize)f(your)h(code.)0 4560 y Fm(3.5)59 b(Error)n
(-Handling)30 b(Statements)125 4842 y Fn(The)19 b Fi(catch)h(statement)h
Fn(allows)e(you)h(to)h(indicate)e(how)h(errors)i(should)d(be)h(handled)f(in)g
(a)h(block.)34 b(Y)-10 b(ou)20 b(can)0 4966 y(use)k(this)f(statement)i(when)e
(you)h(anticipate)f(that)h(an)e(error)k(might)d(occur)i(for)g(reasons)f
(other)h(than)e(your)0 5091 y(programming)32 b(errors.)60 b(For)33
b(instance,)h(you)e(may)g(anticipate)g(being)g(denied)h(permission)g(to)g
(perform)0 5215 y(an)28 b(operation,)j(and)d(use)h(a)f(catch)h(statement)h
(to)g(handle)d(this)i(error)i(explicitly)-10 b(.)45 b(Y)-10
b(ou)29 b(can)f(also)h(use)g(the)0 5340 y(catch)c(statement)i(to)f(make)f
(sure)h(that)f(cleanup)f(operations)j(are)e(performed)j(if)d(an)g(error)i
(occurs.)p eop
%%Page: 17 19
17 18 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(17)125 366 y(The)24 b(catch)i(statement)g(has)f(the)g(following)g(syntax:)
240 735 y Fj(catch)52 b Fi(error)27 b(code)p Fj(,)55 b Fi(error)27
b(code)p Fj(,)55 b Fi(...)458 860 y(body-statement)240 985
y Fj(with)e(handler)458 1109 y Fi(handler-statement)0 1476
y Fn(Y)-10 b(ou)25 b(can)f(substitute)h(the)g(keyword)h Fj(any)d
Fn(for)j(the)f(list)g(of)g(errors)i(to)f(indicate)e(that)h(you)g(wish)f(to)h
(catch)g(all)0 1600 y(errors.)41 b(Y)-10 b(ou)26 b(can)g(leave)g(out)h(the)f
Fj(with)e(handler)f Fn(and)i(the)i(handler)f(statement)h(if)f(you)g(do)h(not)
g(wish)e(to)0 1725 y(do)h(anything)d(in)h(the)i(handler)-7
b(.)125 2101 y(If)39 b(an)f(error)j(listed)e(in)f(the)h(error)i(list)e(is)g
(thrown)g(inside)f Fi(body-statement)p Fn(,)44 b(the)39 b(interpreter)i(will)
0 2225 y(execute)g(the)f(handler)e(rather)j(than)d(aborting)h(the)h(method.)
79 b(After)40 b(the)g(handler)f(is)g(done,)44 b(control)0 2350
y(continues)33 b(after)g(the)g(end)g(of)h(the)f(catch)f(statement,)k(as)c(if)
h Fi(body-statement)h Fn(had)e(completed)i(with)e(no)0 2474
y(errors.)125 2851 y(Inside)e(the)i(handler)-7 b(,)32 b(you)f(can)f(use)h
(the)g(function)g Fj(error\(\))d Fn(to)j(determine)i(the)e(error)i(code)f
(which)0 2975 y(triggered)c(the)e(handler)-7 b(,)27 b(the)f(function)g
Fj(error_arg\(\))c Fn(to)27 b(retrieve)h(the)e(error)j(argument)c
(speci\256ed)j(by)0 3100 y Fj(throw\(\))18 b Fn(if)j(one)g(weas)g(given,)g
(and)g(the)g(function)g Fj(traceback\(\))16 b Fn(to)21 b(retrieve)i(a)e(list)
f(of)i(strings)f(describ-)0 3224 y(ing)26 b(the)h(propagation)h(of)f(the)h
(error)h(down)e(the)g(call)f(stack.)42 b(Y)-10 b(ou)26 b(can)h(use)g(the)g
(function)g Fj(rethrow\(\))c Fn(to)0 3349 y(continue)i(propagating)g(an)f
(error)-7 b(.)125 3725 y(Here)42 b(is)f(an)f(example)h(of)h(how)f(you)g
(might)g(use)g(a)g(catch)g(statement)h(to)h(intelligently)c(handle)h(a)0
3850 y Fj(\304methodnf)21 b Fn(error)27 b(from)g(the)e Fj(list_method\(\))20
b Fn(function:)240 4226 y Fj(catch)52 b(\304methodnf)f({)458
4351 y(code)i(=)h(list_method\(met)o(ho)o(d_)o(na)o(me\))o(;)240
4475 y(})g(with)f(handler)e({)458 4600 y(.tell\("There)e(is)54
b(no)g(method)d(named)i(")h(+)g(tostr\(method_n)o(ame)o(\))48
b(+)54 b("."\);)240 4724 y(})125 5091 y Fn(Note)32 b(that)f(critical)g
(expressions)i(\(see)f(Section)h(3.6.12)d([Error)n(-Handling)h(Expressions],)
i(page)f(30\))0 5215 y(inside)e Fi(body-statement)i Fn(will)e(override)j(the)
e(behavior)f(of)i(the)f(catch)g(statement.)54 b(For)31 b(more)h(detail)f(on)0
5340 y(errors)c(in)e Fj(C--)p Fn(,)f(see)i(Chapter)g(4)e([Errors],)k(page)d
(33.)p eop
%%Page: 18 20
18 19 bop 0 -116 a Fn(18)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(3.6)59 b(Expressions)125 650 y Fn(Y)-10
b(ou)20 b(can)h(express)h(values)f(in)f Fj(C--)f Fn(methods)j(using)e
Fi(expressions)p Fn(.)37 b(The)21 b(following)f(sections)i(document)0
774 y(the)34 b(various)e(types)i(of)g(expressions)h(in)d Fj(C--)p
Fn(,)i(as)f(well)f(as)h(the)h(types)g(of)g(values)e(they)i(can)e(have)h(when)
0 899 y(evaluated.)0 1399 y Fg(3.6.1)54 b(Data)29 b(T)-6 b(ypes)125
1683 y Fn(Every)27 b(piece)h(of)g(data)e(in)g Fj(C--)g Fn(has)g(a)h(type.)42
b(This)26 b(section)h(documents)h(the)g(data)e(types)i(in)f
Fj(C--)p Fn(.)39 b(Y)-10 b(ou)0 1807 y(can)28 b(produce)i(values)e(of)h(the)g
(simpler)g(data)f(types)i(\(integers,)g(strings,)g(dbrefs,)g(symbols,)g
(error)g(codes\))0 1932 y(can)i(be)h(produced)h(with)e Fi(literal)i
Fn(expressions;)k(you)33 b(can)f(produce)i(values)e(of)h(the)g(more)h
(complex)f(data)0 2056 y(types)20 b(\(lists,)h(dictionaries,)g(frobs,)g
(buffers\))f(with)f Fi(constructor)i Fn(expressions.)35 b(As)19
b(we)g(go,)i(we)e(will)f(explain)0 2181 y(how)28 b(to)h(specify)g(or)g
(construct)h(values)d(of)i(each)f(of)h(the)g(data)f(types,)i(and)e(explain)f
(what)g(it)h(means)g(for)h(a)0 2305 y(value)24 b(of)i(each)f(data)g(type)h
(to)h(be)e(true.)125 2561 y(Every)g(piece)h(of)g(data)f(in)g
Fj(C--)f Fn(has)g(a)h(type)h(and)e(a)h(truth)h(value.)34 b(The)25
b(type)h(can)f(be)g(one)h(of:)75 2845 y Fl(\017)60 b Fn(Integer)75
3004 y Fl(\017)g Fn(String)75 3163 y Fl(\017)g Fn(Dbref)75
3322 y Fl(\017)g Fn(List)75 3480 y Fl(\017)g Fn(Symbol)75 3639
y Fl(\017)g Fn(Error)26 b(type)75 3798 y Fl(\017)60 b Fn(Frob)75
3957 y Fl(\017)g Fn(Dictionary)75 4116 y Fl(\017)g Fn(Buffer)125
4434 y(An)30 b Fi(integer)i Fn(is)e(just)h(a)g(number)-7 b(.)53
b(Integers)32 b(can)e(reliably)g(be)h(from)h(-2147483648)27
b(to)32 b Fj(+)p Fn(2147483647.)0 4558 y(An)21 b(integer)i(is)f(true)h(if)f
(it)h(is)f(not)g(zero.)36 b(Y)-10 b(ou)22 b(can)g(denote)i(integer)e
(literals)g(in)g Fj(C--)f Fn(by)g(writing)h(a)g(sequence)0
4683 y(of)k(digits,)f(optionally)g(preceded)j(by)c(a)h(`)p
Fj(-)p Fn(')f(or)i(`)p Fj(+)p Fn(')e(sign.)125 4966 y(A)k Fi(string)i
Fn(is)e(a)h(sequence)h(of)f(printable)g(characters.)48 b(A)28
b(string)h(is)g(true)h(if)f(it)g(is)g(not)g(empty)-10 b(.)48
b(Y)-10 b(ou)29 b(can)0 5091 y(denote)j(string)e(literals)g(in)f
Fj(C--)g Fn(by)g(enclosing)h(a)g(sequence)h(of)f(characters)i(in)d(double)h
(quotes)h(\(`)p Fj(")p Fn('\).)49 b(T)-8 b(o)0 5215 y(include)20
b(a)h(double)g(quote)g(or)h(backslash)e(character)i(in)e(a)h(string)g
(literal,)g(precede)j(it)d(by)g(a)f(backslash)g(\(`)p Fj(\\)p
Fn('\).)0 5340 y(The)25 b(following)f(are)i(string)f(literals:)p
eop
%%Page: 19 21
19 20 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(19)240 366 y Fj("foo")240 491 y("\\"foo\\")51 b(is)j(a)g(metasyntactic)48
b(variable.")240 616 y("The)53 b(backslash)d(\(`\\\\'\))i(is)i(a)g
(much-abused)49 b(character)i(in)i(many)g(languages.")125 891
y Fn(A)29 b Fi(dbref)42 b Fn(is)29 b(a)g(reference)j(to)f(an)d(object,)k
(which)d(may)f(or)j(may)d(not)i(exist.)49 b(Database)28 b(references)33
b(are)0 1015 y(always)25 b(true,)k(whether)f(or)g(not)f(they)g(refer)j(to)d
(actual)g(objects.)42 b(Y)-10 b(ou)27 b(can)g(denote)h(dbref)g(literals)f(in)
f Fj(C--)0 1140 y Fn(by)f(preceding)h(a)f(number)f(with)h(a)g(sharp)g(\(`)p
Fj(#)p Fn('\);)f(for)j(example,)e Fj(#1)g Fn(and)f Fj(#267)g
Fn(are)h(valid)f(dbref)i(literals.)125 1425 y(A)d Fi(list)h
Fn(is)f(a)g(collection)h(of)g(objects)h(of)f(any)e(type.)36
b(Lists)23 b(are)h(useful)f(for)h(manipulating)c(several)k(objects)0
1549 y(at)j(once.)42 b(A)27 b(list)g(is)g(true)h(if)f(it)g(is)g(not)h(empty)
-10 b(.)42 b(Y)-10 b(ou)27 b(can)f(construct)j(a)e(list)g(value)f(by)g
(enclosing)h(a)g(comma-)0 1674 y(separated)f(series)f(of)h(expressions)f(in)f
(square)g(brackets;)i(for)g(example,)f Fj([1,)e(2,)i(3])e Fn(and)h
Fj([1,)g(["foo",)0 1798 y('bar],)f(#23])g Fn(are)j(valid)e(list)h
(construction)h(expressions.)125 2083 y(A)f Fi(symbol)h Fn(is)g(a)f(symbolic)
g(value.)36 b(Y)-10 b(ou)25 b(can)h(denote)h(symbols)e(in)g
Fj(C--)f Fn(by)h(preceding)i(an)d(identi\256er)i(or)0 2208
y(string)c(with)g(an)f(apostrophe)j(\(`)p Fj(')p Fn('\).)34
b Fj('remote)p Fn(,)20 b Fj('template)p Fn(,)f(and)i Fj('object)f
Fn(are)i(valid)f(symbol)h(literals.)0 2332 y(Symbols)j(are)h(always)d(true.)
125 2617 y(An)18 b Fi(error)j(code)e Fn(identi\256es)g(a)g(type)g(of)h(error)
h(condition.)34 b(Both)19 b(the)g Fj(C--)f Fn(interpreter)j(and)d
Fj(C--)g Fn(methods)0 2742 y(use)30 b(error)j(codes)e(to)g(identify)f(types)i
(of)f(errors)h(when)d(they)i(occur)-7 b(.)52 b(See)31 b(Chapter)f(4)g
([Errors],)k(page)c(33)0 2866 y(for)c(information)f(about)g(how)g(Coldmud)g
(handles)f(errors.)38 b(Y)-10 b(ou)25 b(can)g(denote)i(error)g(code)g
(literals)e(in)f Fj(C--)0 2991 y Fn(by)h(preceding)h(an)e(identi\256er)i(or)g
(string)f(with)f(a)h(tilde)h(\(`)p Fj(\304)p Fn('\).)35 b(Error)26
b(codes)h(are)f(always)d(false.)125 3276 y(A)29 b Fi(frob)h
Fn(consists)g(of)h(a)e Fi(class)p Fn(,)j(the)e(dbref)h(of)f(an)f(object,)j
(and)d(a)g Fi(representation)p Fn(,)k(a)c(list)g(or)i(dictionary)-10
b(.)0 3400 y(Frobs)22 b(are)g(intended)g(to)g(serve)h(as)f(lightweight)e
(objects.)35 b(Y)-10 b(ou)22 b(can)f(construct)i(a)e(frob)i(value)d(by)h
(enclosing)0 3525 y(expressions)34 b(for)f(the)g(class)f(and)f
(representation)j(in)e(triangular)f(brackets,)k(separated)e(by)f(a)g(comma;)0
3649 y(for)26 b(instance,)f Fj(<#73,)e([1,)h(2]>)g Fn(is)h(a)g(valid)f(frob)i
(construction)g(expression.)37 b(Frobs)26 b(are)f(always)f(true.)125
3934 y(A)19 b Fi(dictionary)j Fn(is)e(a)f(collection)i(of)g
Fi(associations)p Fn(,)j(each)c(of)h(which)e(has)h(a)f Fi(key)i
Fn(and)e(a)h Fi(value)p Fn(.)34 b(Dictionaries)0 4059 y(take)22
b(up)f(more)h(space)g(than)f(lists,)h(but)f(searching)g(for)h(a)f(data)g
(value)f(in)h(a)g(dictionary)g(is)g(generally)g(faster)0 4183
y(than)k(searching)g(for)i(data)e(values)g(in)g(lists.)36 b(Y)-10
b(ou)26 b(can)f(construct)i(a)f(dictionary)f(by)g(enclosing)g(a)h(comma-)0
4308 y(separated)k(series)h(of)f(associations)f(in)f(square)h(brackets,)j
(where)d(each)h(association)f(is)g(a)f(two-element)0 4432 y(list)37
b(giving)f(a)h(key)h(and)f(a)g(value,)j(and)d(preceding)h(the)g(whole)g
(thing)e(with)h(a)g(hash)g(mark)g(\(`)p Fj(#)p Fn('\).)72 b(For)0
4557 y(instance,)32 b Fj(#[["foo",)21 b(3],)j(["bar",)e('baz]])28
b Fn(is)j(a)f(valid)g(dictionary)g(construction)i(expression.)53
b(A)0 4681 y(dictionary)25 b(is)g(true)h(if)f(it)h(is)f(not)g(empty)-10
b(.)125 4966 y(a)17 b Fi(buffer)i Fn(is)e(an)g(array)h(of)h(unsigned)e
(eight-bit)g(values,)i(intended)g(for)g(network)g(I/O.)f(Y)-10
b(ou)18 b(can)g(construct)0 5091 y(a)37 b(buffer)i(by)e(enclosing)g(a)h
(comma-separated)h(series)g(of)f(integer)h(expressions)g(in)e(square)g
(brackets,)0 5215 y(preceded)20 b(by)d(a)f(percent)j(sign)e(\(`)p
Fj(\045)p Fn('\).)32 b(For)18 b(instance,)g Fj(\045[65,)23
b(66,)h(67,)g(10])16 b Fn(is)h(a)g(valid)f(buffer)i(construction)0
5340 y(expression.)37 b(A)25 b(buffer)g(is)g(true)h(if)g(it)f(is)g(not)g
(empty)-10 b(.)p eop
%%Page: 20 22
20 21 bop 0 -116 a Fn(20)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(Y)-10 b(ou)20 b(can)f(get)i(the)g(type)g(of)g(a)f
(piece)h(of)g Fj(C--)e Fn(data)h(using)f(the)i Fj(type\(\))c
Fn(function.)34 b(The)20 b Fj(type\(\))d Fn(function)0 491
y(returns)31 b(a)e(symbol)h(corresponding)h(to)g(the)f(type)h(of)g(its)f
(argument.)50 b(This)28 b(symbol)i(can)f(be)h Fj('integer)p
Fn(,)0 616 y Fj('string)p Fn(,)22 b Fj('dbref)p Fn(,)h Fj('list)p
Fn(,)g Fj('symbol)p Fn(,)g Fj('error)p Fn(,)g Fj('frob)p Fn(,)g(or)j
Fj('dictionary)p Fn(.)0 1070 y Fg(3.6.2)54 b(Names)125 1348
y Fn(A)23 b Fi(name)h Fn(is)f(an)g(indirect)i(reference)h(to)f(an)e(object.)
36 b(Coldmud)23 b(translates)h(names)f(into)h(dbrefs)h(during)0
1472 y(method)31 b(interpretation)g(according)f(to)h(the)f(associations)g
(made)g(using)e(the)i(administrative)f(function)0 1597 y Fj(set_name\(\))p
Fn(.)46 b(A)30 b Fi(name)g(expression)j Fn(is)d(simply)g(a)g(name)f(token,)k
(an)c(identi\256er)i(or)g(string)f(following)f(a)0 1722 y(dollar)c(sign)f
(\(`)p Fj($)p Fn('\).)125 2000 y(When)c(the)h(interpreter)j(encounters)d(a)g
(name)f(expression,)j(it)e(looks)g(up)g(the)g(name)f(to)h(see)h(what)e(dbref)
0 2124 y(it)h(has)g(been)g(assigned)g(by)g(the)h Fj(set_name\(\))16
b Fn(function.)34 b(If)22 b(no)f(such)g(assignment)g(has)f(been)i(made,)g
(then)0 2249 y(the)32 b(interpreter)h(throws)f(a)f Fj(\304namenf)d
Fn(error;)37 b(otherwise,)d(the)e(value)e(of)i(the)g(name)e(expression)j(is)e
(the)0 2373 y(dbref)26 b(assigned)f(to)h(the)f(name)g(by)g
Fj(set_name\(\))p Fn(.)125 2652 y(Y)-10 b(ou)29 b(can)g(also)g(use)h(the)g
(\(non-administrative\))f(function)g Fj(get_name\(\))c Fn(to)30
b(look)g(up)f(a)g(symbol)g(as)g(a)0 2776 y(name.)125 3055 y(The)24
b(administrative)h(function)g Fj(del_name\(\))20 b Fn(deletes)27
b(the)f(association)f(for)h(a)f(name.)0 3509 y Fg(3.6.3)54
b(Lists)125 3787 y Fn(A)28 b Fi(list)i Fn(is)e(a)h(collection)h(of)f(pieces)h
(of)g(data)e(of)i(any)e(type.)47 b(Y)-10 b(ou)29 b(can)f(create)j(a)d(list)h
(in)f Fj(C--)f Fn(using)h(a)g Fi(list)0 3912 y(construction)f(expression)p
Fn(.)38 b(A)25 b(list)g(construction)h(expression)h(has)d(the)i(following)e
(syntax:)240 4165 y Fj([)p Fi(expression1)p Fj(,)56 b Fi(expression2)p
Fj(,)g(...])0 4443 y Fi(expression1)p Fn(,)33 b Fi(expression2)p
Fn(,)h Fi(...)50 b Fn(are)30 b(the)g(elements)g(of)h(the)f(list.)49
b(Y)-10 b(ou)30 b(can)f(also)g(splice)h(a)g(list)f(into)h(a)f(list)0
4568 y(construction)21 b(expression;)i(see)e(Section)g(3.6.13)e([Splicing],)h
(page)g(31.)33 b(The)20 b(result)g(of)h(a)e(list)h(construction)0
4692 y(expression)30 b(is)g(a)e(list)i(containing)d(the)j(values)f(of)h(the)f
(expressions.)50 b(Here)30 b(are)g(some)g(examples)f(of)h(list)0
4817 y(construction)c(expressions:)240 5088 y Fj([1,)53 b(2,)h(3])240
5212 y([a)g(+)g(5,)f('string,)e([3,)i("b"],)g(tostr\(\304none\)])240
5337 y([])p eop
%%Page: 21 23
21 22 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(21)125 366 y(T)-8 b(o)39 b(retrieve)j(an)e(element)h(of)f(a)g(list,)k(you)c
(can)f(use)i(a)e Fi(list)i(selection)i(expression)p Fn(,)j(which)39
b(has)h(the)0 491 y(following)24 b(syntax:)240 748 y Fi(list)p
Fj([)p Fi(element)p Fj(])0 1030 y Fi(list)d Fn(must)e(be)h(an)f(expression)i
(of)f(list)g(type)h(\(or)f(string)g(type;)j(see)e(below\))e(and)g
Fi(element)i Fn(is)f(an)e(expression)j(of)0 1155 y(integer)i(type)g(whose)f
(value)f(is)h(between)h(one)f(and)f(the)i(length)e(of)i(the)g(list.)34
b(The)22 b(value)f(of)i(a)e(list)h(selection)0 1279 y(expression)27
b(is)e(the)h(value)e(of)j(the)f(element)g(of)g Fi(list)h Fn(numbered)e(by)g
Fi(element)p Fn(,)h(where)h(the)e(elements)i(of)f Fi(list)0
1404 y Fn(are)g(numbered)f(starting)g(from)h(one.)36 b(For)26
b(example,)f(the)h(following)e(method)i(returns)g Fj(3)p Fn(:)240
1678 y Fj(var)53 b(a;)240 1927 y(a)h(=)g(["foo",)e(2,)h('bar,)f(3,)i
(\304parents];)240 2052 y(return)e(a[4];)0 2324 y Fn(Y)-10
b(ou)29 b(can)g(use)g(the)h(list)f(selection)h(expression)g(with)f(strings)g
(as)g(well)f(as)h(with)g(lists.)47 b(In)29 b(this)f(case,)j
Fj(C--)0 2449 y Fn(treats)j(the)f(string)g(as)f(if)h(it)g(were)h(a)e(list)h
(of)g(one-character)i(strings.)58 b(The)33 b(following)f(method)h(returns)0
2573 y Fj("p")p Fn(:)240 2848 y Fj(var)53 b(a;)240 3097 y(a)h(=)g("Depth";)
240 3222 y(return)e(a[3];)125 3494 y Fn(Y)-10 b(ou)24 b(can)h(also)f(use)h
(the)h(list)e(selection)i(expression)g(with)f(dictionaries;)g(we)g(will)f
(describe)i(this)f(usage)0 3618 y(in)f(the)i(next)g(section.)125
3900 y(Y)-10 b(ou)23 b(can)h(look)g(for)h(a)f(piece)h(of)f(data)g(in)f(a)h
(list,)g(you)g(can)f(use)h(a)g Fi(list)g(search)i(expression)p
Fn(,)h(which)c(has)g(the)0 4025 y(following)h(syntax:)240 4282
y Fi(element)55 b Fj(in)f Fi(list)0 4564 y Fn(The)20 b(value)g(of)h(this)f
(expression)i(is)e(the)h(index)f(of)i(the)e(\256rst)h(occurrance)h(of)g
Fi(element)f Fn(in)f Fi(list)p Fn(,)i(or)g Fj(0)e Fn(if)g Fi(element)0
4689 y Fn(does)26 b(not)g(occur)g(in)f Fi(list)p Fn(.)36 b(The)25
b(following)g(method)h(returns)g Fj([3,)e(0])p Fn(:)240 4963
y Fj(var)53 b(a;)240 5212 y(a)h(=)g(['foo,)e("bar",)g(4)i(+)g(2,)g(#77];)240
5337 y(return)e([6)h(in)h(a,)g('quux)e(in)i(a];)p eop
%%Page: 22 24
22 23 bop 0 -116 a Fn(22)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y(As)32 b(with)g(the)g(list)g(selection)h(expression,)j
(you)c(can)g(use)g(the)h(list)f(search)g(expression)i(with)d(strings)h(as)0
491 y(well)22 b(as)g(with)f(lists.)34 b(In)22 b(this)g(case,)i(both)e
Fi(element)h Fn(and)e Fi(list)i Fn(must)f(be)g(strings,)h(and)f(the)g(result)
h(is)f(the)h(\256rst)0 616 y(position)j(at)f(which)f Fi(element)i
Fn(occurs)g(in)f Fi(list)p Fn(,)h(or)g(0)f(if)g(it)h(does)g(not)g(occur)-7
b(.)0 1172 y Fg(3.6.4)54 b(Dictionaries)125 1462 y Fn(A)34
b Fi(dictionary)j Fn(is)d(a)h(list)g(of)g Fi(associations)p
Fn(.)68 b(Each)34 b(association)h(contains)f(a)h Fi(key)g Fn(and)f(a)h
Fi(value)p Fn(,)j(both)0 1587 y(arbitrary)21 b Fj(C--)e Fn(data)i(values.)33
b(Dictionaries)21 b(take)g(up)g(more)h(space)g(than)e(lists,)i(but)e(allow)h
(fast)g(searches.)0 1711 y(Only)j(one)i(association)f(in)f(a)h(dictionary)g
(may)g(have)f(a)h(given)g(key)-10 b(.)125 2001 y(Dictionary)24
b(construction)j(expressions)f(have)f(the)g(following)g(syntax:)240
2266 y Fj(#[[)p Fi(key1)p Fj(,)53 b Fi(value1)p Fj(],)g([)p
Fi(key2)p Fj(,)h Fi(value2)p Fj(],)g Fi(...)p Fj(])125 2556
y Fn(The)25 b(result)h(of)g(a)g(dictionary)f(construction)i(expression)g(is)e
(a)g(dictionary)h(with)f(the)h(keys)g Fi(key1)p Fn(,)g Fi(key2)p
Fn(,)0 2680 y Fi(...)34 b Fn(and)19 b(the)i(associated)f(values)f
Fi(value1)p Fn(,)i Fi(value2)p Fn(,)g Fi(...)p Fn(.)35 b(The)19
b(following)g(are)i(valid)d(dictionary)i(construction)0 2805
y(expressions:)240 3069 y Fj(#[["foo",)50 b(3],)k(['bar,)d(4],)j([8,)f([#0,)g
('startup]]])240 3169 y(#[['type,)d('and],)i(['lhs,)g(3],)h(['rhs,)f(0]])125
3459 y Fn(Y)-10 b(ou)29 b(can)f(search)i(for)g(the)g(value)e(associated)i
(with)e(a)h(key)g(in)g(a)g(dictionary)g(using)f(the)h(list)g(selection)0
3583 y(expression:)240 3848 y Fi(dict)p Fj([)p Fi(key)p Fj(])125
4138 y Fn(If)24 b(any)g(of)h(the)g(associations)f(in)g Fi(dict)h
Fn(have)f(the)h(key)f Fi(key)p Fn(,)i(the)f(result)g(of)g(this)f(expression)i
(is)e(the)h(value)0 4262 y(associated)37 b(with)f(that)h(key)-10
b(.)70 b(If)37 b Fi(key)g Fn(is)f(not)h(the)g(key)g(of)h(any)d(of)j(the)f
(associations)f(in)g Fi(dict)p Fn(,)k(then)d(the)0 4387 y(interpreter)28
b(raises)d(a)g Fj(\304keynf)e Fn(error)-7 b(.)125 4677 y(Y)d(ou)24
b(can)g(iterate)i(over)g(a)e(dictionary')m(s)g(associations)h(using)e(the)i
(for)n(-list)h(statement;)g(at)f(each)f(step)i(of)0 4801 y(the)17
b(for)n(-list)h(statement,)i(the)d(loop)g(index)f(will)g(contain)g(a)g(list)g
Fj([)p Fi(key)p Fj(,)25 b Fi(value)p Fj(])17 b Fn(for)g(the)g(current)h
(association.)125 5091 y(The)43 b(four)i(dictionary)f(manipulation)e
(functions)i Fj(dict_keys\(\))p Fn(,)g Fj(dict_contains\(\))o
Fn(,)f Fj(dict_)0 5215 y(add\(\))p Fn(,)e(and)e Fj(dict_del\(\))c
Fn(allow)k(you)g(to)i(manipulate)d(dictionaries)i(in)e(other)j(ways;)46
b(see)41 b(the)f(de-)0 5340 y(scriptions)26 b(of)g(each)f(function)g(for)i
(details.)p eop
%%Page: 23 25
23 24 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(23)0 366 y Fg(3.6.5)54 b(Buffers)125 649 y Fn(A)32 b Fi(buffer)g
Fn(is)h(a)f(vector)i(of)f(unsigned)e(eight-bit)h(values,)i(intended)f
(primarily)e(for)j(network)f(I/O.)f(Al-)0 773 y(though)h(they)h(are)h(not)f
(as)f(convenient)i(to)f(use)g(as)g(strings,)i(they)e(can)g(contain)f(any)g
(character)i(value,)0 898 y(while)24 b(strings)h(can)g(contain)g(only)g
(printable)f(characters.)125 1180 y(Y)-10 b(ou)27 b(can)h(construct)h(a)f
(buffer)h(using)d(a)i Fi(buffer)g(construction)i(expression)p
Fn(,)h(which)c(has)g(the)i(following)0 1305 y(syntax:)240 1562
y Fj(\045[)p Fi(byte1)p Fj(,)53 b Fi(byte2)p Fj(,)h Fi(...)p
Fj(])125 1844 y Fn(The)34 b(result)i(of)g(a)e(buffer)i(construction)g
(expression)g(is)f(a)g(buffer)g(containing)f(the)h(byte)g(values)f(ex-)0
1969 y(pressed)29 b(by)e Fi(byte1)p Fn(,)h Fi(byte2)p Fn(,)g
Fi(...)p Fn(,)i(all)c(of)i(which)e(must)i(be)f(integers.)43
b(If)28 b(any)e(of)i(the)g(values)e(of)j Fi(byte1)p Fn(,)f
Fi(byte2)p Fn(,)0 2093 y Fi(...)37 b Fn(cannot)26 b(\256t)f(inside)g(an)g
(unsigned)f(eight-bit)i(number)-7 b(,)25 b(then)h(that)f(byte)h(will)e
(contain)h(the)h(lower)g(order)0 2218 y(eight)f(bits)g(of)h(the)g
(speci\256ed)g(number)-7 b(.)125 2500 y(Apart)30 b(from)h(operations)g(which)
e(apply)h(to)g(all)f(data)h(types,)j(the)d(only)g(language)e(operations)j
(which)0 2625 y(apply)47 b(to)h(buffers)g(are)g(the)g(functions)f(whose)g
(names)g(begin)g(with)f(`)p Fj(buffer_)p Fn(':)76 b Fj(buffer_len\(\))p
Fn(,)0 2749 y Fj(buffer_retrieve)o(\(\))o Fn(,)31 b Fj(buffer_append\()o(\))p
Fn(,)f Fj(buffer_replace\()o(\))p Fn(,)g Fj(buffer_add\(\))p
Fn(,)h Fj(buffer_)0 2874 y(truncate\(\))p Fn(,)f Fj(buffer_to_strin)o(gs)o
(\(\))p Fn(,)e(and)k Fj(buffer_from_str)o(in)o(gs\()o(\))p
Fn(.)51 b(The)33 b(last)f(two)h(func-)0 2998 y(tions)25 b(allow)g(you)g(to)h
(convert)g(between)g(buffers)g(and)f(lists)g(of)h(strings.)125
3281 y(Coldmud)32 b(passes)i(data)f(between)g(the)h(object)g(heirarchy)f(and)
g(network)h(connections)g(in)e(terms)i(of)0 3405 y(buffers;)26
b(see)g(Section)h(6.3)d([Connections],)j(page)e(74)f(for)j(details.)0
3895 y Fg(3.6.6)54 b(Frobs)125 4178 y Fn(A)30 b Fi(frob)i Fn(is)e(a)h
(dictionary)f(or)i(list)f(\(its)g Fi(representation)p Fn(\))i(associated)f
(with)e(a)h(dbref)g(\(its)h Fi(class)p Fn(\).)54 b(Frobs)0
4302 y(represent)22 b(a)e(kind)g(of)h(lightweight)d(object,)23
b(with)c(less)i(overhead)g(than)e(real)h(objects.)35 b(The)20
b(encapsulation)0 4427 y(around)28 b(frobs)i(is)f(not)g(as)f(strong)i(as)e
(the)i(encapsulation)d(around)i(real)g(objects,)i(and)d(in)g(some)i(respects)
0 4551 y(frobs)i(are)g(not)g(as)f(convenient)h(to)h(work)f(with)e(as)i(real)f
(objects.)56 b(In)31 b(general,)i(objects)g(should)e(be)h(used)0
4676 y(for)26 b(long-lasting,)e(complicated,)i(changing)d(entities,)i(while)f
(frobs)i(should)e(be)h(used)h(for)g(small)d(pieces)j(of)0 4800
y(data.)125 5083 y(Frob)f(construction)h(expressions)h(have)d(the)i
(following)e(syntax:)240 5340 y Fj(<)p Fi(class)p Fj(,)55 b
Fi(representation)p Fj(>)p eop
%%Page: 24 26
24 25 bop 0 -116 a Fn(24)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(The)h(result)h(of)h(a)e(frob)h(construction)h
(expression)g(is)f(a)f(frob)i(of)f(class)g Fi(class)p Fn(,)i(which)c(must)i
(be)g(a)f(dbref,)0 491 y(with)18 b(a)h(representation)i Fi(representation)p
Fn(,)i(which)18 b(must)h(be)g(a)f(list)h(or)h(dictionary)-10
b(.)34 b(In)18 b(general,)j(you)e(should)0 616 y(only)32 b(use)g(the)h(frob)g
(construction)g(expression)h(to)f(construct)h(frobs)f(of)g(class)f
Fj(this\(\))p Fn(,)g(but)g(this)g(is)g(not)0 740 y(enforced.)38
b(The)25 b(following)f(are)i(valid)e(frob)i(construction)g(expressions:)240
999 y Fj(<#76,)52 b(#[['type,)f('true]]>)240 1099 y(<#89,)h(["You)h(cannot)e
(go)j(that)f(way."]>)125 1383 y Fn(Apart)21 b(from)h(operations)g(which)e
(apply)h(to)h(all)e(data)g(types,)k(the)d(only)g(operations)h(supported)h(on)
e(frobs)0 1507 y(are)37 b(message-passing)g(and)f(the)h Fj(class\(\))d
Fn(function.)70 b(When)37 b(you)g(send)g(a)f(message)i(to)f(a)g(frob,)k(the)0
1632 y(interpreter)26 b(treats)e(it)f(as)g(a)g(message)g(to)h(the)g(frob')m
(s)f(class,)g(with)g(the)g(frob')m(s)g(representation)i(inserted)f(as)0
1756 y(the)i(\256rst)f(argument.)35 b(The)25 b Fj(class\(\))d
Fn(function)j(returns)h(the)g(class)f(of)h(a)f(frob.)0 2261
y Fg(3.6.7)54 b(V)-10 b(ariables)125 2545 y Fj(C--)23 b Fn(provides)k(two)f
(kinds)e(of)i(variables,)f Fi(local)h(variables)h Fn(and)e
Fi(object)h(variables)p Fn(.)125 2829 y Fi(Local)35 b(variables)i
Fn(allow)c(methods)j(to)f(temporarily)h(store)g(information.)64
b(T)-8 b(o)34 b(use)h(a)f(local)g(variable)0 2953 y(in)g(a)g(method,)k
(declare)d(the)g(local)f(variable')m(s)e(name)i(\(an)g(identi\256er\))h(at)f
(the)h(top)g(of)h(the)f(method)g(in)e(a)0 3078 y Fj(var)h Fn(declaration)i
(\(see)g(Section)h(3.3)e([Method)h(Structure],)k(page)c(9\).)66
b(The)35 b(variable')m(s)e(name)i(is)g(then)0 3202 y(an)26
b(expression)i(whose)f(value)f(is)g(the)h(contents)h(of)g(the)f(variable.)38
b(The)27 b(variable)e(initially)f(contains)j(the)0 3327 y(integer)f
Fj(0)p Fn(.)125 3611 y(T)-8 b(o)19 b(set)h(the)g(variable')m(s)e(contents,)k
(use)e(an)e Fi(assignment)i(statement)p Fn(,)i(which)c(has)h(the)h(following)
f(syntax:)240 3870 y Fi(variable)56 b Fj(=)e Fi(value)p Fj(;)125
4154 y Fn(This)41 b(assigns)g(the)h(value)f Fi(value)i Fn(to)g(the)f
(variable)f Fi(variable)p Fn(.)88 b(The)41 b(values)h(of)g(a)g(method')m(s)g
(local)0 4278 y(variables)e(are)i(speci\256c)g(to)g(the)g(processing)h(of)f
(a)f(particular)g(message)g(call;)49 b(when)41 b(the)h(method)g(is)0
4403 y(invoked)25 b(another)h(time,)g(all)e(of)i(its)f(local)g(variables)f
(begin)g(with)h(the)g(value)g Fj(0)f Fn(again.)125 4687 y(The)g(following)h
(example)g(method)h(returns)g Fj(6)p Fn(:)240 4963 y Fj(var)53
b(a;)240 5212 y(a)h(=)g(3;)240 5337 y(return)e(a)i(+)g(3;)p
eop
%%Page: 25 27
25 26 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(25)125 366 y Fi(Object)39 b(variables)j Fn(store)g(information)e(for)h(an)e
(inde\256nite)h(period)h(of)g(time.)81 b(Y)-10 b(ou)40 b(refer)i(to)f(object)
0 491 y(variables)24 b(through)h(parameters,)i(which)d(are)i(de\256ned)f(on)h
(the)f(current)i(method')m(s)e(de\256ning)f(object)j(\()p Fi(not)0
616 y Fn(the)k(current)h(object\).)54 b(As)31 b(with)f(local)h(variables,)g
(you)g(can)f(retrieve)j(the)f(value)e(of)h(an)f(object)i(variable)0
740 y(by)h(writing)g(the)i(name)e(of)i(the)f(parameter)h(which)e(refers)j(to)
f(that)f(variable,)h(and)e(you)h(can)f(assign)g(to)0 865 y(an)38
b(object)h(variable)e(using)g(an)h(assignment)f(statement.)76
b(Y)-10 b(ou)39 b(can)f(also)g(use)h(the)f Fj(get_var\(\))d
Fn(and)0 989 y Fj(set_var\(\))22 b Fn(functions)j(to)i(perform)g(these)g
(operations.)37 b(It)27 b(is)e(an)g(error)i(of)g(type)f Fj(\304paramnf)c
Fn(to)27 b(refer)g(to)0 1114 y(a)32 b(parameter)i(which)d(does)j(not)f(exist)
f(on)h(the)g(current)g(method')m(s)g(de\256ning)e(object.)58
b(Object)33 b(variables)0 1238 y(begin)24 b(with)h(the)g(value)g
Fj(0)p Fn(.)0 1813 y Fg(3.6.8)54 b(Operators)125 2104 y Fn(Operators)40
b(are)f(used)g(to)h(perform)g(simple)f(operations)h(on)f(expression)h
(values,)h(such)e(as)f(adding)0 2229 y(two)d(values)f(together)-7
b(.)66 b Fj(C--)34 b Fn(provides)h(a)g(variety)f(of)i(operators)h(to)e
(perform)i(arithmetic)e(and)f(logical)0 2353 y(operations)17
b(on)g(data.)32 b(Most)17 b(of)g(these)g(operators)h(fall)e(into)g(two)h
(syntactical)e(categories:)33 b Fi(unary)16 b(operators)0 2478
y Fn(and)25 b Fi(binary)g(operators)p Fn(.)125 2770 y Fi(Unary)32
b(operators)i Fn(act)e(on)g(a)f(single)g(expression)i(value.)54
b(In)31 b Fj(C--)p Fn(,)i(all)d(unary)h(operators)j(are)e(single)0
2894 y(characters)27 b(which)e(precede)k(expressions.)40 b(For)27
b(example,)f Fj(!a)g Fn(is)g(the)g(logical)g(negation)f(of)i(the)g(value)e
(of)0 3019 y(the)h(variable)d Fj(a)p Fn(.)125 3310 y Fi(Binary)h(operators)i
Fn(act)f(on)e(two)i(expression)g(values.)34 b(For)24 b(example,)h
Fj(a)g(+)f(b)g Fn(is)f(the)i(sum)e(of)i(the)f(values)0 3435
y(of)i(the)g(variables)e Fj(a)g Fn(and)h Fj(b)p Fn(.)125 3727
y(Several)j(operators)i(are)d(neither)h(unary)f(nor)h(binary)-10
b(.)41 b(The)27 b(message)h(operator)i(\()p Fj(.)p Fn(\))d(acts)h(on)g(a)f
(value)0 3851 y(on)c(the)g(left)h(but)e(a)g(message)h(name)f(and)h(an)e
(argument)i(list)f(on)h(the)g(right)g(\(see)h(Section)g(3.6.10)d([Sending)0
3976 y(Messages],)43 b(page)38 b(29\).)75 b(The)38 b(index)g(operator)j(\()p
Fj([])p Fn(\))d(uses)g(two)h(punctuation)f(marks)g(to)h(delimit)g(the)0
4100 y(beginning)27 b(and)h(end)h(of)h(the)f(offset)i(\(see)f(Section)h
(3.6.3)d([Lists],)i(page)f(20\).)47 b(The)28 b(conditional)h(operator)0
4225 y(\()p Fj(?|)p Fn(\))c(operates)i(on)e(three)i(data)e(values)f(\(see)j
(Section)f(3.6.8.4)e([Conditional)g(Operators],)k(page)d(27\).)0
4799 y Fg(3.6.8.1)54 b(Precedence)125 5091 y Fn(It)33 b(is)f(easy)h(to)h
(write)g(an)e(expression)i(whose)f(order)h(of)g(evaluation)e(is)g(unclear)-7
b(.)59 b(For)33 b(instance,)i(the)0 5215 y(expression)18 b
Fj(a)24 b(-)h(b)g(+)g(c)16 b Fn(could)h(be)f(parsed)h(as)g
Fj(\(a)24 b(-)h(b\))f(+)h(c)16 b Fn(or)h(as)f Fj(a)25 b(-)g(\(b)f(+)h(c\))p
Fn(.)32 b(T)-8 b(o)16 b(resolve)i(these)f(con\257icts,)0 5340
y(each)25 b(operator)j(has)c(two)i(properties:)38 b Fi(precedence)27
b Fn(and)e Fi(association)p Fn(.)p eop
%%Page: 26 28
26 27 bop 0 -116 a Fn(26)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y Fi(Precedence)j Fn(determines)g(whether)f(an)f
(operator)j(binds)d(more)i(tightly)e(than)g(another)h(operator;)j(for)0
491 y(instance,)c Fj(a)f(+)f(b)h(*)g(c)g Fn(is)h(equivalent)e(to)j
Fj(a)e(+)g(\(b)f(*)h(c\))g Fn(because)h(multiplication)e(has)h(higher)g
(precedence)0 616 y(than)f(addition.)125 897 y Fi(Association)36
b Fn(determines)g(whether)f(operators)i(at)e(the)f(same)h(precedence)i(level)
e(associate)g(left)g(to)0 1021 y(right)25 b(or)h(right)e(to)i(left;)g
Fj(a)f(-)g(b)g(-)g(c)f Fn(is)h(equivalent)f(to)i Fj(\(a)e(-)h(b\))f(-)h(c)g
Fn(because)g(subtraction)g(associates)g(left)0 1146 y(to)h(right.)125
1427 y(Here)40 b(is)f(a)f(list)h(of)h(operators)i(grouped)e(by)e(precedence,)
46 b(in)38 b(order)j(from)g(highest)d(precedence)k(to)0 1551
y(lowest:)75 1832 y Fl(\017)60 b Fj(.)75 1988 y Fl(\017)g Fj([])75
2145 y Fl(\017)g Fj(!)25 b Fn(and)f(unary)g Fj(-)75 2301 y
Fl(\017)60 b Fj(*)25 b(/)g(\045)75 2458 y Fl(\017)60 b Fj(+)25
b(-)75 2614 y Fl(\017)60 b Fj(==)24 b(!=)h(>)g(>=)f(<)h(<=)75
2771 y Fl(\017)60 b Fj(in)75 2927 y Fl(\017)g Fj(&&)75 3084
y Fl(\017)g Fj(||)75 3240 y Fl(\017)g Fj(?|)125 3553 y Fn(All)15
b(operators)k(associate)e(from)h(left)f(to)g(right)g(except)h(the)f
Fj(&&)p Fn(,)h Fj(||)p Fn(,)g(and)d Fj(?|)h Fn(operators,)21
b(which)15 b(associate)0 3677 y(from)21 b(right)e(to)i(left.)35
b(Y)-10 b(ou)19 b(can)h(always)e(use)i(parentheses)h(\(`)p
Fj(\()p Fn(')e(and)g(`)p Fj(\))p Fn('\))g(to)h(specify)h(the)f(order)i(of)e
(evaluation)0 3802 y(explicitly)-10 b(.)0 4280 y Fg(3.6.8.2)54
b(Arithmetic)125 4561 y Fj(C--)34 b Fn(provides)i(seven)g(operators)h(for)g
(doing)e(arithmetic,)j(two)e(unary)e(operators)k(and)c(\256ve)i(binary)0
4685 y(operators.)i(These)24 b(operators)j(apply)d(primarily)f(to)i
(integers,)h(but)e(the)h(addition)f(operator)i(also)e(applies)0
4810 y(to)i(strings.)36 b(Using)24 b(these)i(operators)i(on)d(inappropriate)h
(data)f(is)g(an)f(error)j(of)f(type)g Fj(\304type)p Fn(.)125
5091 y(The)e(unary)g Fj(-)h Fn(operator)i(takes)f(the)f(negative)g(of)h(an)e
(integer)h(value.)35 b(The)25 b(expression)h Fj(-\(3)e(+)h(4\))f
Fn(has)0 5215 y(the)32 b(value)f Fj(-7)p Fn(.)55 b(The)32 b(unary)e
Fj(+)i Fn(operator)i(has)d(no)h(effect)i(on)e(its)g(argument,)h(and)f(is)f
(provided)j(only)d(for)0 5340 y(completeness.)p eop
%%Page: 27 29
27 28 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(27)125 366 y(The)39 b(binary)f(operator)k Fj(*)d Fn(performs)j
(multiplication)37 b(on)j(its)g(arguments.)78 b(The)39 b(expression)i
Fj(\(3)24 b(*)0 491 y(4\))33 b Fn(has)g(the)h(value)f Fj(12)p
Fn(.)60 b(The)33 b(binary)g(operators)j Fj(/)d Fn(and)g Fj(\045)g
Fn(perform)j(integer)f(division)d(and)h(modulus,)0 616 y(respectively)-10
b(,)32 b(on)d(their)h(arguments.)47 b(The)29 b(expressions)i
Fj(\(13)24 b(/)h(5\))j Fn(and)h Fj(\(13)23 b(\045)i(5\))k Fn(have)f(the)i
(values)e Fj(2)0 740 y Fn(and)d Fj(3)f Fn(respectively)-10
b(.)125 1020 y(The)27 b(binary)g(operators)k Fj(+)c Fn(and)h
Fj(-)g Fn(perform)i(addition)e(and)f(subtraction.)44 b(The)28
b(expressions)i Fj(\(3)24 b(+)h(4\))0 1144 y Fn(and)k Fj(\(3)c(-)f(4\))30
b Fn(have)f(the)h(values)f Fj(7)h Fn(and)f Fj(-1)g Fn(respectively)-10
b(.)52 b(The)29 b(binary)g Fj(+)g Fn(operator)k(can)c(also)h(apply)f(to)0
1269 y(strings)i(and)e(lists,)j(in)e(which)g(case)h(it)f(performs)j
(concatenation;)h(the)d(expression)g Fj(\("foo")23 b(+)i("bar"\))0
1393 y Fn(has)33 b(the)h(value)f Fj("foobar")p Fn(,)g(and)g(the)h(expression)
h Fj(\(["foo",)21 b("bar"])i(+)i(["baz"]\))30 b Fn(has)j(the)h(value)0
1518 y Fj(["foo",)22 b("bar",)h("baz"])p Fn(.)0 1983 y Fg(3.6.8.3)54
b(Logic)125 2262 y Fj(C--)27 b Fn(provides)i(a)g(number)e(of)j(relational)d
(and)h(logical)g(operators.)48 b(These)28 b(operators)j(are)e(primarily)0
2387 y(useful)36 b(for)i(expressing)f(conditions,)j(since)c(they)h(return)g
(either)h(true)f(or)h(false,)h(represented)h(by)c(the)0 2511
y(integers)26 b Fj(1)f Fn(and)f Fj(0)p Fn(.)125 2791 y(The)i
Fj(==)f Fn(and)h Fj(!=)f Fn(operators)k(test)e(for)h(equality)d(and)g
(inequality)-10 b(,)25 b(respectively)-10 b(,)28 b(of)f(their)g(arguments.)0
2916 y(T)-6 b(wo)23 b(pieces)j(of)e(data)g(are)g(equal)f(if)h(they)g(have)g
(the)g(same)g(type)h(and)e(contain)h(the)g(same)g(value.)34
b(Equality)0 3040 y(of)c(strings)e(is)h(not)g(case-sensitive,)i(but)d
(equality)g(of)i(symbols)e(is,)i(so)f Fj(\("foo")23 b(==)h("fOo"\))i
Fn(is)j(true,)i(but)0 3165 y Fj(\('car)23 b(==)h('CAr\))f Fn(is)i(false.)36
b(Lists)25 b(are)h(equal)e(if)h(all)f(of)i(their)g(elements)g(are)f(equal.)
125 3444 y(The)40 b Fj(<)p Fn(,)45 b Fj(<=)p Fn(,)g Fj(>=)p
Fn(,)f(and)d Fj(>)f Fn(operators)k(test)e(whether)g(their)f(left-hand)g
(arguments)g(are)g(less)h(than,)0 3569 y(less)31 b(than)f(or)i(equal)e(to,)k
(greater)e(than)e(or)i(equal)e(to,)j(or)f(greater)h(than)d(their)h
(right-hand)f(arguments,)0 3693 y(respectively)-10 b(.)62 b(Arguments)33
b(to)i(these)f(operators)i(must)e(both)f(be)h(of)g(the)g(same)g(type,)i(and)d
(must)h(be)f(of)0 3818 y(integer)-7 b(,)26 b(string,)e(or)h(dbref)g(type.)36
b(String)24 b(comparison)h(is)f(not)g(case-sensitive,)i(so)e
Fj(\("fooa")e(<)j("fooB"\))0 3942 y Fn(is)g(true,)h(even)g(though)e(the)i
(ASCII)f(value)f(of)i(`)p Fj(a)p Fn(')e(is)h(greater)i(than)d(that)h(of)h(`)p
Fj(B)p Fn('.)125 4222 y(The)39 b(unary)f Fj(!)h Fn(operator)i(tests)g
(whether)f(its)f(argument)g(is)g(false,)44 b(thus)39 b(acting)f(as)h(a)g
(logical)g(not)0 4346 y(operation.)0 4811 y Fg(3.6.8.4)54 b(Conditional)30
b(Operators)125 5091 y Fn(The)d Fj(||)f Fn(and)h Fj(&&)g Fn(operators)j(act)d
(as)h(logical)e(or)j(and)d(and)h(operators,)k(respectively)-10
b(.)44 b(The)27 b(expression)0 5215 y Fj(\(a)d(||)h(b\))35
b Fn(has)g(the)h(value)f(of)h Fj(a)g Fn(if)g Fj(a)f Fn(is)h(true,)j(or)e(the)
f(value)f(of)i Fj(b)e Fn(if)h Fj(a)f Fn(is)h(false.)67 b(The)36
b(expression)h Fj(\(a)0 5340 y(&&)24 b(b\))31 b Fn(has)f(the)h(value)g(of)g
Fj(a)g Fn(if)g Fj(a)g Fn(is)g(false,)h(and)f(the)g(value)f(of)i
Fj(b)f Fn(if)g Fj(a)g Fn(is)g(true.)53 b Fj(C--)p Fn(')m(s)30
b(logical)g(operators)p eop
%%Page: 28 30
28 29 bop 0 -116 a Fn(28)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y(are)f Fi(short-circuit)i(operators)p Fn(,)h(meaning)22
b(that)h(the)h(right-hand)f(argument)g(is)g(not)h(evaluated)f(if)h(the)g
(left-)0 491 y(hand)f(argument)h(is)g(suf\256cient)h(to)g(determine)h(the)f
(value)e(of)i(the)g(expression.)37 b(This)23 b(is)h(important)h(if)g(the)0
616 y(right-hand)f(argument)h(has)f(side-effects)k(or)f(could)e(cause)g(an)g
(error)-7 b(.)125 904 y(The)24 b Fj(?|)h Fn(operator)i(is)e(a)g(trinary)g
(operator)-7 b(,)28 b(with)d(the)g(following)g(syntax:)240
1167 y Fi(condition)55 b Fj(?)f Fi(true-expr)j Fj(|)d Fi(false-expr)0
1456 y Fn(The)37 b(result)g(of)h(this)f(expression)h(is)f(the)g(result)h(of)f
Fi(true-expr)i Fn(if)e Fi(condition)h Fn(is)e(true,)41 b(or)d(the)g(result)f
(of)0 1580 y Fi(false-expr)g Fn(if)c Fi(condition)h Fn(is)f(false.)60
b(See)35 b(Section)g(3.6.1)d([Data)h(T)-5 b(ypes],)37 b(page)c(18)g(for)i
(the)e(de\256nition)g(of)0 1705 y(truth)25 b(for)i Fj(C--)d
Fn(data.)0 2250 y Fg(3.6.9)54 b(Calling)31 b(Functions)125
2539 y Fn(A)e Fj(C--)g Fn(method)i(can)f(call)g(a)g(built-in)e(function)i
(using)f(a)h Fi(function)g(call)i(expression)p Fn(,)i(which)29
b(has)h(the)0 2663 y(following)24 b(syntax:)240 2927 y Fi(function-name)p
Fj(\()p Fi(arg1)p Fj(,)54 b Fi(arg2)p Fj(,)g Fi(...)p Fj(\))125
3215 y Fi(function-name)35 b Fn(is)g(an)f(identi\256er)i(naming)d(the)j
(function,)h(and)e Fi(arg1)p Fn(,)j Fi(arg2)p Fn(,)g Fi(...)66
b Fn(are)36 b(expressions.)0 3339 y(There)30 b(do)g(not)g(have)f(to)h(be)f
(any)g(arguments,)h(but)f(you)g(must)h(include)e(the)i(parentheses)h(even)e
(if)h(there)0 3464 y(are)c(no)f(arguments.)35 b(The)25 b(arguments)g(are)g
(evaluated)g(from)h(left)g(to)h(right.)125 3752 y(As)21 b(an)h(example,)h
(the)f Fj(pad\(\))e Fn(function)i(pads)g(a)g(string)g(argument)f(with)g
(spaces)i(to)g(a)f(certain)g(length.)0 3877 y(The)j(following)f(expression)j
(has)d(the)i(value)e Fj("foo)g(")p Fn(:)240 4140 y Fj(pad\("foo",)50
b(6\);)125 4429 y Fn(Coldmud')m(s)19 b(built-in)h(functions)h(allow)f(you)h
(to)h(perform)h(string)e(and)f(list)h(operations,)i(modify)f(and)e(re-)0
4553 y(trieve)j(information)e(from)i(the)f(current)h(object,)h(perform)g
(administrative)d(tasks,)i(among)e(other)i(things.)0 4678 y(For)j
(descriptions)g(of)g(the)g(available)d(functions,)i(see)h(Chapter)g(5)e
([Function)h(Descriptions],)i(page)e(35.)125 4966 y(For)30
b(various)f(reasons,)j(functions)d(can)h(throw)g(errors.)51
b(For)30 b(instance,)h(calling)d(a)h(function)h(with)f(an)0
5091 y(incorrect)34 b(number)e(of)h(arguments)f(causes)h(a)f
Fj(\304numargs)d Fn(error)-7 b(,)36 b(and)c(calling)f(a)h(function)g(with)f
(argu-)0 5215 y(ments)24 b(of)g(incorrect)i(type)e(causes)g(a)f
Fj(\304type)f Fn(error)-7 b(.)37 b(See)25 b(Chapter)f(4)f([Errors],)j(page)e
(33)f(for)h(information)0 5340 y(on)h(how)g(to)h(handle)f(errors.)p
eop
%%Page: 29 31
29 30 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(29)0 366 y Fg(3.6.10)54 b(Sending)29 b(Messages)125 646 y
Fn(If)c(you)h(want)e(to)i(retrieve)i(information)d(from)h(or)h(modify)e(an)g
(object)h(other)h(than)d(the)i(current)h(object,)0 771 y(you)g(can)f(do)h(so)
h(by)e(sending)g(it)h(a)f(message.)41 b(Y)-10 b(ou)26 b(can)h(do)g(this)f
(with)h(a)f Fi(message)i(expression)p Fn(,)i(which)c(has)0
895 y(the)g(following)e(syntax:)240 1150 y Fi(receiver)p Fj(.)p
Fi(message)p Fj(\()p Fi(arg1)p Fj(,)57 b Fi(arg2)p Fj(,)d Fi(...)p
Fj(\))0 1430 y Fn(Y)-10 b(ou)20 b(may)f(omit)i Fi(receiver)p
Fn(,)j(in)19 b(which)g(case)i(it)f(is)g(assumed)g(to)h(be)f(the)g(current)i
(object.)35 b(Otherwise,)21 b Fi(receiver)0 1555 y Fn(must)26
b(be)h(an)e(expression)j(of)f(dbref)g(or)g(frob)g(type,)h(and)e
Fi(message)h Fn(an)f(identi\256er)g(giving)f(the)i(name)f(of)h(the)0
1679 y(message.)68 b Fi(arg1)p Fn(,)39 b Fi(arg2)p Fn(,)g Fi(...)68
b Fn(are)36 b(the)h(arguments)e(to)i(be)f(sent)g(with)g(the)g(message.)68
b(The)35 b(arguments)0 1804 y(are)26 b(evaluated)f(from)i(left)f(to)h(right.)
36 b(Y)-10 b(ou)25 b(must)h(include)f(the)h(parentheses)h(around)e(the)h
(argument)f(list,)0 1928 y(even)j(if)g(there)h(are)g(no)f(arguments.)43
b(The)28 b(result)g(of)h(a)f(message)g(expression)h(is)f(the)g(value)f
(returned)j(by)0 2053 y Fi(receiver)p Fn(')m(s)d(method)f(for)h(the)e
(message)h Fi(message)p Fn(.)125 2333 y(If)39 b Fi(receiver)j
Fn(is)e(a)f(frob,)k(then)d(the)g(message)f(is)h(sent)g(to)g(the)g(frob')m(s)f
(class)g(object,)45 b(with)38 b(the)i(frob')m(s)0 2457 y(representation)28
b(inserted)g(as)e(the)h(\256rst)g(argument.)39 b(If)27 b Fi(receiver)i
Fn(is)e(a)f(dbref,)i(then)e(the)h(message)g(is)g(sent)0 2582
y(to)f(the)g(object)g(with)f(that)g(dbref.)125 2862 y(If)d
Fi(receiver)i Fn(is)e(not)h(an)e(object)i(or)g(frob,)g(then)f(the)h
(interpreter)h(throws)f(a)e Fj(\304type)f Fn(error)-7 b(.)37
b(If)22 b Fi(receiver)j Fn(is)c(a)0 2986 y(dbref)26 b(which)f(does)h(not)g
(refer)i(to)e(an)f(existing)g(object,)i(or)f(if)g(it)f(is)g(a)h(frob)g(whose)
g(class)f(is)g(not)h(an)f(existing)0 3111 y(object,)d(then)d(the)h
(interpreter)h(throws)f(an)e Fj(\304objnf)f Fn(error)-7 b(.)36
b(If)19 b Fi(receiver)j Fn(does)f(not)e(have)g(a)g(method)h(de\256ned)0
3235 y(for)26 b Fi(message)p Fn(,)g(then)f(the)h(interpreter)h(throws)e(a)g
Fj(\304methodnf)c Fn(error)-7 b(.)37 b(See)27 b(Chapter)e(4)f([Errors],)j
(page)e(33)0 3360 y(for)h(information)f(on)h(how)f(to)h(handle)e(errors.)125
3640 y(Here)i(are)f(some)i(examples)e(of)h(message)f(expressions:)240
3912 y Fj(.tell\("I)51 b(don't)h(see)h(that)g(here."\);)240
4037 y($sys.wizards\(\))240 4161 y(loc.tell_conten)o(ts)o(\(a)o(rg)o(s[1)o
(]\))o(;)125 4432 y Fn(Y)-10 b(ou)21 b(can)g(substitute)g(an)f(arbitrary)h
(expression)i(for)f Fi(message)p Fn(,)i(by)c(enclosing)h(it)g(in)g
(parentheses.)35 b(The)0 4556 y(syntax)24 b(for)j(sending)d(an)h(arbitrary)g
(message)g(is:)240 4811 y Fi(receiver)p Fj(.\()p Fi(message-expression)p
Fj(\)\()p Fi(arg1)p Fj(,)59 b Fi(arg2)p Fj(,)54 b Fi(...)p
Fj(\))0 5091 y Fn(As)17 b(before,)k Fi(receiver)f Fn(can)c(be)i(omitted,)i
(in)d(which)f(case)i(it)f(is)g(assumed)g(to)h(be)f(the)h(current)g(object.)34
b Fi(message-)0 5215 y(expression)c Fn(must)e(be)f(an)g(expression)i(of)f
(symbol)f(type,)j(or)e(the)g(expression)h(will)d(cause)i(a)f
Fj(\304type)e Fn(error)-7 b(.)0 5340 y(Y)d(ou)25 b(must)g(include)g(the)h
(parentheses)g(around)f(the)g(argument)g(list,)g(even)h(if)f(there)i(are)e
(no)h(arguments.)p eop
%%Page: 30 32
30 31 bop 0 -116 a Fn(30)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(In)h(order)i(to)f(prevent)h(incidents)e(of)h
(in\256nite)f(recursion,)h(Coldmud)f(has)g(a)g(maximum)f(calling)f(depth)0
491 y(for)29 b(messages.)45 b(This)28 b(maximum)e(depth)j(is)f
Fj(128)f Fn(method)i(calls)f(in)f(the)i(current)g(version.)45
b(If)29 b(sending)e(a)0 616 y(message)d(would)f(exceed)i(the)f(maximum)e
(calling)f(depth,)k(the)f(interpreter)i(raises)e(a)f Fj(\304maxdepth)c
Fn(error)-7 b(.)0 1067 y Fg(3.6.11)54 b(Passing)29 b(Messages)125
1345 y Fn(A)e(method)h(can)f(pass)g(control)i(of)f(a)f(message)h(to)g(a)f
(different)i(ancestor)f(of)h(the)e(current)i(object)f(using)0
1469 y(a)d Fi(pass)h(expression)p Fn(,)i(which)d(has)f(the)i(following)e
(syntax:)240 1722 y Fj(pass\()p Fi(arg1)p Fj(,)52 b Fi(arg2)p
Fj(,)i Fi(...)p Fj(\))0 2000 y Fn(The)27 b(arguments)h(are)g(evaluated)f
(from)i(left)g(to)f(right.)43 b(The)28 b(result)g(of)h(this)e(expression)i
(is)f(the)g(result)g(of)0 2125 y(calling)c(the)i(\252next\272)g(method)g
(with)f(the)h(arguments)f Fi(arg1)p Fn(,)h Fi(arg2)p Fn(,)f
Fi(...)p Fn(.)37 b(The)26 b(\252next\272)g(method)g(is)g(de\256ned)f(as)0
2249 y(the)j(method)g(which)e(would)h(be)h(called)f(if)g(the)h(current)g
(method,)h(and)e(any)f(other)j(methods)f(which)f(have)0 2374
y(already)35 b(passed)g(control)i(of)f(the)f(message,)j(were)e(not)g
(de\256ned.)66 b(This)34 b(method)i(may)e(not)h(be)h(de\256ned)0
2499 y(on)28 b(an)f(ancestor)j(of)f(the)f(current)i(object;)h(you)d(should,)g
(in)g(general,)h(not)f(depend)h(on)g(a)e(speci\256c)i(method)0
2623 y(being)24 b(called)h(when)g(you)g(use)g(a)g(pass)g(expression.)125
2901 y(The)f(called)i(method)g(sees)g(the)g(same)f(current)h(object,)h
(sender)-7 b(,)27 b(and)d(caller)h(as)g(the)h(current)g(method.)125
3179 y(The)c(pass)h(expression)h(can)e(cause)h(a)f Fj(\304methodnf)d
Fn(errors)24 b(if)f(the)g(called)g(method)h(does)f(not)h(exist.)35
b(See)0 3304 y(Chapter)25 b(4)g([Errors],)j(page)d(33)f(for)j(information)d
(on)i(how)f(to)h(handle)e(errors.)0 3755 y Fg(3.6.12)54 b(Error)n(-Handling)
29 b(Expressions)125 4033 y Fj(C--)h Fn(provides)k(two)f(kinds)e(of)i
(expressions)h(for)f(handling)d(errors)k(in)e(expressions.)58
b(These)32 b(are)h(the)0 4157 y Fi(critical)27 b(expression)h
Fn(and)d(the)h Fi(propagation)g(expression)p Fn(.)125 4435
y(The)d Fi(critical)j(expression)h Fn(allows)d(you)f(to)i(ignore)g(errors)h
(which)d(occur)i(inside)f(an)f(expression.)36 b(It)25 b(has)0
4560 y(the)h(following)e(syntax:)240 4813 y Fj(\(|)54 b(expression)c(|\))125
5091 y Fn(If)30 b(an)g(error)i(occurs)g(in)e Fi(expression)p
Fn(,)35 b(then)30 b(the)h(interpreter)i(will)c(stop)j(evaluating)c
Fi(expression)p Fn(,)35 b(and)0 5215 y(continue)20 b(to)g(execute)h(the)f
(current)h(method)f(as)g(if)f(it)h(had)f(succeeded)j(evaluating)17
b Fi(expression)p Fn(.)37 b(The)19 b(value)0 5340 y(of)26 b
Fi(expression)i Fn(will)c(be)h(the)h(error)h(code)g(for)f(the)g(error)h
(condition)f(which)e(occurred.)p eop
%%Page: 31 33
31 32 bop 0 -116 a Fn(Chapter)25 b(3:)36 b(De\256ning)23 b(methods)2576
b(31)125 366 y(The)32 b Fi(propagation)i(expression)i Fn(allows)c(you)g(to)i
(indicate)e(that)h(any)e(errors)k(which)d(occur)i(inside)e(an)0
491 y(expression)26 b(are)g(the)g(responsibility)e(of)i(the)g(calling)d
(routine.)36 b(It)26 b(has)f(the)g(following)g(syntax:)240
740 y Fj(\(>)54 b(expression)c(<\))125 1014 y Fn(If)27 b(an)f(unhandled)f
(error)k(occurs)f(in)e Fi(expression)p Fn(,)k(then)d(it)g(will)e(propagate)j
(to)g(the)f(calling)e(routine)i(as)0 1139 y(itself,)f(instead)f(of)h(as)f
Fj(\304methoderr)p Fn(.)125 1413 y(Critical)i(expressions)i(override)h(the)e
(behavior)g(of)h(catch)f(statements,)i(so)f(that)f(errors)i(which)d(occur)0
1537 y(within)19 b(critical)h(expressions)h(do)g(not)g(trigger)g(catch)g
(error)h(handlers.)33 b(Propagation)20 b(expressions)i(do)f(not)0
1662 y(override)35 b(critical)d(expressions)i(or)g(catch)f(statements,)j
(however;)i(they)33 b(do)h(not)f(prevent)h(errors)h(from)0
1786 y(being)24 b(caught,)h(but)g(only)f(determine)j(how)e(errors)i
(propagate)g(if)e(they)g(are)h(not)f(caught.)125 2060 y(For)g(more)i
(information)e(on)g(how)g Fj(C--)f Fn(handles)g(errors,)k(see)e(Chapter)f(4)g
([Errors],)i(page)f(33.)0 2475 y Fg(3.6.13)54 b(Splicing)125
2749 y Fn(Whenever)25 b(you)g(are)g(writing)g(an)f(argument)g(list)h(or)h(a)e
(list)h(constructor)i(expression,)f(you)f(can)g(splice)0 2874
y(a)36 b(list)g(value)g(into)g(the)h(sequence)g(of)g(expressions)h(by)d
(prepending)i(a)f(list)g(expression)i(with)e(`)p Fj(@)p Fn('.)68
b(For)0 2998 y(instance,)25 b(the)h(following)e(method)i(returns)g
Fj(['foo,)d(4,)h(5,)h(6,)f('quux])p Fn(:)240 3265 y Fj(var)53
b(a;)240 3514 y(a)h(=)g([4,)f(5,)h(6];)240 3639 y(return)e(['foo,)g(@a,)h
('quux];)125 3903 y Fn(Y)-10 b(ou)25 b(use)g(the)h(splicing)e(operator)j(to)f
(pass)g(a)e(message)i(along)e(with)h(all)f(of)i(its)f(arguments:)240
4152 y Fj(pass\(@args\);)125 4426 y Fn(The)19 b(splicing)g(operator)j(is)e
(not)g(listed)g(in)f(the)i(operator)h(precedence)g(list)e(\(see)h(Section)g
(3.6.8.1)e([Prece-)0 4550 y(dence],)30 b(page)e(25\).)43 b(This)27
b(is)h(because)g(it)g(is)g(meaningless)e(to)j(talk)f(about,)g(say)-10
b(,)28 b(adding)f(a)h(spliced)g(list)g(to)0 4675 y(another)e(value.)34
b(Using)25 b(the)g(splicing)f(operator)k(never)e(causes)f(an)g(ambiguity)-10
b(.)p eop
%%Page: 32 34
32 33 bop 0 -116 a Fn(32)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)p eop
%%Page: 33 35
33 34 bop 0 -116 a Fn(Chapter)25 b(4:)36 b(Errors)3044 b(33)0
366 y Fk(4)72 b(Errors)125 732 y Fn(When)32 b(something)g(goes)h(wrong)g(in)f
(a)g Fj(C--)f Fn(method,)k(the)e(interpreter)i(will)c(often)j(throw)f(an)e
(error)-7 b(.)0 857 y(Methods)37 b(can)f(also)g(throw)h(their)g(own)f(errors)
i(using)d(the)i Fj(throw\(\))c Fn(function.)69 b(An)35 b(error)k(condition)0
981 y(consists)25 b(of)h(an)e(error)j(code)f(\(the)g Fi(type)f
Fn(of)h(the)f(error\))i(and)d(a)h(string)f(describing)h(the)g(error)-7
b(.)38 b(Methods)26 b(can)0 1106 y(recognize)32 b(errors)i(using)c(the)i
(error)i(codes;)i(the)c(string)f(appears,)j(along)d(with)g(the)h(error)h
(code,)i(in)c(the)0 1230 y(traceback)26 b(obtainable)d(through)i(the)h
Fj(traceback\(\))20 b Fn(function)25 b(inside)g(a)g(catch)g(handler)-7
b(.)125 1504 y(When)19 b(the)i(interpreter)i(throws)e(an)e(error)-7
b(,)24 b(it)c(checks)h(to)g(see)g(how)f(the)h(current)g(method)g(handles)e
(that)0 1629 y(error)35 b(type.)61 b(If)34 b(the)g(error)h(occured)g(in)e(a)g
(critical)g(expression)i(\(see)g(Section)f(3.6.12)e([Error)n(-Handling)0
1753 y(Expressions],)46 b(page)41 b(30\),)k(then)c(the)g(interpreter)j(will)c
(cease)i(evaluating)d(the)j(critical)f(expression.)0 1878 y(Processing)30
b(of)g(the)g(method)g(will)e(continue)h(as)g(if)h(the)g(interpreter)i(had)c
(completed)k(evaluation)27 b(of)k(the)0 2003 y(critical)c(expression.)41
b(The)26 b(value)g(of)h(the)g(critical)g(expression)g(will)f(be)g(the)h
(error)i(code)f(associated)g(with)0 2127 y(the)e(thrown)g(error)-7
b(.)39 b(In)25 b(this)g(case,)i(the)f(traceback)g(is)f(not)h(accessible)g
(from)h Fj(traceback\(\))p Fn(;)21 b(in)k(order)i(to)0 2252
y(get)f(a)f(traceback,)h(you)f(must)g(use)g(a)g(catch)h(statement.)125
2526 y(If)h(the)g(error)i(did)f(not)f(occur)h(in)f(a)f(critical)h
(expression,)i(but)e(occurred)i(in)d(a)h(catch)g(statement)h(which)0
2650 y(catches)c(the)f(error)i(code)g(\(either)f(because)f(it)g(is)g(a)g
Fj(catch)g(all)e Fn(statement)k(or)e(because)h(it)f(lists)g(the)g(error)0
2775 y(code\320see)31 b(Section)f(3.5)e([Error)n(-Handling)h(Statements],)j
(page)c(16\),)i(then)f(processing)g(of)h(the)f(method)0 2899
y(jumps)i(to)h(the)g(error)i(handler)-7 b(,)33 b(if)e(one)h(was)f(provided,)j
(or)f(to)f(the)g(end)g(of)g(the)g(catch)f(statement)i(if)e(not.)0
3024 y(Inside)c(an)f(error)k(handler)-7 b(,)27 b(you)g(can)g(use)g(the)h
Fj(error\(\))p Fn(,)d Fj(traceback\(\))p Fn(,)e(and)j Fj(rethrow\(\))d
Fn(functions)0 3148 y(to)h(retrieve)i(the)e(error)i(or)e(traceback)g
(associated)h(with)d(the)i(error)i(condition,)f(or)f(continue)g(propagating)0
3273 y(the)i(error)-7 b(.)125 3547 y(If)37 b(the)g(error)i(did)d(not)h(occur)
h(in)e(a)h(critical)f(expression)i(or)g(in)e(an)g(appropriate)i(catch)f
(statement,)0 3671 y(then)32 b(the)g(current)g(method)h(aborts,)h(and)d(the)h
(interpreter)i(throws)f(an)d(error)k(in)d(the)h(calling)e(method.)0
3796 y(Normally)-10 b(,)31 b(the)g(error)h(thrown)e(in)g(the)h(calling)d
(routine)j(will)e(have)g(the)i(error)h(code)g Fj(\304methoderr)p
Fn(,)c(but)0 3920 y(if)e(the)g(original)e(error)k(occurred)g(in)d(a)g
(propagation)h(expression)h(\(see)g(Section)g(3.6.12)d([Error)n(-Handling)0
4045 y(Expressions],)j(page)g(30,)f(then)g(the)g(error)j(code)f(will)c(be)j
(the)f(same)h(as)f(it)g(was)f(for)j(the)e(original)f(error)-7
b(.)41 b(A)0 4169 y(propagation)20 b(expression)i(has)d(no)h(effect)i(on)f
(how)e(an)h(error)i(is)e(handled)f(except)j(to)f(cause)f(it)g(to)h(propagate)
0 4294 y(differently)26 b(to)g(the)g(calling)d(routine.)125
4568 y(Y)-10 b(ou)26 b(can)h(throw)g(your)g(own)f(errors)j(using)d(the)h
Fj(throw\(\))d Fn(function.)40 b(This)26 b(does)i(not)f(throw)g(an)f(error)0
4692 y(in)e(the)h(current)h(method;)g(instead,)e(it)h(exits)g(the)g(current)h
(method)f(and)f(throws)h(an)f(error)j(in)d(the)h(calling)0
4817 y(method.)36 b(Thus)25 b(a)f(method)i(cannot)g(ignore)f(an)f(error)k
(which)c(it)h(threw)h(itself)g(using)d Fj(throw\(\))p Fn(.)125
5091 y(There)g(is)h(one)g(case)f(in)g(which)f(a)h(method)i(cannot)e(catch)g
(an)g(interpreter)n(-generated)28 b(error)-7 b(.)37 b(Methods)0
5215 y(have)22 b(a)f(limited)h(amount)g(of)h(time)g(to)g(run,)f(measured)h
(in)e Fi(ticks)p Fn(.)36 b(A)22 b(method)h(will)e(generally)g(only)h(run)g
(out)0 5340 y(of)29 b(ticks)g(if)f(it)g(gets)h(stuck)f(in)g(an)f(in\256nite)g
(loop.)45 b(If)29 b(a)f(method)h(runs)f(out)g(of)h(ticks,)h(then)e(the)g
(interpreter)p eop
%%Page: 34 36
34 35 bop 0 -116 a Fn(34)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y(will)g(throw)i(a)g Fj(\304ticks)c Fn(error)-7
b(,)30 b(which)25 b(the)i(method)h(cannot)e(catch.)40 b(This)26
b(causes)h(the)g(method)g(to)g(abort,)0 491 y(which)d(in)h(turn)g(causes)g
(the)h(interpreter)h(to)g(throw)e(a)g Fj(\304methoderr)c Fn(error)27
b(in)e(the)g(calling)f(routine.)125 765 y(Y)-10 b(ou)22 b(should)h(use)g
(critical)g(expressions)h(when)e(you)h(anticipate)f(that)h(you)g(may)f(be)h
(calling)e(a)i(buggy)e(or)0 890 y(unde\256ned)29 b(method,)j(but)d(you)g(do)i
(not)f(wish)e(your)i(own)g(method)g(to)g(bomb)f(as)h(a)f(result.)49
b(For)30 b(instance,)0 1014 y(a)38 b(method)h(which)f(announces)f(a)i(string)
f(to)h(every)h(object)f(in)f(a)g(container)h(should)f(probably)g(ignore)0
1139 y(errors)45 b(in)d(the)g(methods)i(for)g(each)e(individual)e(object)k
(which)d(handle)h(receiving)h(the)g(string.)87 b(Y)-10 b(ou)0
1263 y(should)21 b(be)h(careful)h(that)e(your)i(critical)f(expressions)h(are)
f(correct)j(code,)f(however)-7 b(,)24 b(because)e(you)g(will)f(not)0
1388 y(immediately)k(notice)h(errors)h(which)d(occur)j(while)d(the)h
(interpreter)j(is)d(evaluating)e(them.)125 1662 y(Y)-10 b(ou)22
b(should)g(use)h(catch)g(statements)g(when)f(you)h(wish)e(to)j(handle)d
(errors)k(with)d(any)f(kind)h(of)i(sophisti-)0 1786 y(cation.)41
b(The)27 b(catch)g(statement)h(is)f(much)f(more)i(powerful)g(than)e(the)i
(critical)f(expression,)h(and)f(is)g(ideal)0 1911 y(for)f(situations)f(in)f
(which)g(\256ne-grain)g(control)j(over)f(error)i(handling)22
b(is)j(required.)125 2185 y(Y)-10 b(ou)24 b(should)f(use)h(propagation)g
(expressions)i(when)d(your)h(method)h(is)f(an)f(intermediary)h(between)h(an)0
2309 y(outside)h(object)g(and)f(an)f(internal)g(feature.)37
b(For)25 b(instance,)h(a)e(method)i(which)e(checks)i(permissions)g(and)0
2434 y(calls)20 b(an)g(object)i(function)f(such)f(as)h Fj(list_method\(\))15
b Fn(is)20 b(acting)g(as)h(an)f(intermediary)-10 b(.)34 b(In)21
b(this)f(case,)j(the)0 2558 y(method)i(should)f(throw)h(the)g(same)g(errors)h
(as)e(the)h Fj(list_method\(\))19 b Fn(function,)25 b(so)g(you)f(should)g
(enclose)0 2683 y(the)i(function)f(call)f(in)h(a)f(propagation)i(expression.)
p eop
%%Page: 35 37
35 36 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(35)0 366 y Fk(5)72 b(Function)30 b(Descriptions)125 792 y
Fn(The)f(function)h(descriptions)i(are)f(arranged)f(by)f(category)-10
b(,)33 b(and)d(alphabetically)e(within)g(their)j(cate-)0 917
y(gory)-10 b(.)36 b(Y)-10 b(ou)25 b(can)g(use)g(the)h(function)f(index)g(to)h
(look)g(up)f(the)g(description)i(of)f(a)f(function)g(by)f(name.)125
1201 y(Every)d(function)h(can)f(throw)h(a)f Fj(\304numargs)d
Fn(error)24 b(if)d(passed)i(the)f(wrong)f(number)g(of)i(arguments,)f(and)0
1325 y(most)j(can)g(throw)g(a)f Fj(\304type)e Fn(error)27 b(if)e(passed)g
(arguments)f(of)i(the)f(wrong)f(type.)37 b(If)25 b(a)f(function)g(can)h
(throw)0 1450 y(any)f(other)j(type)f(of)g(error)-7 b(,)28 b(it)d(will)f(be)h
(documented)i(in)d(the)i(function')m(s)e(description.)0 1992
y Fm(5.1)60 b(Data)30 b(functions)125 2276 y Fn(The)i(functions)h(described)i
(in)d(this)h(section)h(allow)f(you)g(to)h(perform)h(various)e(operations)h
(on)f(data.)0 2401 y(Operations)26 b(speci\256c)g(to)g(strings)f(or)h(lists)f
(are)h(grouped)g(in)e(their)i(own)f(sections.)0 2943 y Fm(class)240
3202 y Fj(class\()p Fi(frob)p Fj(\))125 3486 y Fn(This)j(function)h(returns)h
(the)f(class)g(of)h(a)f(frob.)48 b(See)31 b(Section)f(3.6.6)f([Frobs],)i
(page)e(23)f(for)j(details)e(on)0 3611 y(frobs.)0 4153 y Fm(todbref)240
4412 y Fj(todbref\()p Fi(number)p Fj(\))125 4697 y Fn(This)24
b(function)h(converts)h Fi(number)f Fn(to)h(a)f(dbref.)125
4981 y(Examples:)240 5240 y Fj(todbref\(0\))513 5334 y Fl(\))658
5340 y Fj(#0)p eop
%%Page: 36 38
36 37 bop 0 -116 a Fn(36)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(toerr)240 618 y Fj(toerr\()p Fi(string)p
Fj(\))125 894 y Fn(This)f(function)h(converts)i Fi(string)f
Fn(to)h(an)d(error)k(code.)38 b Fi(string)26 b Fn(can)f(be)h(any)e(string;)i
(it)g(does)g(not)g(have)f(to)0 1019 y(be)g(a)g(valid)f(identi\256er)-7
b(.)125 1295 y(Examples:)240 1546 y Fj(toerr\("foo"\))513 1640
y Fl(\))658 1646 y Fj(\304foo)0 2114 y Fm(toint)240 2365 y
Fj(toint\()p Fi(string)p Fj(\))125 2642 y Fn(This)24 b(function)i(converts)h
Fi(string)g Fn(to)f(an)f(integer)-7 b(.)39 b(If)26 b Fi(string)g
Fn(is)g(not)g(a)g(number)-7 b(,)26 b(the)g(resulting)f(integer)0
2766 y(will)f(be)h Fj(0)p Fn(.)125 3042 y(Examples:)240 3294
y Fj(toint\("67"\))513 3387 y Fl(\))658 3393 y Fj(67)240 3493
y(toint\("foo"\))513 3586 y Fl(\))658 3592 y Fj(0)0 4061 y
Fm(toliteral)240 4312 y Fj(toliteral\()p Fi(data)p Fj(\))125
4588 y Fn(This)19 b(function)i(converts)h(any)e(data)g(to)i(a)e
Fj(C--)g Fn(literal)g(or)i(constructor)h(expression)f(which,)e(when)g(read)0
4713 y(by)25 b(the)g(interpreter)-7 b(,)29 b(will)24 b(result)h(in)g(the)g
(same)h(data)e(object.)125 4989 y(Examples:)240 5240 y Fj(toliteral\([3,)49
b("foo",)i('bar,)i(#60,)f(\304none]\))513 5334 y Fl(\))658
5340 y Fj("[3,)h(\\"foo\\",)e('bar,)h(#60,)h(\304none]")p eop
%%Page: 37 39
37 38 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(37)240 366 y Fj(toliteral\(tosym)o(\(")o(fo)o(o-)o(")49 b(+)54
b(tostr\(3)d(+)j(4\)\)\))513 460 y Fl(\))658 466 y Fj("tosym\(\\"foo-7\\)o
("\))o(")240 566 y(toliteral\(<#56,)48 b(#[['type,)i('obj],)i(['obj,)g
(#22]]>\))513 659 y Fl(\))658 665 y Fj("<#56,)g(#[['type,)e('obj],)i(['obj,)g
(#22]]>")0 1120 y Fm(tostr)240 1370 y Fj(tostr\()p Fi(data)p
Fj(\))125 1644 y Fn(This)34 b(function)h(converts)i(any)d(data)h(to)h(a)f
(string)g(representation)j(of)e(it.)66 b(For)35 b(strings,)j(the)e(string)0
1769 y(representation)f(is)e(the)g(string)g(itself;)38 b(for)d(symbols)d(and)
h(error)i(codes,)i(the)c(string)g(representation)i(is)0 1893
y(the)26 b(identi\256er)g(part)g(of)g(the)g(data)f(object)i(converted)h(to)e
(a)f(string)h(value;)f(for)h(lists)g(and)f(frobs,)h(the)g(string)0
2018 y(representations)i(are)e Fj("<list>")d Fn(and)i Fj("<frob>")e
Fn(respectively;)28 b(for)f(integers)g(and)f(dbrefs,)h Fj(tostr\(\))0
2142 y Fn(is)e(equivalent)f(to)i Fj(toliteral\(\))p Fn(.)125
2417 y(Examples:)240 2667 y Fj(tostr\(3\))458 2760 y Fl(\))604
2766 y Fj("3")240 2866 y(tostr\("foo"\))458 2960 y Fl(\))604
2966 y Fj("foo")240 3065 y(tostr\(#0\))458 3159 y Fl(\))604
3165 y Fj("#0")240 3265 y(tostr\([2,)50 b(3,)k(4]\))458 3358
y Fl(\))604 3364 y Fj("<list>")240 3464 y(tostr\('foo\))458
3557 y Fl(\))604 3563 y Fj("foo")240 3663 y(tostr\(\304methodnf)o(\))458
3757 y Fl(\))604 3763 y Fj("methodnf")240 3862 y(tostr\(<#66,)c(#[['type,)g
('obj],)i(['obj,)g(#40]]>\))458 3956 y Fl(\))604 3962 y Fj("<frob>")0
4416 y Fm(tosym)240 4666 y Fj(tosym\()p Fi(string)p Fj(\))125
4941 y Fn(This)22 b(function)i(converts)i Fi(string)e Fn(into)g(a)g(symbol.)
34 b Fi(string)25 b Fn(can)e(be)h(any)f(string;)i(it)f(does)h(not)g(have)e
(to)i(be)0 5065 y(a)g(valid)f(identi\256er)-7 b(.)125 5340
y(Examples:)p eop
%%Page: 38 40
38 39 bop 0 -116 a Fn(38)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)240 366 y Fj(tosym\("foo"\))513 460 y Fl(\))658
466 y Fj('foo)0 1205 y Fm(type)240 1486 y Fj(type\()p Fi(data)p
Fj(\))125 1792 y Fn(This)16 b(function)h(returns)h(a)f(symbol)f(giving)g(the)
h(type)i(of)f Fi(data)p Fn(.)32 b(The)17 b(return)h(value)f(is)g(one)g(of)h
Fj('integer)p Fn(,)0 1917 y Fj('string)p Fn(,)k Fj('dbref)p
Fn(,)h Fj('list)p Fn(,)g Fj('symbol)p Fn(,)g(or)j Fj('error)p
Fn(.)125 2223 y(Examples:)240 2505 y Fj(type\(5\))513 2598
y Fl(\))658 2604 y Fj('integer)240 2704 y(type\([6,)51 b('foo,)h("bar"]\))513
2797 y Fl(\))658 2803 y Fj('list)240 2903 y(type\(<#44,)e(#[['type,)g('obj],)
i(['obj,)g(#20]]>\))513 2997 y Fl(\))658 3003 y Fj('frob)0
3741 y Fm(valid)240 4023 y Fj(valid\()p Fi(data)p Fj(\))125
4329 y Fn(This)26 b(function)g(returns)i Fj(1)f Fn(if)g Fi(data)g
Fn(is)g(a)g(dbref)h(and)e(is)h(valid,)f(or)i Fj(0)f Fn(otherwise.)42
b(A)27 b(dbref)h(is)f(valid)f(if)h(it)0 4454 y(refers)g(to)f(an)f(object)h
(that)f(exists)h(in)e(the)i(database.)125 4760 y(Examples:)240
5041 y Fj(valid\(#0\))513 5135 y Fl(\))658 5141 y Fj(1)240
5240 y(valid\('foo\))513 5334 y Fl(\))658 5340 y Fj(0)p eop
%%Page: 39 41
39 40 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(39)0 366 y Fm(5.2)59 b(String)30 b(Functions)125 646 y Fn(The)19
b(functions)g(described)h(in)f(this)g(section)h(allow)e(you)i(to)g(perform)h
(operations)f(on)g(strings.)33 b(All)19 b(of)h(the)0 770 y(functions)27
b(described)h(in)e(this)h(section)h(are)f(case-insensitive)g(except)i(for)f
Fj(strcmp\(\))23 b Fn(and,)k(if)g(speci\256ed,)0 895 y Fj(match_regexp\(\))p
Fn(.)0 1390 y Fm(crypt)240 1645 y Fj(crypt\()p Fi(string)p
Fj(\))240 1744 y(crypt\()p Fi(string)p Fj(,)52 b Fi(salt)p
Fj(\))125 2023 y Fn(This)36 b(function)i(performs)h(one-way)f(encryption)g
(on)g Fi(string)p Fn(,)j(using)36 b(the)i(host)h(system')m(s)e
Fj(crypt\(\))0 2148 y Fn(library)24 b(routine.)36 b(If)26 b
Fi(salt)g Fn(is)f(speci\256ed,)i(then)e(it)g(must)g(be)h(a)e(two-character)j
(string;)f(otherwise,)g(a)f(salt)g(is)0 2273 y(chosen)19 b(randomly)-10
b(.)33 b(The)18 b(return)h(value)e(of)j Fj(crypt\(\))15 b Fn(is)j(the)h
(encrypted)h(string;)h(the)e(\256rst)g(two)g(characters)0 2397
y(of)26 b(the)g(encrypted)h(string)e(are)g(the)h(salt)f(used.)125
2676 y(The)d(encryption)i(performed)h(by)d(this)g(function)h(has)f(the)h
(property)i(that)e(it)g(is)f(very)h(dif\256cult)g(to)g(\256nd)f(a)0
2801 y(string)k(which)f(will)g(produce)j(a)d(given)h(result;)h(however)-7
b(,)28 b(a)e(given)f(string)h(and)g(a)f(given)h(salt)g(will)f(always)0
2925 y(yield)g(the)h(same)f(encrypted)i(string.)125 3205 y(Examples:)240
3459 y Fj(crypt\("foo",)49 b("ab"\))513 3552 y Fl(\))658 3558
y Fj("abQ9KY.KfrYrc")0 4054 y Fm(explode)240 4308 y Fj(explode\()p
Fi(string)p Fj(\))240 4408 y(explode\()p Fi(string)p Fj(,)i
Fi(separator)p Fj(,)56 b([)p Fi(want-blanks)p Fj(]\))125 4687
y Fn(This)24 b(function)i(returns)g(a)f(list)h(of)g(the)g(words)h(in)e
Fi(string)p Fn(.)37 b(If)26 b(the)g(string)f Fi(separator)k
Fn(is)c(speci\256ed,)i(then)0 4812 y(it)34 b(is)f(used)h(as)f(the)h(word)h
(separator;)k(otherwise)c(a)e(space)i(\()p Fj(")25 b(")p Fn(\))33
b(is)h(used.)61 b(If)34 b(the)g(optional)g(argument)0 4936
y Fi(want-blanks)18 b Fn(is)h(speci\256ed)g(and)f(is)h(true,)i
Fj(explode\(\))15 b Fn(will)i(include)h(zero-length)i(words)g(in)e(the)h
(returned)0 5061 y(list;)25 b(otherwise,)i(it)e(will)f(not.)125
5340 y(Examples:)p eop
%%Page: 40 42
40 41 bop 0 -116 a Fn(40)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)240 366 y Fj(explode\(")50 b(foo)108 b(bar)53 b(baz"\))513
460 y Fl(\))658 466 y Fj(["foo",)f("bar",)f("baz"])240 566
y(explode\("foo:ba)o(r:)o(ba)o(z")o(,)e(":"\))513 659 y Fl(\))658
665 y Fj(["foo",)j("bar",)f("baz"])0 1111 y Fm(lowercase)240
1360 y Fj(lowercase\()p Fi(string)p Fj(\))125 1634 y Fn(This)16
b(function)g(returns)i(the)g(result)f(of)h(changing)d(each)i(uppercase)h
(character)g(in)e Fi(string)i Fn(to)g(lowercase.)240 1883 y
Fj(lowercase\("fOOB)o(Ar)48 b(23"\))513 1977 y Fl(\))658 1983
y Fj("foobar)k(23")0 2429 y Fm(match)p 394 2429 36 6 v 44 w(begin)240
2678 y Fj(match_begin\()p Fi(string)p Fj(,)d Fi(search)p Fj(\))240
2777 y(match_begin\()p Fi(string)p Fj(,)g Fi(search)p Fj(,)55
b Fi(separator)p Fj(\))125 3051 y Fn(This)23 b(function)i(looks)h(for)g(the)f
(string)g Fi(search)h Fn(at)f(the)h(beginning)c(of)k(each)f(word)h(in)e
Fi(string)p Fn(.)36 b(The)24 b(word)0 3176 y(separator)e(is)f(given)g(by)f
(the)h(string)g Fi(separator)j Fn(if)d(it)g(is)g(speci\256ed;)i(otherwise,)h
(a)c(space)i(\()p Fj(")j(")p Fn(\))c(is)g(used.)34 b(The)0
3300 y(return)26 b(value)e(of)i Fj(match_begin\(\))19 b Fn(is)25
b Fj(1)f Fn(if)h Fi(search)h Fn(was)f(found)g(at)g(the)g(beginning)e(of)j(a)e
(word)i(in)e Fi(string)p Fn(,)0 3425 y(or)i Fj(0)f Fn(if)g(not.)125
3699 y(Examples:)240 3948 y Fj(match_begin\("fo)o(o:)o(ba)o(r:)o(baz)o(",)48
b("fo",)k(":"\))513 4041 y Fl(\))658 4047 y Fj(1)240 4147 y(match_begin\("fo)
o(o)c(bar)53 b(baz",)g("ar"\))513 4241 y Fl(\))658 4247 y Fj(0)0
4692 y Fm(match)p 394 4692 V 44 w(pattern)240 4941 y Fj(match_pattern\()p
Fi(pattern)p Fj(,)48 b Fi(string)p Fj(\))125 5215 y Fn(This)28
b(function)h(matches)h(the)g(wildcard)f(pattern)h Fi(pattern)h
Fn(against)d Fi(string)p Fn(.)49 b(A)29 b(wildcard)g(pattern)h(is)0
5340 y(a)e(string)h(with)f(asterixes)h(\(`)p Fj(*)p Fn('\))f(signifying)f
(wildcards.)45 b(A)29 b(regular)f(character)i(matches)e(itself,)j(while)c(a)p
eop
%%Page: 41 43
41 42 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(41)0 366 y(wildcard)18 b(matches)h(any)e(number)h(of)h(arbitrary)f
(characters.)35 b(The)18 b(return)h(value)f(of)h Fj(match_pattern\()o(\))0
491 y Fn(is)28 b(a)f(list)h(of)g(the)g(substrings)f(of)i Fi(string)f
Fn(which)f(matched)h(the)g(wildcards)g(in)f Fi(pattern)p Fn(,)i(or)g
Fj(0)e Fn(if)h(the)g(match)0 616 y(fails.)125 900 y Fj(match_pattern\()o(\))
39 b Fn(allows)44 b(you)g(to)i(do)g(simple)e(character)n(-based)j(matching.)
93 b(For)45 b(matching)0 1025 y(against)24 b(command)h(formats,)h(however)-7
b(,)27 b(you)e(should)g(use)g(the)h Fj(match_template)o(\(\))19
b Fn(function.)125 1309 y(Examples:)240 1569 y Fj(match_pattern\(")o(*")o(,)
48 b("foobar"\))513 1663 y Fl(\))658 1669 y Fj(["foobar"])240
1768 y(match_pattern\(")o(fo)o(o)g(*)54 b(bar)g(*)g(baz",)e("foo)h(quux)f
(bar)i(quuux)e(baz"\))513 1862 y Fl(\))658 1868 y Fj(["quux",)f("quuux"])240
1968 y(match_pattern\(")o(fo)o(o)d(*)54 b(bar",)f("baz"\))513
2061 y Fl(\))658 2067 y Fj(0)0 2611 y Fm(match)p 394 2611 36
6 v 44 w(regexp)240 2871 y Fj(match_regexp\()p Fi(regexp)p
Fj(,)d Fi(string)p Fj(,)k([)p Fi(case)p 1914 2871 28 5 v 34
w(matters)p Fj(]\))125 3155 y Fn(This)35 b(function)i(matches)g(the)g
(regular)g(expression)h Fi(regexp)p Fn(,)j(a)c(string,against)e(the)j(string)
e Fi(string)p Fn(.)0 3280 y(If)41 b Fi(case)p 285 3280 V 34
w(matters)i Fn(is)d(speci\256ed)i(and)f(is)g(true,)46 b(the)41
b(match)g(is)g(case-sensitive;)50 b(otherwise,)c(it)41 b(is)g(case-)0
3405 y(insensitive.)60 b(If)34 b(the)h(match)e(succeeds,)38
b Fj(match_regexp\(\))27 b Fn(returns)35 b(a)e(ten-element)i(list)f(giving)e
(the)0 3529 y(substitutions)25 b(for)h(the)g(match)e(\(see)j(below\);)f
(otherwise,)g Fj(match_regexp\(\))19 b Fn(returns)26 b(0.)125
3814 y(Coldmud)h(uses)g(a)g(regular)h(expression)g(matcher)g(written)h(by)d
(Henry)i(Spencer)-7 b(.)44 b(Its)28 b(syntax)f(is)h(very)0
3938 y(similar)36 b(to)i(the)f(regular)g(expression)h(syntax)e(used)h(by)g
(Unix)f(utilities)g(like)h Fj(ed)f Fn(or)i Fj(egrep)p Fn(.)68
b(Here)38 b(is)0 4063 y(Spencer)5 b(')m(s)26 b(description)h(of)f(his)e
(regular)h(expression)i(syntax:)240 4322 y(A)j(regular)f(expression)j(is)d
(zero)i(or)g(more)g(branches,)g(separated)g(by)f(`)p Fj(|)p
Fn('.)48 b(It)31 b(matches)f(any-)240 4422 y(thing)24 b(that)h(matches)h(one)
f(of)h(the)g(branches.)240 4682 y(A)32 b(branch)f(is)g(zero)i(or)g(more)g
(pieces,)j(concatenated.)57 b(It)32 b(matches)h(a)e(match)h(for)h(the)f
(\256rst,)240 4781 y(followed)26 b(by)f(a)g(match)f(for)j(the)e(second,)i
(etc.)240 5041 y(A)38 b(piece)i(is)e(an)g(atom)h(possibly)f(followed)h(by)f
(`)p Fj(*)p Fn(',)j(`)p Fj(+)p Fn(',)g(or)e(`)p Fj(?)p Fn('.)74
b(An)38 b(atom)h(followed)g(by)f(`)p Fj(*)p Fn(')240 5141 y(matches)d(a)e
(sequence)i(of)g(0)f(or)h(more)h(matches)e(of)i(the)e(atom.)63
b(An)34 b(atom)g(followed)i(by)d(`)p Fj(+)p Fn(')240 5240 y(matches)i(a)e
(sequence)i(of)g(1)f(or)h(more)h(matches)e(of)i(the)e(atom.)63
b(An)34 b(atom)g(followed)i(by)d(`)p Fj(?)p Fn(')240 5340 y(matches)25
b(a)g(match)g(of)h(the)g(atom,)g(or)g(the)f(null)f(string.)p
eop
%%Page: 42 44
42 43 bop 0 -116 a Fn(42)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)240 366 y(An)e(atom)i(is)f(a)f(regular)h(expression)h(in)f
(parentheses)h(\(matching)e(a)h(match)g(for)h(the)f(regular)240
466 y(expression\),)j(a)d(range)h(\(see)h(below\),)f(`)p Fj(.)p
Fn(')f(\(matching)f(any)h(single)g(character\),)j(`)p Fj(\303)p
Fn(')c(\(matching)240 566 y(the)29 b(null)f(string)g(at)h(the)g(beginning)e
(of)j(the)f(input)f(string\),)i(`)p Fj($)p Fn(')e(\(matching)g(the)h(null)e
(string)240 665 y(at)41 b(the)h(end)g(of)g(the)g(input)f(string\),)46
b(a)41 b(`)p Fj(\\)p Fn(')f(followed)j(by)e(a)g(single)g(character)h
(\(matching)240 765 y(that)36 b(character\),)k(or)c(a)g(single)f(character)h
(with)f(no)h(other)h(signi\256cance)d(\(matching)h(that)240
865 y(character\).)240 1123 y(A)j(range)f(is)h(a)f(sequence)i(of)f
(characters)h(enclosed)g(in)e(`)p Fj([])p Fn('.)72 b(It)38
b(normally)f(matches)h(any)240 1223 y(single)c(character)j(from)f(the)g
(sequence.)66 b(If)35 b(the)h(sequence)g(begins)e(with)h(`)p
Fj(\303)p Fn(',)i(it)e(matches)240 1322 y(any)d(single)g(character)i(not)f
(from)h(the)f(rest)h(of)g(the)f(sequence.)59 b(If)33 b(two)h(characters)g(in)
e(the)240 1422 y(sequence)22 b(are)f(separated)i(by)d(`)p Fj(-)p
Fn(',)h(this)g(is)g(shorthand)g(for)h(the)g(full)e(list)h(of)h(ASCII)f
(characters)240 1522 y(between)31 b(them)g(\(e.g.)52 b Fj([0-9])28
b Fn(matches)j(any)e(decimal)h(digit\).)51 b(T)-8 b(o)31 b(include)f(a)g
(literal)g(`)p Fj(])p Fn(')f(in)240 1621 y(the)35 b(sequence,)i(make)d(it)g
(the)g(\256rst)h(character)g(\(following)f(a)f(possible)i(`)p
Fj(\303)p Fn('\).)61 b(T)-8 b(o)34 b(include)f(a)240 1721 y(literal)25
b(`)p Fj(-)p Fn(',)f(make)h(it)g(the)h(\256rst)g(or)g(last)f(character)-7
b(.)125 2163 y(The)29 b(substitutions)g(are)h(the)g(text)g(in)f
Fi(string)h Fn(which)f(matches)g(the)h(parenthesized)h(subexpressions)0
2288 y(in)c Fi(regexp)p Fn(.)44 b(The)28 b(\256rst)g(substitution)f(is)g(the)
h(text)h(in)e Fi(string)h Fn(which)e(matches)i(the)g(whole)g(regexp.)44
b(Thus,)0 2412 y(a)25 b(regular)h(expression)h(can)e(contain)h(no)f(more)i
(than)e(nine)g(parenthesized)i(subexpressions.)37 b(Substitu-)0
2537 y(tions)29 b(are)g(returned)h(as)f(two-element)h(lists)e
Fj([)p Fi(start)p Fj(,)e Fi(len)p Fj(])i Fn(giving)f(the)i(index)g(of)g(the)h
(matching)d(text)j(in)0 2661 y Fi(string)24 b Fn(and)g(the)g(length)f(of)i
(the)f(text.)37 b(When)23 b(the)i(substitutions)e(are)h(ambiguous,)f
(leftmost)i(`)p Fj(*)p Fn(')e(matches)0 2786 y(are)j(always)d(as)i(long)g(as)
g(possible.)125 3069 y(If)g Fi(regexp)i Fn(is)e(not)h(a)e(valid)g(regular)h
(expression,)i Fj(match_regexp\(\))19 b Fn(throws)26 b(a)f
Fj(\304regexp)d Fn(error)-7 b(.)125 3353 y(Examples:)240 3611
y Fj(match_regexp\("b)o(ar)o(",)48 b("fooBAR"\))513 3705 y
Fl(\))658 3711 y Fj([[4,)53 b(3],)g([0,)g(0],)g([0,)h(0],)f([0,)g(0],)g([0,)g
(0],)513 3810 y([0,)g(0],)g([0,)g(0],)g([0,)h(0],)f([0,)g(0],)g([0,)g(0]])240
3910 y(match_regexp\("\303)o(\([)o(\303)48 b(]+\))54 b(says,)e
(\\"\(.*\)\\"$",)d("Greg)k(says,)f(\\"Hello.\\""\))513 4004
y Fl(\))658 4010 y Fj([[1,)h(19],)g([1,)g(4],)g([13,)g(6],)g([0,)g(0],)g([0,)
g(0],)513 4109 y([0,)g(0],)g([0,)g(0],)g([0,)h(0],)f([0,)g(0],)g([0,)g(0]])
240 4209 y(match_regexp\("[)o(0-)o(9])o(+")o(,)c(")54 b(300)f(100)g(200)g
("\))513 4303 y Fl(\))658 4309 y Fj([[2,)g(3],)g([0,)g(0],)g([0,)h(0],)f([0,)
g(0],)g([0,)g(0],)513 4408 y([0,)g(0],)g([0,)g(0],)g([0,)h(0],)f([0,)g(0],)g
([0,)g(0]])240 4508 y(match_regexp\("f)o(oo)o(",)48 b("bar"\))513
4601 y Fl(\))658 4607 y Fj(0)240 4707 y(match_regexp\("f)o(oo)o(",)g("Foo",)k
(1\))513 4801 y Fl(\))658 4807 y Fj(0)0 5340 y Fm(match)p 394
5340 36 6 v 44 w(template)p eop
%%Page: 43 45
43 44 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(43)240 366 y Fj(match_template\()o Fi(template)p Fj(,)49
b Fi(string)p Fj(\))125 646 y Fn(This)37 b(function)h(matches)h(the)g
(template)g Fi(template)h Fn(against)d(the)i(command)f Fi(string)p
Fn(.)76 b(The)38 b(return)0 770 y(value)27 b(of)j Fj(match_template)o(\(\))22
b Fn(is)28 b(a)g(list)g(of)h(\256elds)g(resulting)e(from)j(the)f(template)g
(match,)g(or)g Fj(0)f Fn(if)h(the)0 895 y(match)c(fails)f(or)i(if)g
Fi(template)g Fn(is)f(an)f(invalid)g(template.)125 1174 y(A)30
b Fi(template)i Fn(is)e(a)g(sequence)h(of)h(word-patterns)g(and)e(wildcards)h
(separated)h(by)e(spaces,)j(with)d(wild-)0 1299 y(cards)17
b(never)g(occurring)g(more)h(than)d(one)i(at)g(a)f(time.)33
b(A)16 b Fi(word-pattern)i Fn(is)e(a)g(sequence)h(of)g(words)h(separated)0
1423 y(by)31 b(pipe)h(characters)g(\(`)p Fj(|)p Fn('\).)53
b(A)31 b(word)h(is)f(a)g(sequence)h(of)g(alphanumeric)e(characters,)k(with)d
(an)f(optional)0 1548 y(question)24 b(mark)f(\(`)p Fj(?)p Fn('\))g
(indicating)f(the)i(beginning)e(of)i(an)f(allowed)h(partial)f(match.)35
b(A)23 b Fi(wildcard)i Fn(is)e(either)0 1672 y(a)31 b(simple)g(wildcard,)i
(represented)h(by)d(an)f(asterix)i(\(`)p Fj(*)p Fn('\))e(or)i(a)f
Fi(coupled)h(wildcard)p Fn(,)i(represented)g(by)d(the)0 1797
y(three-character)d(sequence)d(`)p Fj(*=*)p Fn('.)125 2076
y(That)e(de\256nition)i(of)g(a)f(template)i(is)e(confusing,)h(so)g(we)g(will)
e(now)i(go)g(back)f(and)g(explain)g(each)g(compo-)0 2200 y(nent)h(of)h(a)f
(template)h(in)f(more)h(detail.)125 2480 y(A)32 b Fi(word-pattern)i
Fn(is)e(a)h(list)f(of)i(words)g(separated)g(by)e(pipe)h(characters.)60
b(A)32 b(word-pattern)j(matches)0 2604 y(any)29 b(of)h(the)h(words)f
(contained)g(in)f(it.)50 b(The)29 b(word-pattern)j Fj("look|examine")23
b Fn(matches)30 b(either)h(of)g(the)0 2729 y(words)26 b Fj("look")d
Fn(or)j Fj("examine")p Fn(.)31 b(The)25 b(word)h(separator)h(for)f(template)g
(matching)e(is)h(always)f(a)h(space.)125 3008 y(A)31 b(word)j(can)d(include)h
(a)g(question)g(mark)g(\(`)p Fj(?)p Fn('\))f(to)i(indicate)g(that)f(partial)f
(matches)i(that)f(extend)h(at)0 3132 y(least)21 b(as)g(far)h(as)f(the)h
(question)f(mark)g(are)h(okay)-10 b(.)34 b(The)21 b(word)h(pattern)g
Fj("look|ex?amine")15 b Fn(matches)21 b(any)0 3257 y(of)26
b(the)g(words)g Fj("look")p Fn(,)d Fj("ex")p Fn(,)g Fj("exa")p
Fn(,)h Fj("exam")p Fn(,)e Fj("exami")p Fn(,)h Fj("examin")p
Fn(,)f(and)i Fj("examine")p Fn(.)125 3536 y(When)k(a)g(word-pattern)i
(successfully)e(matches)h(a)f(word)h(in)e Fi(string)p Fn(,)j(it)e(results)h
(in)f(a)g Fi(\256eld)p Fn(,)h(or)g(string)0 3661 y(in)24 b(the)i(returned)h
(list.)35 b(This)24 b(\256eld)h(contains)g(the)h(word)g(which)e(matched)h
(the)h(word-pattern.)125 3940 y(A)18 b Fi(simple)i(wildcard)f
Fn(is)f(represented)j(by)d(an)g(asterix)h(\(`)p Fj(*)p Fn('\).)33
b(A)18 b(simple)g(wildcard)g(matches)h(any)f(number)0 4065
y(of)29 b(words)f(in)f Fi(string)p Fn(.)44 b(If)28 b(the)g(wildcard)g(is)f
(followed)i(by)e(a)h(word-pattern)h(in)e Fi(template)p Fn(,)j(then)e(it)g
(can)f(also)0 4189 y(match)e(a)g Fi(quoted)f(wildcard)i(match)p
Fn(.)125 4468 y(A)f(quoted)i(wildcard)f(match)g(is)g(just)g(like)g(a)f
Fj(C--)g Fn(string)h(literal:)37 b(it)27 b(begins)e(and)g(ends)i(with)e(a)h
(double)0 4593 y(quote)c(\(`)p Fj(")p Fn('\),)g(and)f(can)g(include)g(a)h
(literal)f(double)g(quote)i(or)f(backslash)e(by)h(preceding)i(the)f
(character)h(with)0 4717 y(a)g(backslash)f(\(`)p Fj(\\)p Fn('\).)34
b(If)24 b(the)g(simple)g(wildcard)f(is)g(followed)h(by)f(a)h(word-pattern,)i
(and)c(the)i(words)h(in)e Fi(string)0 4842 y Fn(that)29 b(the)g(wildcard)g
(would)g(match)g(begin)f(with)g(a)h(double)g(quote,)h(then)f(the)h(match)f
(must)g(be)g(a)f(quoted)0 4966 y(wildcard)d(match)h(or)g(the)g(match)f
(fails,)g(even)h(if)g(the)g(match)f(would)g(have)g(succeeded)j(if)e(the)g
(words)g(were)0 5091 y(not)d(treated)h(as)e(a)h(quoted)g(wildcard)f(match.)34
b(However)-7 b(,)25 b(if)d(the)h(words)h(that)e(the)h(wildcard)f(would)g
(match)0 5215 y(begin)36 b(with)g(a)h(backslash)e(followed)j(by)f(a)f(double)
h(quote,)k(then)c(the)h(backslash)d(is)i(ignored)g(and)g(the)0
5340 y(double)25 b(quote)h(and)e(the)i(text)g(following)f(it)g(are)h(treated)
h(as)d(regular)h(words.)p eop
%%Page: 44 46
44 45 bop 0 -116 a Fn(44)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(The)f(template)j Fj("*)d(bar")f Fn(matches)j(any)e(of)i
(the)g(following)e(strings:)240 636 y Fj(foo)53 b(bar)240 735
y(foo)g(baz)g(bar)240 835 y("foo)g(bar)g(\\\\)h(\\")f(baz")g(bar)240
935 y(\\"foo)f(baz)h(bar)125 1229 y Fn(Matching)21 b(against)h(a)h(simple)g
(wildcard)g(produces)i(one)e(\256eld,)h(the)g(words)g(that)f(the)g(simple)g
(wildcard)0 1353 y(matched.)52 b(If)31 b(the)g(wildcard)f(matches)h(a)f
(quoted)h(wildcard)f(match,)i(then)f(the)g(beginning)d(and)i(ending)0
1478 y(double)22 b(quotes)h(are)g(stripped)h(out)f(of)g(the)f(resulting)g
(\256eld,)h(as)f(well)g(as)g(any)g(backslashes)f(used)i(to)g(escape)0
1602 y(characters)j(inside)f(the)h(double)f(quotes.)125 1897
y(A)k Fi(coupled)h(wildcard)g Fn(is)f(represented)k(by)28 b(the)i
(three-character)i(sequence)e(`)p Fj(*=*)p Fn('.)46 b(It)30
b(matches)g(any)0 2021 y(sequence)d(of)h(words)g(containing)d(an)h(equal)g
(sign)g(\(`)p Fj(=)p Fn('\),)g(and)h(results)g(in)f(two)i(\256elds,)f(the)g
(text)h(before)h(the)0 2146 y(equal)h(sign)h(and)g(the)h(text)h(after)f(it.)
55 b(Any)31 b(spaces)h(surrounding)f(the)h(equal)f(sign)f(are)i(ignored)g
(and)f(do)0 2270 y(not)f(show)g(up)f(in)g(the)h(resulting)f(\256elds.)49
b(The)30 b(text)g(before)i(the)e(equal)e(sign)h(can)g(be)h(a)f(quoted)h
(wildcard)0 2395 y(match)h(\(as)g(before,)k(if)c(it)g(begins)f(with)h(a)g
(double)g(quote,)i(then)e(it)h(must)f(be)g(a)g(quoted)g(wildcard)g(match)0
2519 y(or)g(the)f(match)f(fails,)h(unless)f(the)h(initial)e(double)i(quote)g
(is)f(escaped)i(by)e(a)h(backslash\).)47 b(If)30 b(the)g(coupled)0
2644 y(wildcard)24 b(is)g(followed)h(by)f(a)g(word)h(pattern,)g(then)g(the)f
(text)i(after)f(the)g(equal)e(sign)g(can)h(also)g(be)h(a)e(quoted)0
2768 y(wildcard)i(match.)125 3063 y(The)19 b(coupled)h(wildcard)g(is)f(a)g
(special)h(feature)g(intended)g(for)h(parsing)e(T)n(inyMUD)e(command)j
(formats.)0 3187 y(If)26 b(possible,)f(its)h(use)f(should)g(be)g(avoided.)125
3481 y(If)g Fi(template)i Fn(is)e(invalid,)e(then)i(the)h(match)f(usually)e
(fails,)i(although)e(this)i(is)g(not)h(guaranteed.)125 3776
y(Examples:)240 4045 y Fj(match_template\()o("@)o(de)o(sc)o(?ri)o(be)48
b(*)54 b(as)f(*",)h("@descr)d(me)j(as)f(foobar"\))513 4138
y Fl(\))658 4144 y Fj(["@descr",)d("me",)i("as",)h("foobar"])240
4244 y(match_template\()o("@)o(de)o(sc)o(?ri)o(be)48 b(*)54
b(as)f(*",)h("@desc)d(\\"as)i(is\\")g(as)h(foobar"\))513 4338
y Fl(\))658 4344 y Fj(["@desc",)d("as)i(is",)g("as",)f("foobar"])240
4443 y(match_template\()o("@)o(de)o(sc)o(?ri)o(be)c(*)54 b(as)f(*",)h("@desc)
d(\\"as\\")h(is)i(as)g(foobar"\))513 4537 y Fl(\))658 4543
y Fj(0)240 4643 y(match_template\()o("@)o(de)o(sc)o(?ri)o(be)48
b(*)54 b(as)f(*",)h("@desc)d(\\\\\\"as\\")g(is)j(as)g(foobar"\))513
4736 y Fl(\))658 4742 y Fj(["@desc",)d("\\"as\\")g(is",)i("as",)f("foobar"])
240 4842 y(match_template\()o("@)o(de)o(sc)o(?ri)o(be)c(*=*",)k("@descr)f(me)
j(=foobar"\))513 4935 y Fl(\))658 4941 y Fj(["@descr",)c("me",)i("foobar"])
240 5041 y(match_template\()o("@)o(de)o(sc)o(?ri)o(be)c(*=*",)k("@desc)g
(\\"2+2=4\\"=)e(an)j(equation"\))513 5135 y Fl(\))658 5141
y Fj(["@desc",)e("2+2=4",)g("an)i(equation"])240 5240 y(match_template\()o
("l)o(?o)o(ok)o(|ex)o(?a)o(mi)o(ne)48 b(*",)53 b("look)f(at)i(rose"\))513
5334 y Fl(\))658 5340 y Fj(["look",)d("at)i(rose"])p eop
%%Page: 45 47
45 46 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(45)0 366 y Fm(pad)240 616 y Fj(pad\()p Fi(string)p Fj(,)53
b Fi(length)p Fj(\))240 716 y(pad\()p Fi(string)p Fj(,)g Fi(length)p
Fj(,)g Fi(\256ller)p Fj(\))125 990 y Fn(This)19 b(function)i(pads)f(or)i
(truncates)f Fi(string)g Fn(to)h(the)f(length)f Fi(length)p
Fn(.)33 b(If)21 b Fi(\256ller)h Fn(is)e(speci\256ed,)j(then)e(it)f(must)0
1115 y(be)25 b(a)g(single-character)g(string)g(to)h(use)f(as)g(the)g
(\256ller)g(character;)i(otherwise,)f(a)f(space)g(is)g(used.)36
b(If)25 b Fi(length)0 1239 y Fn(is)f(greater)i(than)d(the)i(length)f(of)h
Fi(string)p Fn(,)h(then)e Fi(pad)g Fn(adds)h(\256ller)f(characters)h(on)g
(the)f(right;)h(however)-7 b(,)26 b(you)0 1364 y(can)f(force)i
Fi(pad)e Fn(to)h(add)f(\256ller)g(on)h(the)f(left)h(by)f(specifying)g
Fi(length)g Fn(as)g(a)f(negative)h(number)-7 b(.)125 1639 y(Examples:)240
1888 y Fj(pad\("foo",)50 b(6\))513 1982 y Fl(\))658 1988 y
Fj("foo)162 b(")240 2088 y(pad\("foobar",)49 b(3\))513 2181
y Fl(\))658 2187 y Fj("foo")240 2287 y(pad\(tostr\(29\),)f(-4,)53
b("0"\))513 2380 y Fl(\))658 2386 y Fj("0029")0 2840 y Fm(strcmp)240
3090 y Fj(strcmp\()p Fi(string1)p Fj(,)e Fi(string2)p Fj(\))125
3365 y Fn(This)25 b(function)h(compares)i Fi(string1)f Fn(against)e
Fi(string2)i Fn(and)e(returns)j(zero)f(if)g(they)g(are)g(equal,)f(greater)0
3489 y(than)i(zero)h(if)g Fi(string1)g Fn(is)f(lexically)g(greater)i(than)d
Fi(string2)p Fn(,)j(and)e(less)h(than)f(zero)i(if)e Fi(string1)h
Fn(is)f(lexically)0 3614 y(less)e(than)e Fi(string2)p Fn(.)35
b(The)25 b(comparison)h(performed)i(by)c Fj(strcmp\(\))e Fn(is)j
(case-sensitive.)240 3864 y Fj(strcmp\("Foo",)49 b("bar"\))513
3957 y Fl(\))658 3963 y Fj(-28)240 4063 y(strcmp\("cashmir)o(",)f
("cashmiR"\))513 4156 y Fl(\))658 4162 y Fj(32)240 4262 y(strcmp\("foo",)h
("foo"\))513 4356 y Fl(\))658 4362 y Fj(0)0 4816 y Fm(strlen)240
5065 y Fj(strlen\()p Fi(string)p Fj(\))125 5340 y Fn(This)24
b(function)h(returns)h(the)f(length)g(of)h Fi(string)p Fn(.)p
eop
%%Page: 46 48
46 47 bop 0 -116 a Fn(46)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(Examples:)240 627 y Fj(length\("foo"\))513
721 y Fl(\))658 727 y Fj(3)0 1281 y Fm(strsub)240 1541 y Fj(strsub\()p
Fi(string)p Fj(,)51 b Fi(search)p Fj(,)56 b Fi(replace)p Fj(\))125
1827 y Fn(This)25 b(function)h(returns)i(the)f(result)g(of)g(replacing)f
(each)h(occurrence)h(of)g(the)f(string)f Fi(search)i Fn(in)e
Fi(string)0 1952 y Fn(with)f(the)g(string)g Fi(replace)p Fn(.)125
2237 y(Examples:)240 2498 y Fj(strsub\("foobar")o(,)48 b("bar",)k("baz"\))513
2592 y Fl(\))658 2598 y Fj("foobaz")0 3151 y Fm(substr)240
3412 y Fj(substr\()p Fi(string)p Fj(,)f Fi(start)p Fj(\))240
3512 y(substr\()p Fi(string)p Fj(,)g Fi(start)p Fj(,)k Fi(length)p
Fj(\))125 3797 y Fn(This)27 b(function)h(returns)h(a)f(substring)f(of)i
Fi(string)g Fn(beginning)d(at)i(the)h(character)g(numbered)f(by)g
Fi(start)p Fn(.)0 3922 y(If)35 b Fi(length)f Fn(is)g(speci\256ed,)k(then)d
(the)g(substring)e(has)h(that)g(length;)39 b(otherwise,)g(the)c(length)e(is)i
(given)f(by)0 4046 y Fj(\(length\()p Fi(string)p Fj(\))22 b(-)i(\()p
Fi(start)i Fj(-)f(1\)\))p Fn(.)85 b(If)42 b Fi(start)h Fn(is)f(less)g(than)f
Fj(1)p Fn(,)46 b(if)c(the)h(length)e(of)i(the)f(substring)f(is)0
4171 y(negative,)36 b(or)f(if)f(the)h(sum)e(of)i Fi(start)g
Fn(and)e Fi(length)h Fn(is)g(greater)h(than)e(one)i(more)g(than)e(the)h
(length)g(of)h(the)0 4295 y(string,)25 b(then)h Fj(substr\(\))21
b Fn(throws)26 b(a)f Fj(\304range)d Fn(error)-7 b(.)125 4581
y(Examples:)240 4842 y Fj(substr\("foobar")o(,)48 b(2,)54 b(3\))513
4935 y Fl(\))658 4941 y Fj("oob")240 5041 y(substr\("foobar")o(,)48
b(3\))513 5135 y Fl(\))658 5141 y Fj("obar")240 5240 y(substr\("foobar")o(,)g
(7\))513 5334 y Fl(\))658 5340 y Fj("")p eop
%%Page: 47 49
47 48 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(47)0 366 y Fm(uppercase)240 617 y Fj(uppercase\()p Fi(string)p
Fj(\))125 893 y Fn(This)16 b(function)g(returns)i(the)g(result)f(of)h
(changing)d(each)i(lowercase)h(character)g(in)e Fi(string)i
Fn(to)g(uppercase.)240 1144 y Fj(uppercase\("fOOB)o(Ar)48 b(23"\))513
1238 y Fl(\))658 1244 y Fj("FOOBAR)k(23")0 1708 y Fm(5.3)59
b(List)31 b(Functions)125 1984 y Fn(The)i(functions)h(described)h(in)e(this)g
(section)i(allow)e(you)h(to)g(perform)i(operations)f(on)f(list.)61
b(None)34 b(of)0 2109 y(these)29 b(functions)f(actually)e(modify)j(the)f
(lists)g(passed)h(as)e(arguments;)j(instead,)f(they)f(return)h(modi\256ed)0
2233 y(lists.)0 2698 y Fm(delete)240 2949 y Fj(delete\()p Fi(list)p
Fj(,)52 b Fi(position)p Fj(\))125 3224 y Fn(This)33 b(function)h(returns)i
(the)f(result)g(of)g(deleting)g(the)g(element)g(of)g Fi(list)h
Fn(numbered)e(by)g(the)h(integer)0 3349 y Fi(position)p Fn(.)j(If)26
b Fi(position)h Fn(is)f(less)g(than)e Fj(1)h Fn(or)i(is)e(greater)i(than)e
(the)h(length)f(of)h Fi(list)p Fn(,)h(then)e Fj(delete\(\))d
Fn(throws)0 3473 y(a)j Fj(\304range)d Fn(error)-7 b(.)125 3749
y(Examples:)240 4000 y Fj(delete\([2,)50 b(3,)k(4],)f(2\))513
4094 y Fl(\))658 4100 y Fj([2,)g(4])0 4564 y Fm(insert)240
4815 y Fj(insert\()p Fi(list)p Fj(,)f Fi(position)p Fj(,)j
Fi(data)p Fj(\))125 5091 y Fn(This)23 b(function)h(returns)h(the)g(result)g
(of)g(inserting)f Fi(data)g Fn(into)g Fi(list)i Fn(before)f(the)g(element)g
(numbered)g(by)0 5215 y(the)k(integer)g Fi(position)p Fn(.)48
b(If)29 b Fi(position)h Fn(is)e(less)h(than)f(one)h(or)h(is)e(more)i(than)e
(one)h(more)g(than)f(the)h(length)f(of)0 5340 y Fi(list)p Fn(,)e(then)g
Fj(insert\(\))21 b Fn(throws)26 b(a)f Fj(\304range)d Fn(error)-7
b(.)p eop
%%Page: 48 50
48 49 bop 0 -116 a Fn(48)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)125 366 y(Examples:)240 623 y Fj(insert\([2,)50
b(3,)k(4],)f(3,)g('foo\))513 717 y Fl(\))658 723 y Fj([2,)g(3,)h('foo,)e(4])
240 823 y(insert\(["foo",)c('bar,)k(\304none],)g(4,)h('baz\))513
916 y Fl(\))658 922 y Fj(["foo",)f('bar,)g(\304none,)g('baz])0
1441 y Fm(listlen)240 1698 y Fj(listlen\()p Fi(list)p Fj(\))125
1980 y Fn(This)24 b(function)h(returns)h(the)f(length)g(of)h
Fi(list)p Fn(.)125 2262 y(Examples:)240 2519 y Fj(length\([2,)50
b("foo",)i('bar]\))513 2613 y Fl(\))658 2619 y Fj(3)0 3138
y Fm(replace)240 3395 y Fj(replace\()p Fi(list)p Fj(,)f Fi(position)p
Fj(,)56 b Fi(data)p Fj(\))125 3676 y Fn(This)23 b(function)i(returns)h(the)f
(result)g(of)h(replacing)e(the)h(element)h(of)g Fi(list)f Fn(numbered)g(by)f
Fi(position)j Fn(with)0 3801 y Fi(data)p Fn(.)36 b(If)25 b
Fi(position)i Fn(is)e(less)g(than)g(one)g(or)i(is)d(greater)j(than)d(the)i
(length)f(of)h Fi(list)p Fn(,)g(then)f Fj(replace\(\))c Fn(throws)0
3926 y(a)k Fj(\304range)d Fn(error)-7 b(.)125 4207 y(Examples:)240
4464 y Fj(replace\([2,)50 b(3,)j(4],)g(2,)h('foo\))513 4558
y Fl(\))658 4564 y Fj([2,)f('foo,)g(4])0 5083 y Fm(setadd)240
5340 y Fj(setadd\()p Fi(list)p Fj(,)f Fi(data)p Fj(\))p eop
%%Page: 49 51
49 50 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(49)125 366 y(This)38 b(function)h(returns)h(the)g(result)g(of)g(adding)e
Fi(data)h Fn(to)i(the)e(end)h(of)g Fi(list)g Fn(if)g(it)f(was)g(not)g
(already)0 491 y(somewhere)27 b(in)d Fi(list)p Fn(.)37 b(If)25
b Fi(data)g Fn(was)g(already)g(in)f Fi(list)p Fn(,)j(then)e
Fj(setadd\(\))d Fn(returns)k Fi(list)g Fn(unmodi\256ed.)125
767 y(Examples:)240 1019 y Fj(setadd\([2,)50 b(3,)k(4],)f('foo\))513
1113 y Fl(\))658 1119 y Fj([2,)g(3,)h(4,)g('foo])240 1218 y(setadd\([2,)c(3,)
k(4],)f(3\))513 1312 y Fl(\))658 1318 y Fj([2,)g(3,)h(4])0
1789 y Fm(setremove)240 2040 y Fj(setremove\()p Fi(list)p Fj(,)c
Fi(data)p Fj(\))125 2317 y Fn(This)30 b(function)g(returns)i(the)g(result)f
(of)h(removing)f(the)g(\256rst)h(occurrence)h(of)f Fi(data)f
Fn(from)h Fi(list)g Fn(if)f Fi(data)0 2441 y Fn(exists)26 b(in)e
Fi(list)p Fn(.)37 b(If)25 b Fi(data)g Fn(does)i(not)f(exist)f(in)g
Fi(list)p Fn(,)h(then)f Fj(setremove\(\))c Fn(returns)26 b
Fi(list)g Fn(unmodi\256ed.)125 2717 y(Examples:)240 2969 y
Fj(setremove\([2,)49 b(3,)k(4,)h('foo],)e('foo\))513 3063 y
Fl(\))658 3069 y Fj([2,)h(3,)h(4])240 3168 y(setremove\([2,)49
b(3,)k(4],)g(5\))513 3262 y Fl(\))658 3268 y Fj([2,)g(3,)h(4])240
3368 y(setremove\([2,)49 b(3,)k(2,)h(4],)f(2\))513 3461 y Fl(\))658
3467 y Fj([3,)g(2,)h(4])0 3938 y Fm(sublist)240 4189 y Fj(sublist\()p
Fi(list)p Fj(,)d Fi(start)p Fj(\))240 4289 y(sublist\()p Fi(list)p
Fj(,)g Fi(start)p Fj(,)k Fi(length)p Fj(\))125 4565 y Fn(This)20
b(function)h(returns)h(a)e(sublist)g(of)i Fi(list)h Fn(beginning)18
b(at)j(the)h(element)g(numbered)f(by)g Fi(start)p Fn(.)35 b(If)21
b Fi(length)0 4690 y Fn(is)k(speci\256ed,)h(then)f(the)g(sublist)f(has)g
(that)h(length;)g(otherwise,)h(the)g(length)e(is)h(given)f(by)g
Fj(\(length\()p Fi(list)p Fj(\))0 4814 y(-)h(\()p Fi(start)h
Fj(-)e(1\)\))p Fn(.)44 b(If)28 b Fi(start)h Fn(is)f(less)h(than)e
Fj(1)p Fn(,)i(if)f(the)h(length)f(of)h(the)f(sublist)g(is)g(negative,)h(or)g
(if)f(the)h(sum)e(of)0 4939 y Fi(start)f Fn(and)e Fi(length)h
Fn(is)g(greater)i(than)d(one)h(more)i(than)d(the)h(length)g(of)h(the)f(list,)
g(then)g Fj(sublist\(\))c Fn(throws)0 5064 y(a)k Fj(\304range)d
Fn(error)-7 b(.)125 5340 y(Examples:)p eop
%%Page: 50 52
50 51 bop 0 -116 a Fn(50)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)240 366 y Fj(sublist\([2,)50 b(3,)j(4,)h(5,)f(6,)h(7],)f(2,)h
(3\))513 460 y Fl(\))658 466 y Fj([3,)f(4,)h(5])240 566 y(sublist\([2,)c(3,)j
(4,)h(5,)f(6,)h(7],)f(3\))513 659 y Fl(\))658 665 y Fj([4,)g(5,)h(6,)g(7])240
765 y(sublist\([2,)c(3,)j(4,)h(5,)f(6,)h(7],)f(7\))513 859
y Fl(\))658 865 y Fj([])0 1377 y Fm(union)240 1633 y Fj(union\()p
Fi(list1)p Fj(,)f Fi(list2)p Fj(\))125 1914 y Fn(This)34 b(function)i
(returns)h(the)f(result)g(of)h(adding)e(each)h(element)g(of)h
Fi(list2)f Fn(which)f(does)i(not)f(already)0 2039 y(exist)29
b(in)f Fi(list1)h Fn(to)g(the)g(elements)h(of)f Fi(list1)p
Fn(.)46 b(Elements)28 b(which)g(exist)h(in)f Fi(list2)h Fn(more)g(than)f
(once)h(will)f(only)0 2163 y(be)d(added)h(once,)g(but)f(duplicate)g(elements)
h(in)f Fi(list1)h Fn(will)e(remain.)240 2419 y Fj(union\([2,)50
b(3,)k(4],)f([4,)g(5,)h(4,)g(6]\))513 2513 y Fl(\))658 2519
y Fj([2,)f(3,)h(4,)g(5,)f(6])240 2619 y(union\([2,)d(2,)k(4,)g(5],)f([4,)g
(5,)h(6,)f(6,)h(7]\))513 2712 y Fl(\))658 2718 y Fj([2,)f(2,)h(4,)g(5,)f(6,)h
(7]\))0 3230 y Fm(5.4)59 b(Dictionary)31 b(Functions)125 3511
y Fn(The)d(functions)h(described)i(in)d(this)h(section)h(perform)i
(operations)e(on)f(dictionaries.)48 b(These)29 b(options)0
3636 y(do)36 b(not)f(actually)e(modify)i(the)g(dictionaries)h(they)f(accept)h
(as)e(arguments;)40 b(instead,)d(they)e(return)h(the)0 3760
y(modi\256ed)26 b(dictionaries)f(as)g(their)h(return)g(values.)0
4273 y Fm(dict)p 248 4273 36 6 v 43 w(add)240 4529 y Fj(dict_add\()p
Fi(dictionary)p Fj(,)51 b Fi(key)p Fj(,)k Fi(value)p Fj(\))125
4810 y Fn(This)30 b(function)i(returns)h(the)f(result)h(of)g(adding)e(the)h
(association)g Fj([)p Fi(key)p Fj(,)25 b Fi(value)p Fj(])32
b Fn(to)h(the)f(dictionary)0 4934 y Fi(dictionary)p Fn(.)58
b(If)33 b Fi(key)g Fn(already)f(exists)h(in)e Fi(dictionary)p
Fn(,)36 b(then)d Fj(dict_add\(\))27 b Fn(replaces)34 b(the)f(value)e(of)i
(that)0 5059 y(key)25 b(with)g Fi(value)p Fn(.)125 5340 y(Examples:)p
eop
%%Page: 51 53
51 52 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(51)240 366 y Fj(dict_add\(#[["fo)o(o")o(,)48 b("bar"]],)j(3,)j('quux\))513
460 y Fl(\))658 466 y Fj(#[["foo",)d("bar"],)g([3,)i('quux]])240
566 y(dict_add\(#[["fo)o(o")o(,)48 b(1],)54 b(["bar",)d(2],)i(["baz",)e(3]],)
i("bar",)f(4\))513 659 y Fl(\))658 665 y Fj(#[["foo",)f(1],)i(["bar",)e(4],)i
(["baz",)f(3]])0 1232 y Fm(dict)p 248 1232 36 6 v 43 w(add)p
524 1232 V 43 w(elem)240 1494 y Fj(dict_add_elem\()p Fi(d)o(ictionary)p
Fj(,)e Fi(key)p Fj(,)55 b Fi(element)p Fj(\))125 1781 y Fn(This)32
b(function)i(returns)h(the)f(result)h(of)g(adding)e Fi(element)i
Fn(to)f(the)h(list)f(value)f Fi(key)h Fn(in)f Fi(dictionary)p
Fn(.)64 b(If)0 1905 y Fi(dictionary)21 b Fn(has)e(no)g(association)g(with)g
(key)h Fi(key)p Fn(,)h(then)f Fj(dict_add_elem\()o(\))13 b
Fn(adds)20 b(an)e(association)i Fj([)p Fi(key)p Fj(,)0 2030
y([)p Fi(element)p Fj(]])31 b Fn(to)h Fi(dictionary)p Fn(.)57
b(If)31 b Fi(dictionary)j Fn(has)c(an)h(association)g(with)g(key)h
Fi(key)p Fn(,)i(and)d(the)h(value)f(part)0 2155 y(of)j(the)g(association)f
(is)h(a)f(list,)i(then)f Fj(dict_add_elem\()o(\))27 b Fn(adds)34
b Fi(element)g Fn(to)g(the)g(end)g(of)g(that)g(list.)60 b(If)0
2279 y Fi(dictionary)29 b Fn(has)e(an)g(association)h(with)f(key)h
Fi(key)p Fn(,)h(but)e(the)h(value)f(part)i(of)f(the)g(association)g(is)f(not)
i(a)e(list,)0 2404 y(then)e Fj(dict_add_elem\(\))19 b Fn(throws)25
b(a)g Fj(\304type)e Fn(error)-7 b(.)125 2691 y(Examples:)240
2953 y Fj(dict_add_elem\(#)o([[)o("f)o(oo)o(",)48 b(["bar"]]],)i("foo",)i
("baz"\))513 3046 y Fl(\))658 3052 y Fj(#[["foo",)f(["bar",)g("baz"]]])240
3152 y(dict_add_elem\(#)o([])o(,)d("foo",)k("bar"\))513 3246
y Fl(\))658 3252 y Fj(#[["foo",)f(["bar"]]])0 3818 y Fm(dict)p
248 3818 V 43 w(contains)240 4080 y Fj(dict_contains\()p Fi(d)o(ictionary)p
Fj(,)f Fi(key)p Fj(\))125 4367 y Fn(This)40 b(function)h(returns)i(1)e(if)g
(there)i(is)e(an)g(association)g(in)g Fi(dictionary)i Fn(with)e(the)h(key)g
Fi(key)p Fn(,)k(or)c(0)0 4492 y(otherwise.)125 4779 y(Examples:)240
5041 y Fj(dict_contains\(#)o([[)o("f)o(oo)o(",)48 b("bar"]],)j("foo"\))513
5135 y Fl(\))658 5141 y Fj(1)240 5240 y(dict_contains\(#)o([[)o("f)o(oo)o(",)
d("bar"]],)j("bar"\))513 5334 y Fl(\))658 5340 y Fj(0)p eop
%%Page: 52 54
52 53 bop 0 -116 a Fn(52)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(dict)p 248 366 36 6 v 43 w(del)240 618
y Fj(dict_del\()p Fi(dictionary)p Fj(,)51 b Fi(key)p Fj(\))125
894 y Fn(This)31 b(function)i(returns)g(the)g(result)g(of)h(removing)e(the)i
(association)e(in)g Fi(dictionary)i Fn(which)e(has)g(the)0
1019 y(key)25 b Fi(key)p Fn(.)36 b(If)26 b(there)g(is)f(no)h(such)f
(association,)g(then)g Fj(dict_del\(\))c Fn(raises)k(a)g Fj(\304keynf)e
Fn(exception.)240 1270 y Fj(dict_del\(#[["fo)o(o")o(,)48 b(1],)54
b(["bar",)d(2]],)i("foo"\))513 1364 y Fl(\))658 1370 y Fj(#[["bar",)e(2]])0
1840 y Fm(dict)p 248 1840 V 43 w(del)p 482 1840 V 43 w(elem)240
2091 y Fj(dict_del_elem\()p Fi(d)o(ictionary)p Fj(,)f Fi(key)p
Fj(,)55 b Fi(element)p Fj(\))125 2368 y Fn(This)19 b(function)h(returns)h
(the)g(result)g(of)h(removing)e Fi(element)h Fn(from)h(the)f(list)f(value)f
(of)j Fi(key)f Fn(in)e Fi(dictionary)p Fn(.)0 2492 y(If)26
b Fi(dictionary)h Fn(contains)e(no)h(association)f(with)g(key)h
Fi(key)p Fn(,)h(then)e Fj(dict_del_elem\(\))19 b Fn(throws)26
b(a)g Fj(\304keynf)0 2617 y Fn(error)-7 b(.)40 b(If)26 b Fi(dictionary)i
Fn(contains)d(an)g(association)h(with)f(key)h Fi(key)p Fn(,)h(and)e(it)h(is)g
(not)h(a)e(list,)h(then)g Fj(dict_del_)0 2741 y(elem\(\))d
Fn(throws)i(a)g Fj(\304type)e Fn(error)-7 b(.)125 3018 y(Assuming)37
b(that)h Fi(dictionary)j Fn(contains)d(an)g(association)h(with)f(key)h
Fi(key)p Fn(,)k(and)38 b(it)h(is)g(a)f(list,)k Fj(dict_)0 3142
y(del_elem\(\))27 b Fn(removes)33 b(the)f(\256rst)g(occurrence)i(of)e
Fi(element)g Fn(in)f(the)h(list)f(if)g Fi(element)i Fn(occurs)f(in)f(the)h
(list.)0 3267 y(If)h(the)g(resulting)f(list)g(is)g(an)g(empty)h(list,)i(then)
d Fj(dict_del_elem\(\))26 b Fn(removes)34 b(the)f(association)f(from)0
3391 y Fi(dictionary)g Fn(altogether)-7 b(.)52 b(If)31 b Fi(element)g
Fn(does)h(not)f(occur)g(in)f(the)h(list,)g(then)g Fj(dict_del_elem\()o(\))24
b Fn(returns)0 3516 y Fi(dictionary)j Fn(unchanged.)125 3792
y(Examples:)240 4043 y Fj(dict_del_elem\(#)o([[)o("f)o(oo)o(",)48
b(["bar",)j("baz"]]],)g("foo",)h("bar"\))513 4137 y Fl(\))658
4143 y Fj(#[["foo",)f(["baz"]]])240 4243 y(dict_del_elem\(#)o([[)o("f)o(oo)o
(",)d(["baz"]]],)i("foo",)i("baz"\))513 4336 y Fl(\))658 4342
y Fj(#[])0 4812 y Fm(dict)p 248 4812 V 43 w(keys)240 5064 y
Fj(dict_keys\()p Fi(dictionary)p Fj(\))125 5340 y Fn(This)24
b(function)h(returns)h(a)f(list)g(of)h(the)f(keys)h(of)g(the)f(associations)g
(in)g Fi(dictionary)p Fn(.)p eop
%%Page: 53 55
53 54 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(53)240 366 y Fj(dict_keys\(#[["f)o(oo)o(",)48 b(1"],)53 b(["bar",)e(2],)i
(['baz,)f(3]]\))513 460 y Fl(\))658 466 y Fj(["foo",)g("bar",)f('baz])0
1062 y Fm(5.5)59 b(Buffer)29 b(Functions)125 1352 y Fn(The)j(functions)g
(described)i(in)d(this)h(section)i(apply)e(to)h(buffers.)58
b(As)32 b(with)g(strings)g(and)g(lists,)i(these)0 1477 y(functions)d(will)f
(not)h(actually)f(modify)h(any)f(buffers)i(passed)g(as)f(arguments,)h(but)f
(will)e(instead)i(return)0 1601 y(the)26 b(results)f(of)h(performing)h
(modi\256cations)e(on)g(the)g(buffers.)0 2197 y Fm(buffer)p
391 2197 36 6 v 42 w(add)240 2463 y Fj(buffer_add\()p Fi(buffer)p
Fj(,)49 b Fi(byte)p Fj(\))125 2753 y Fn(This)29 b(function)h(returns)h(the)f
(result)h(of)g(adding)e Fi(byte)p Fn(,)j(an)e(integer)-7 b(,)32
b(to)f(the)g(end)f(of)h Fi(buffer)p Fn(.)51 b(If)31 b Fi(byte)f
Fn(is)0 2877 y(not)24 b(between)g Fj(0)f Fn(and)g Fj(255)p
Fn(,)g(the)h(value)f(appended)h(to)h Fi(buffer)f Fn(will)e(be)i(the)g(lower)n
(-order)i(eight)e(bits)f(of)h Fi(byte)p Fn(.)125 3168 y(Examples:)240
3433 y Fj(buffer_add\(\045[65)o(,)48 b(66,)53 b(67],)g(10\))513
3527 y Fl(\))658 3533 y Fj(\045[65,)f(66,)i(67,)f(10])0 4129
y Fm(buffer)p 391 4129 V 42 w(append)240 4394 y Fj(buffer_append\()p
Fi(b)o(uffer1)p Fj(,)c Fi(buffer2)p Fj(\))125 4685 y Fn(This)24
b(function)h(returns)h(the)f(result)h(of)g(appending)e Fi(buffer2)i
Fn(to)g(the)f(end)h(of)g Fi(buffer1)p Fn(.)125 4975 y(Examples:)240
5240 y Fj(buffer_append\(\045)o([6)o(5,)48 b(66,)53 b(67,)g(10],)g(\045[67,)f
(66,)h(65,)h(10]\))513 5334 y Fl(\))658 5340 y Fj(\045[65,)e(66,)i(67,)f(10,)
g(67,)g(66,)g(65,)h(10])p eop
%%Page: 54 56
54 55 bop 0 -116 a Fn(54)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(buffer)p 391 366 36 6 v 42 w(from)p
730 366 V 43 w(strings)240 621 y Fj(buffer_from_str)o(in)o(gs)o(\()p
Fi(list-of-strings)p Fj(,)51 b([)p Fi(terminator)p Fj(]\))125
901 y Fn(This)33 b(function)h(returns)h(a)f(buffer)h(constructed)i(by)d
(appending)g(the)g(strings)h(in)e Fi(list-of-strings)38 b Fn(to-)0
1026 y(gether)-7 b(,)27 b(treating)f(the)g(strings)f(as)g(sequences)i(of)f
(ASCII)f(values,)g(with)g(each)g(string)h(followed)g(by)f Fi(termi-)0
1150 y(nator)p Fn(,)h(a)e(buffer)-7 b(.)36 b(If)25 b Fi(terminator)g
Fn(is)g(not)g(speci\256ed,)g(then)g Fj(buffer_from_str)o(in)o(gs)o(\(\))18
b Fn(uses)25 b(the)g(buffer)0 1275 y Fj(\045[13,)e(10])p Fn(,)g(a)g(two-byte)
i(buffer)f(containing)e(the)i(ASCII)f(codes)i(for)g(a)e(carriage)g(return)i
(and)e(a)g(newline.)125 1554 y(Examples:)240 1809 y Fj(buffer_from_str)o(in)o
(gs)o(\([)o("fo)o(o")o(,)48 b("bar"]\))513 1903 y Fl(\))658
1909 y Fj(\045[102,)k(111,)h(111,)f(13,)i(10,)f(98,)g(97,)g(4,)h(13,)f(10])
240 2008 y(buffer_from_str)o(in)o(gs)o(\([)o("fo)o(o")o(,)48
b("bar"],)k(\045[10]\))513 2102 y Fl(\))658 2108 y Fj(\045[102,)g(111,)h
(111,)f(10,)i(98,)f(97,)g(4,)h(10])0 2608 y Fm(buffer)p 391
2608 V 42 w(len)240 2863 y Fj(buffer_len\()p Fi(buffer)p Fj(\))125
3143 y Fn(This)24 b(function)h(returns)h(the)f(length)g(of)h(the)g(buffer)f
Fi(buffer)p Fn(.)125 3422 y(Examples:)240 3677 y Fj(buffer_len\(\045[65)o(,)
48 b(66,)53 b(67,)h(10]\))513 3771 y Fl(\))658 3777 y Fj(4)0
4277 y Fm(buffer)p 391 4277 V 42 w(replace)240 4531 y Fj(buffer_replace\()o
Fi(bu)o(ffer)p Fj(,)c Fi(pos)p Fj(,)55 b Fi(value)p Fj(\))125
4811 y Fn(This)19 b(function)h(returns)i(the)f(result)g(of)g(replacing)f(the)
h(byte)g(numbered)g Fi(pos)g Fn(in)f Fi(buffer)h Fn(with)f(the)h(value)0
4936 y Fi(value)p Fn(,)34 b(with)e(the)g(\256rst)g(byte)g(of)h
Fi(buffer)f Fn(is)g(numbered)g Fj(1)p Fn(.)55 b(If)32 b Fi(pos)h
Fn(is)e(less)h(than)f Fj(1)p Fn(,)j(or)e(greater)i(than)d(the)0
5060 y(length)25 b(of)h Fi(buffer)p Fn(,)g(then)f Fj(buffer_replace)o(\(\))19
b Fn(throws)26 b(a)e Fj(\304range)f Fn(error)-7 b(.)125 5340
y(Examples:)p eop
%%Page: 55 57
55 56 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(55)240 366 y Fj(buffer_replace\()o(\045[)o(65)o(,)48 b(66,)54
b(67,)f(10],)g(3,)g(15\))458 460 y Fl(\))604 466 y Fj(\045[65,)f(66,)h(15,)g
(10])0 1015 y Fm(buffer)p 391 1015 36 6 v 42 w(retrieve)240
1275 y Fj(buffer_retrieve)o(\()p Fi(b)o(uffer)p Fj(,)c Fi(pos)p
Fj(\))125 1561 y Fn(This)23 b(function)h(returns)i(the)f(byte)f(numbered)h
Fi(pos)h Fn(in)d Fi(buffer)p Fn(,)j(with)e(the)g(\256rst)h(byte)g(of)h
Fi(buffer)e Fn(is)h(num-)0 1685 y(bered)k Fj(1)p Fn(.)44 b(If)28
b Fi(pos)h Fn(is)f(less)h(than)e Fj(1)p Fn(,)h(or)h(greater)h(than)d(the)h
(length)g(of)h Fi(buffer)p Fn(,)g(then)f Fj(buffer_replace\()o(\))0
1810 y Fn(throws)e(a)f Fj(\304range)d Fn(error)-7 b(.)125 2095
y(Examples:)240 2355 y Fj(buffer_retrieve)o(\(\045)o([6)o(5,)48
b(66,)53 b(67,)g(10],)g(3\))513 2449 y Fl(\))658 2455 y Fj(67)0
3004 y Fm(buffer)p 391 3004 V 42 w(to)p 557 3004 V 43 w(strings)240
3264 y Fj(buffer_to_strin)o(gs)o(\()p Fi(b)o(uffer)p Fj(,)c([)p
Fi(separator)p Fj(]\))125 3549 y Fn(This)33 b(function)i(returns)g(a)f(list)h
(of)g(strings)g(constructed)i(from)e Fi(buffer)g Fn(by)g(splitting)f(it)g
(around)h(the)0 3674 y(bytes)21 b(given)f(by)g(the)h(buffer)g
Fi(separator)p Fn(.)37 b(If)21 b Fi(separator)i Fn(is)e(not)g(speci\256ed,)i
Fj(buffer_to_stri)o(ng)o(s\(\))14 b Fn(uses)0 3798 y(the)27
b(buffer)g Fj(\045[10])p Fn(,)d(a)i(single-byte)g(buffer)h(containing)e(the)i
(ASCII)f(code)i(for)f(a)f(newline.)39 b Fj(buffer_to_)0 3923
y(strings\(\))32 b Fn(treats)37 b(the)g(bytes)g(in)e Fi(buffer)h
Fn(not)h(accounted)g(for)g(by)f(the)g(separator)i(as)e(ASCII)g(values;)0
4047 y(unprintable)j(ASCII)h(values)g(are)h(stripped.)84 b(The)41
b(last)f(element)h(of)h(the)f(returned)h(list)f(is)f(a)h(buffer)0
4172 y(containing)27 b(the)i(bytes)g(in)f(the)h(buffer)g(after)h(the)f(last)f
(separator)i(found;)h(no)e(string)f(is)h(included)f(in)g(the)0
4296 y(returned)f(list)e(for)h(these)g(bytes.)125 4582 y(Examples:)240
4842 y Fj(buffer_to_strin)o(gs)o(\(\045)o([6)o(5,)48 b(66,)53
b(67,)g(13,)h(10,)f(67,)g(66,)g(65,)g(13,)h(10,)f(66]\))513
4935 y Fl(\))658 4941 y Fj(["ABC",)f("CBA",)f(\045[66]])240
5041 y(buffer_to_strin)o(gs)o(\(\045)o([6)o(6,)d(10,)53 b(10,)g(65,)h(10]\))
513 5135 y Fl(\))658 5141 y Fj(["B",)e("",)i("A",)e(\045[]])240
5240 y(buffer_to_strin)o(gs)o(\(\045)o([6)o(5,)c(66,)53 b(67,)g(13,)h(10,)f
(67,)g(66,)g(65,)g(10,)h(66],)e(\045[66]\))513 5334 y Fl(\))658
5340 y Fj(["A",)g("CC",)h("A",)f(\045[]])p eop
%%Page: 56 58
56 57 bop 0 -116 a Fn(56)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(buffer)p 391 366 36 6 v 42 w(truncate)240
627 y Fj(buffer_truncate)o(\()p Fi(b)o(uffer)p Fj(,)49 b Fi(length)p
Fj(\))125 913 y Fn(This)27 b(function)h(returns)h(the)g(result)f(of)h
(truncating)f Fi(buffer)g Fn(to)i(the)e(length)g Fi(length)p
Fn(.)44 b(If)29 b Fi(length)f Fn(is)g(less)0 1037 y(than)20
b Fj(0)g Fn(or)h(greater)h(than)d(the)i(length)f(of)h Fi(buffer)p
Fn(,)h(then)f Fj(buffer_truncat)o(e\(\))14 b Fn(throws)21 b(a)f
Fj(\304range)d Fn(error)-7 b(.)125 1323 y(Examples:)240 1583
y Fj(buffer_truncate)o(\(\045)o([6)o(5,)48 b(66,)53 b(67,)g(10],)g(2\))513
1677 y Fl(\))658 1683 y Fj(\045[65,)f(66])0 2235 y Fm(5.6)59
b(Method)30 b(Functions)125 2521 y Fn(The)k(functions)h(described)i(in)d
(this)h(section)h(return)g(information)f(about)f(the)i(objects)g(involved)f
(in)0 2645 y(the)27 b(call)f(to)h(the)g(current)g(method:)39
b(the)27 b(caller)-7 b(,)28 b(the)f(de\256ner)-7 b(,)28 b(the)e(sender)-7
b(,)29 b(and)d(the)h(current)g(object.)41 b(If)26 b(a)0 2770
y(method)31 b(de\256ned)g(by)f(object)i(A,)e(processing)h(a)f(message)h(for)h
(object)f(B,)g(sends)f(a)g(message)h(to)h(object)f(C,)0 2894
y(which)24 b(results)i(in)e(a)h(call)f(to)i(a)f(method)h(de\256ned)g(by)e
(object)j(D,)e(then)g(A)g(is)g(the)g(caller)-7 b(,)26 b(B)f(is)g(the)h
(sender)-7 b(,)26 b(C)0 3019 y(is)f(the)h(current)g(object,)h(and)d(D)h(is)g
(the)h(de\256ner)-7 b(.)0 3571 y Fm(caller)240 3832 y Fj(caller\(\))125
4117 y Fn(This)33 b(function)h(returns)i(the)f(dbref)g(of)g(the)g(object)h
(which)e(de\256nes)g(the)h(method)h(which)d(called)i(the)0
4242 y(current)26 b(method,)h(or)f Fj(0)f Fn(if)g(the)g(current)i(method)f
(was)e(called)h(by)g(the)h(server)-7 b(.)0 4794 y Fm(de\256ner)240
5054 y Fj(definer\(\))125 5340 y Fn(This)24 b(function)h(returns)h(the)f
(dbref)h(of)g(the)g(object)g(which)f(de\256nes)g(the)h(current)g(method.)p
eop
%%Page: 57 59
57 58 bop 0 -116 a Fn(Chapter)25 b(5:)36 b(Function)24 b(Descriptions)2389
b(57)0 366 y Fm(sender)240 617 y Fj(sender\(\))125 892 y Fn(This)31
b(function)h(returns)h(the)g(dbref)g(of)g(the)g(object)h(which)d(sent)i(the)g
(current)g(message,)i(or)e Fj(0)f Fn(if)h(the)0 1017 y(current)26
b(method)g(was)f(called)g(by)g(the)g(server)-7 b(.)0 1479 y
Fm(task)p 271 1479 36 6 v 43 w(id)240 1729 y Fj(task_id\(\))125
2005 y Fn(This)22 b(function)i(returns)g(the)g(ID)g(of)g(the)g(current)h
(task.)35 b(The)24 b(task)f(ID)h(is)f(an)g(integer)i(which)d(begins)h(at)0
2129 y Fj(0)i Fn(for)h(the)g(\256rst)f(task)h(and)e(increases)i(by)f
Fj(1)f Fn(each)i(time)f(a)g(task)g(runs.)0 2591 y Fm(this)240
2842 y Fj(this\(\))125 3117 y Fn(This)f(function)h(returns)h(the)f(dbref)h
(of)g(the)g(current)g(object.)0 3579 y Fm(5.7)59 b(Error)30
b(Functions)125 3854 y Fn(The)24 b(functions)g(described)i(in)e(this)g
(section)h(perform)i(operations)e(related)h(to)f(handling)d(error)27
b(condi-)0 3979 y(tions.)0 4440 y Fm(error)240 4691 y Fj(error\(\))125
4966 y Fn(This)21 b(function,)h(which)f(you)h(should)g(only)f(call)h(inside)g
(an)f(error)j(handler)d(for)j(a)d(catch)i(statement)g(\(see)0
5091 y(Section)j(3.5)e([Error)n(-Handling)h(Statements],)i(page)e(16\),)f
(returns)i(the)f(error)i(code)g(for)f(the)f(error)i(which)0
5215 y(triggered)22 b(the)g(error)h(handler)-7 b(.)33 b(If)22
b(you)e(are)i(not)f(in)f(an)g(error)j(handler)-7 b(,)22 b(this)e(function)h
(throws)h(an)e Fj(\304error)0 5340 y Fn(error)-7 b(.)p eop
%%Page: 58 60
58 59 bop 0 -116 a Fn(58)2357 b(Coldmud)25 b(Programmer)5 b(')m(s)25
b(Reference)0 366 y Fm(error)p 335 366 36 6 v 43 w(arg)240
620 y Fj(error_arg\(\))125 899 y Fn(This)c(function,)h(which)f(you)h(should)g
(only)f(call)h(inside)g(an)f(error)j(handler)d(for)j(a)d(catch)i(statement)g
(\(see)0 1024 y(Section)34 b(3.5)e([Error)n(-Handling)h(Stateme

Showing the first 150 KB. Download the file for the full text.

Site Stats

Snippets: 1791
Codebases: 571