Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Rivard F.Smalltalk.A reflective language

.pdf
Скачиваний:
13
Добавлен:
23.08.2013
Размер:
379.35 Кб
Скачать

yield

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

heItsittod

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ouslyVMturncommonpusat.edssame.withconrunexeTh

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

suspendsproc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ThethItone(itsthe

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

maphore

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

preves

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

waittothe(unsha[new.processsemaph:primiatbloc:currentwilland:.process] kitivfruntheyormak(thepriorityrunhisContext.).in

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

signalprocess,ssesforknewat

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

thewhic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

thewa:=ProcessesvrrjailabletlycationeatesdyingwSemaphoregnal]the.proc"processrunning

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

haintoreiprocess,)running

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

beforelyofexecut

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ss.othcurren

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

presen

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

nextThecod

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

thethisTheilehance.listated

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

escreationrity)previouwj[semaphorsemaphore\Giv

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ough

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

BlockContextningsemaphonlypriincutmallakelfto

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

urns

The

mo

 

 

 

 

 

able re

 

tiv

facil

 

y

f Small-

 

inst

context of

the

cur

 

ntly runn ng

 

 

-

ss. It

is

an

nce of

the

 

 

 

 

 

3):

 

 

 

 

 

 

 

 

 

A

 

 

clremark.inly knows (Figu

 

 

 

 

 

ack,

alk is the

 

 

 

 

 

 

 

 

of

 

any

 

 

 

run

 

 

 

 

rgu

 

ents:), or the

 

v

 

 

 

 

of B

class,kClos

re

xts

 

 

 

 

c

 

 

 

of

 

ink

 

 

 

 

k f am s,

 

mell d

 

 

 

[Par94a].

 

The

pseued

 

-stav riable

 

 

 

 

ia the

 

 

 

 

con text

(sender)

 

MethodConhas \created" it

 

that the receiver is an instance of the BlockClosuroperand

 

: : : ),method

(

 

 

 

 

 

 

 

 

 

valueWithReld y

class) cur-

 

using

 

#valueWithArgumealuations: (or #va ue #val e:

 

 

pplica ion of methodwhic( f

 

 

 

 

 

 

ei

 

r:

 

 

 

 

 

 

tructiofaCompiledMethodthe ssage, and the arguments. Note

 

 

 

 

ins actually being executed beringmethod,

 

 

 

 

an

 

ly being executed,

 

 

remem

 

 

 

the

 

 

 

 

 

 

 

 

 

 

 

 

po

 

ter,

 

 

 

 

 

 

 

 

 

class for BlockContext.

 

 

 

 

 

 

 

 

 

 

 

 

18Wrenhareceivsimpli ed the

code for clearer understanding.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Context

 

 

 

 

 

executiv

 

 

 

 

The

 

 

 

 

 

 

 

 

 

 

 

 

 

 

thisConteession

 

 

 

 

aM thodContex

 

presen

aCompiledMe hod

 

 

 

 

 

me hod

 

 

xtreme

 

 

 

 

 

1<10> pu h local 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

er

 

 

 

expr

 

 

 

 

 

 

 

 

 

 

pc

 

 

 

 

 

 

 

 

 

2<44> pu h s lf

 

 

 

 

 

 

 

 

grams

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

execution, using

 

 

 

sender

 

 

 

 

 

 

 

 

 

3<80> send s mFr mPoint:

 

 

 

actionsrocutimanipulateobjectsSmall2mostFigureheendedrol.5ough.error2is(MethodCreturnthein3sctoalksucUsage:Twcan:fullyreplSmerr'ssttheplontasdl.acrejectlementsrsi:llTheconmenngk,ed.execuThissystemtrolintationlkExcerstd,orderof,ivitsimplemenpowhic:the,startthofofcaughstactiontsinwntotheSmallmodiorderofDebuggerkproposeclassapplication)excepinterc.intatioExceptionsyoforderestoreialkstackhisthexttakmayes[Don90..handler\toalternativobjectsrs.egular"itappropriaallows(seehandledearetoplf].regularnedbmrawhichbeinggureconprosedexxeertohy-

 

Therefore,

 

are

 

4 <65> re urn

handle

 

 

 

 

 

 

ceiver

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

of

 

 

secoru

 

 

 

 

 

 

plica

 

 

 

 

 

 

 

execution

 

 

 

memessagack is

 

 

 

aPoint

 

 

 

 

to

 

 

 

F

 

 

 

ck

 

 

 

 

 

 

 

 

 

 

 

 

= 2

 

 

 

 

 

 

 

 

 

 

 

3), whichandle:d

 

 

 

 

 

 

 

 

 

 

y = 4

 

 

 

 

 

 

 

 

 

 

 

me

 

 

 

 

 

 

 

il dMe

od

 

 

 

 

 

 

 

 

 

 

 

 

 

pc

 

 

 

ins

 

ucti

n

 

 

er

 

the

 

 

of m th

 

 

 

 

nd

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rec iver

 

 

 

 

 

 

 

 

 

 

 

 

 

 

hod

 

 

 

 

 

 

 

 

 

 

 

 

ck

 

 

 

rgu

 

 

 

 

 

,

 

 

por

 

 

 

wor

 

 

ack

 

 

 

A

 

 

 

very impor an

 

 

 

 

 

 

 

 

f

 

re ca

look at

what part

 

of

 

the selected

 

context is

 

 

 

s lt

 

y con ext of

 

 

 

 

 

entire executivthestack,

executed,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ssage

 

 

 

 

 

 

insp ct

the receiver of the

 

 

 

 

 

 

 

 

 

 

ts and

 

temporaries of the selected

pr

ceed argumento \st p by s ep" execu

 

 

 

(send, step),

 

 

t xt,

 

 

 

 

 

 

by recompilation of its m thod,

conm dify any con

 

 

 

and continue thtextexecution with this new

code.

w illustrate. Dealingdeveltheirwithpmenuseextensiwithvironmalksmallof the,mewbutmodel,compl. Th compiler,isre/palizaypst

icalomainer tonewprovideyasconstructifwellusingregularaslanguagethessibleSmallth. Pre/postextenda suitsec heenactutroduceoffthecilaptiesll underin or

he

 

 

 

 

gory of softw

 

notengi

 

 

 

ring

 

ols. both dev

pro

men

 

 

nd coding

 

 

 

ns .

 

 

 

 

 

 

 

 

 

 

duringis ss

 

 

ti

l

 

 

 

 

vide

 

 

Applicationshanisms in

 

 

are

 

 

Thereforeto c ck b

 

.

 

 

 

 

proper ieselopf

and the assump

 

 

to

 

his role. A

 

 

 

 

Pr

 

 

 

post

 

con

 

 

 

cat

 

d v

 

 

 

 

 

 

 

 

um

 

 

 

 

 

la nguage:,

fo lowi

 

 

Flavors [M

 

 

o86], implemen

before/after

 

 

 

 

 

s.

he

 

 

 

cause

otedta

 

 

 

of pre/pstable

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

to

 

 

 

But

 

 

 

 

 

 

 

 

 

 

 

 

 

madeder

thodsconditionsofmpl

 

xcan

 

 

conditionsimplemenhanism and

 

bec usemethodsrely are assignedicationto

 

 

 

 

 

 

 

 

before/afme

 

 

 

ins

 

 

 

 

 

of the

 

 

 

 

 

 

 

 

 

 

 

the

 

 

is howteesw use

 

pre/post

 

 

onditions. Our

 

 

 

 

 

l is to pro

anoth

 

 

 

 

be

 

 

bjecked conditiw

the

 

 

 

 

thod methodsis calle .

 

 

 

 

guaran

 

 

when

 

 

 

ret

rns."

 

 

 

 

 

 

 

 

 

 

].

 

 

 

 

 

 

 

 

method

 

 

 

 

 

ply connectsamicitclass to its metacl ss

( f 2.2.1),

 

 

 

 

(regular(nameplem

 

 

 

atioin. It be

eadsu ts

 

 

eir ro

 

 

 

 

as

 

 

 

poscribedect-

ndit

 

 

 

 

 

 

 

i es those

pr expressesthat

 

 

 

 

 

 

 

 

 

 

 

 

vide pre/po

 

 

 

 

 

 

 

 

 

 

 

 

 

in

 

 

 

 

 

 

pre/postthaord spect

 

be

ods (SOM [DFM94], CLOS,: : :). O

 

 

of their uses

 

 

 

 

 

elves

 

 

 

 

i

 

ver

 

 

 

 

 

hods)Small

alk (cf 2.3.1)), w

 

us

 

 

men

 

 

 

and

the

softwar[Mey90rtie

 

 

 

 

 

 

 

to

 

 

be

 

 

 

dynamic

 

 

\T

onditionsvivial

adition of the lanaboutgWheng . Speci

 

 

 

 

 

by:

 

 

 

 

pre-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

the

prop

rti

 

longer ustf

 

l. They should be

 

 

 

 

 

 

ved in

 

 

 

 

 

 

 

 

 

 

 

 

 

correct me hod use mak

 

 

 

 

 

 

 

 

 

 

 

conditi ns no

eased, ftware

 

lean from any devremoel pmen

 

 

 

opics.

 

This

 

 

of

aling

 

 

 

 

dy

 

 

 

 

 

 

 

y, lik

adding an insta

 

 

ce vari-

 

 

 

whicwithis

 

 

 

 

 

 

 

 

 

inst

nce.

In resp

ati

 

this

 

 

 

 

 

 

 

w

proposthe

 

 

 

Smalltion (or

 

 

 

 

 

 

 

n) of

 

 

modelpr pre/postconditionditions

 

he

class/meteactivcl ss ctouple,

 

 

 

ynamic behavior

:

follows:

 

alkusers

 

re used

 

 

catielopns are

 

ummar zed

 

 

 

he S

 

allanotherlk mod l

 

 

hi rarc ey indepe

 

 

dence:

 

 

 

 

 

able

ndywhere

 

 

 

 

 

hi

archy of classes.

 

 

Dyna

 

icithey

 

 

whe

 

 

 

 

 

do not in

 

rfere

 

 

 

all with

 

 

 

 

 

ode,

 

 

 

 

 

or

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

me ns b ing

 

 

 

ble to swap

 

 

rom

 

 

state where th y

 

 

re

 

activ

 

 

to

 

 

 

 

 

 

 

 

 

 

one

 

 

but only locally. Tholeactivity of

conditions on an A

 

(cfpurposeswiandsethodof2.the3omen.1))-semanusedprivatethis[GR83]canprotocolschemeics. videproto(usingNotiaresucceSmallol,thesupposedthatprivwhicreialkcy,edystaex:to, compilerastheensibeforthatreturnxampleprivofmethin

 

ofreturnanticsma

 

(contexwillthe tics" .evymbol)aluatedassumeW evy requireat an the poppoccurng

 

in

 

 

 

 

 

 

of meth

 

ds (or

n

 

 

a blockreturnsactivaluat

 

 

exib libody:

the code

of

 

 

whenpre-

 

and

post-

 

 

 

 

iti

ns m y accesscompatibilthe eth d context,

 

 

 

 

 

modion: cati

ns m

st be as small as possi

le.especiallyTh

 

 

 

 

look

 

the

source

 

 

 

pre/post

conditions

 

 

 

 

(

 

 

and temporaries,

 

 

 

 

 

 

 

 

are acuseriv

 

 

 

 

 

 

 

), witheth

 

 

Figurenori

 

 

 

 

 

 

whicthe clo es

beturn),

(cf

 

 

 

 

 

4):

The

 

rface

 

 

vivial

interface

ou

 

 

 

 

 

parametershod

 

 

(wi

 

 

 

man

 

 

 

 

 

 

 

 

{

 

as

ociated

 

 

 

 

 

 

d while

browsing th

 

 

 

c

 

 

 

the activity

ofa the

 

 

 

 

 

 

ulations),of class

 

 

 

 

kno

 

thr ugh

 

is

 

v

therdevelopmen

 

ool

 

 

 

 

justbrowsery losourceking at methclass name

 

splay (

 

 

 

 

 

usinghange popup menu, as in conditionsSmall alk's usage.

 

 

 

 

pane of

 

browser),

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 : The

 

 

tly selec

 

 

class (NodeIt m) has

 

 

he menu (

 

 

 

s) that pimermits the

 

h ng

from ac-

 

Figureconditiv to nonconditio-activcurrencutedndiations

(and vice versassociated).

condi

 

 

ons

 

ns

 

 

 

ness et (cf (c)).

 

 

 

 

 

 

 

 

odes is ex

 

 

runt

 

. The gure also showits

 

j temporarireConditioj

. ]

 

preCondit on.

 

 

 

 

 

 

 

 

Thisexpr1[..sucnosynblockP....ticsostCow represenexcrearNhaviti

hodsbeenof..qua] areopostCondi ersedintrseveraltionced,advantages:.aswhoseselit iscto

 

 

wit

meth uldcombin

 

 

 

 

 

 

 

 

in [Coi90]. Ars,a

 

matt\parasitic"of fact, th

ationst soluti

 

su ers major

 

 

 

 

backs:

 

 

 

 

qual ed me hods p

lute

 

 

 

inte f

 

 

of the cl ss, and

 

 

 

 

no way

fromprohibit theidraus

 

 

as

 

 

 

block to

 

in ons

scribedn xt,

 

 

 

 

 

 

 

 

Using

 

 

 

 

 

 

 

a condi ion allows full ac

 

 

ess to

 

to

method context. It w

 

 

 

theirv

 

 

 

quitne

 

 

 

 

 

 

 

 

 

 

 

sucth a

methodsc

 

 

text with

 

dinditiocultthesemanipulatesidetherepresem thod

itself

 

(both

tempo-

 

 

 

s

nd a guments accderivss would

hav

 

been

hard

do not allow

 

 

Extensiontestconditionsto if

sho

 

ld absolutely

 

 

not

activ

 

pre/p

st

 

 

 

 

 

 

 

3.1 rariModelalize,

 

example).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

th ir

 

 

 

 

refore,urselv ac ive, thenmethod code needed f

 

 

Wheninterfere

 

 

ex cu

 

ur

 

ime.

This is

 

the

 

 

st -

p rtan

 

sp

ci cat

 

of

 

 

 

 

 

 

pre/post

 

 

 

 

 

.

activ . Th

 

 

 

 

the

estmeansus

 

be done

 

 

 

 

 

 

le time:

 

 

 

 

 

 

 

are

not

 

 

 

e, then

he

 

 

 

ndconditions

 

Th s poin

 

crucial.

It

 

 

 

 

 

hat at execu

 

 

 

time, w

 

 

gncutionand

 

 

th

 

 

 

 

method b

 

dy is

 

 

 

Thus, w rednditionsw di

renactivmpilation

 

 

 

 

 

 

.

Chang

 

 

ex

 

 

 

is gen

rat

d at compile

ime,

 

vice versa)

ng from ac iv to non-activ

 

 

 

 

 

 

 

 

 

 

 

 

 

at d.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ducmenthetionprogrammins1920xpreConceptuallyclasThisof.ionWsofnewsedcompilationextg, metaclasuchinrfacesubcla, termsourdescribeasonly19extensionssObjVLisp.doesinofofaMetaclassnotourhasystemregularvingcan[Coi87]soterfereconditionsbeutiallassimilatequick.20wingwith.basedexplicirecompilation(andhephasesurcehemetaclasstheinmatroducinagef-s

manag

 

b havior according to dev

 

 

pm

 

 

methodSmalltoicseplassmpiuB.ucllyer)Thusalkof(cfraisare2kpr.3>>dusrnel./post1)defaultoneretu2.2.condit1)compilerClaandns. thelevMetaclassWithControonsthe.fromThemethodswhosthatcompilmethodtheofinstaofcompilerrClassiscesgivencon(cf(a-

Class of the

 

 

 

(i.

.,

 

one of theBehaviornext w

 

viorClassmetaclasshod

) (cf A.1),

 

the

default

 

 

 

>>

 

 

 

 

 

allsreturns

 

ompi er that d es not tak

 

 

 

into

(and just fo gets

ir

 

 

sociated

code ),

 

 

 

 

 

 

 

 

compilerClasthat d als with conditions codes.

MetaclassfroMetaclassm

WithControl to

 

Metaclass

 

 

 

 

 

 

rol>>compilerCl

 

 

 

accounretur s

(and vice versa) using

the

changeClassToThatOf:

Thus (cf Figure 5),

f

 

 

 

 

 

 

 

 

 

 

are

he compiinstacl

 

 

 

 

whoseconditionsare notactiv-

iv is an

in tance of

 

 

 

.

 

 

 

 

 

 

 

done by dyna

 

 

ically

ha cglassWng theithContro[Riv96] of the

is

 

 

ce

f

co

d ons to

 

 

 

 

,

 

ones is

Changing

 

 

ctiv

 

nonctiv

method (cf 1.2).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

metaclass

class

 

Metaclass

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

namicallyFigureAnyClass5 .:The

 

 

AnyClass

 

s changes

its class

 

dy-

 

 

 

: is instance of

 

 

 

 

 

MetaclassWithControl

 

 

 

: inherits from

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

: dynamic

 

 

ss change

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

metaclassonllelynamicalwll Ahinwouldclassyourvelsaddedhavspecisubclas(cftaclacompilerClasses2.cation2proconnected.1:esw.Sma.Thisbyushavbehavior,bothAismethodandduebeenmoallto(cfwitsass).2icrited.subpar3and.1)is

 

no condevelopmdestedn tionwi hopicsnorsoinuievidedeir en inwou

 

.havThis( addedust

 

 

 

 

theirinsinheritancev ab

 

 

 

to

 

he

 

Clthassalk ss

 

n

 

 

 

 

 

,

 

 

in order

to remember the

activity at

 

 

 

 

 

 

 

. The

 

 

 

fault

 

co

 

 

 

 

 

 

 

 

 

w

ouldhaverface)to est neither

 

 

stance

 

 

 

ariable in order

to

 

an wer

 

 

 

corrtimect

 

v

 

 

-

 

 

 

iler.

 

Com

ared

 

 

 

 

 

ou s, th

 

 

last solu

 

 

 

 

 

 

 

 

 

 

 

expensiv

 

.

 

in

 

v

 

it

ionf

 

 

ass de ni

 

 

 

 

mp ct

 

 

 

nd

 

 

 

 

 

 

Mor

 

 

 

 

implies. It

nother problecom:

 

 

 

 

 

the

 

 

same

 

 

 

 

an

val

 

 

 

 

 

 

 

 

 

 

 

oned

 

 

whenClass

 

ilerClassbool fore release

 

 

 

not preasonablessib ation r,

 

 

prod

 

 

 

 

stage. Inclanoy case,

 

 

 

does not agree with

 

 

 

 

 

 

becasp ation that

 

 

 

 

 

not act ve,

 

 

 

 

 

 

 

should

w

 

 

(

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(cf

 

2.2.1)) isconditions

 

 

 

 

 

 

 

of

 

thMetaclasskernel \ rick" to

rmsis

 

 

the

 

 

 

 

 

 

ininstancet

 

 

 

 

 

 

 

 

 

 

an applicatito

 

 

 

 

 

sed,

 

its classes

haeryv

 

 

 

 

 

 

spaceucboth

 

 

 

 

 

 

 

stru

 

 

 

 

 

 

.

 

A rec

 

 

p

 

 

 

 

 

 

 

 

of

 

 

notmen

 

 

 

 

 

in anywheny withcture

gular

Small alk.

 

 

 

 

 

 

 

 

u

 

 

 

it would

 

 

 

 

 

lo ger

b

 

 

 

 

 

 

 

 

to hav

 

both

 

 

 

\development"

ion

tance v

 

 

 

 

ablealllw ys

 

os

 

 

 

 

 

 

 

 

 

 

rele

sed

 

applclass

 

 

 

nd appl cati

 

 

 

 

the dev -

d ed,

 

f

actterferensiv condit ons are

 

 

put nsionMet

 

 

ss,

 

its

Finally,

 

otice that

th

 

 

 

 

 

 

 

 

 

 

extpossibleil u

 

 

tes

 

 

 

 

 

at

 

 

xt

 

 

 

 

 

eness

 

ol,

 

stead

 

of

Met

class, whthec

 

 

 

 

 

 

 

 

 

 

f

 

 

the

 

Small

alk

 

kernel.

 

 

 

 

 

In-

regr

ssion. Mor

er

 

 

newmodop in

 

inhe niteantiation

 

 

 

 

k

pp ars when

Metacl ssWithCo

 

 

 

 

 

 

 

 

its condit ons

MetaclassWithContrb extended, without causing the whole system to faeasil.

 

d

epest partof

 

Small

alk kntrolnel (cf 2.2.1) can

 

 

ery

ctivity set to true. This demonst

ates that even the v

 

 

 

3.2

 

 

Environmen

 

 

Exte

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

xt to be accessible from conditisioncodes. From ancon-

Our

 

 

 

 

 

of syntactic conventio

 

 

 

 

 

 

ws the

method and

 

rfachoicepoin

 

of view,

the user

loalloks at i s

associated

condition sources at the same time.

Practical

 

dd

 

 

 

 

Asneww metahav lassextendedcriptionthe

tomod

 

 

withorderdevel

[RM93]:bythisemaanglobalticsddewcsngtopics,areintrdescriinabrowsercospectionxedaccoubroperation. wsers.doesThus,t,classStandardwbetnohouldtomodsimplyeenrderalso,Smally takheskealforandlkthate tonewthebroaccounterfwnamtoce-,

MetaclassWithControl>>browsingNingNaassumeadd the '(c)'

string

 

 

 

su x

 

to

the name (classOnControlString

opmeneed:

 

 

 

ss,

 

but

 

for

 

its

 

 

 

 

 

 

 

 

 

.

With thiss

of

the

 

 

 

 

 

 

 

 

 

what

 

 

 

 

ssage,

 

class fully

controls

 

brow er

showser.

 

 

thod).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.3

 

 

 

 

Compiler Extension

 

 

 

 

 

 

model and

Havi

 

g

 

esigned the structu al

 

part of

 

 

s

h

 

needed codes for activtermspre/post

 

 

 

 

 

.

 

 

 

 

w

 

 

 

its implication in

 

 

 

of interf ce

 

xten ion, w

 

 

w

 

 

 

Our

 

 

 

 

is

 

 

 

 

 

manipulation of the parse

 

 

 

ion

f

he post-

 

 

 

 

 

methv

 

 

 

 

 

 

doexists)an re urn

 

 

 

 

 

 

 

 

to extend the

 

 

 

 

 

 

 

 

in ordther to manag

 

 

 

 

 

hat

does

 

ot returncompilationtrue xecution time,

evalua

 

 

 

 

 

 

 

 

 

 

 

xception f

 

 

 

 

preconditions-

 

 

tree, which is generatedbasedy the Small alk par

er. W

 

 

 

 

 

 

 

 

 

possolution

 

 

 

 

 

-condi

 

 

 

 

(if

 

 

 

 

 

 

as the

 

 

 

 

c ndstatraison,

 

the

 

pre-

the

st

 

 

(if

rais

 

 

thexcep

 

 

 

 

 

 

W

 

 

 

 

 

 

 

 

 

 

 

 

be ev luated.

 

 

 

 

wrap thealuationposten one method using

 

 

 

 

rst

 

 

m

 

 

of the

 

 

 

 

. W

also add the test

 

 

 

 

last

 

 

 

 

 

of

the

hod.

 

As

 

with

 

 

 

pre

be thevalueNowOrOnUcode if ere to decompile the parse tree after

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

windDo: whicthatallows

xecution of

 

 

 

 

or wr p withinadd blockClosure re eived as

an ar-

 

 

 

 

true.

As

 

eturpostmay occur (in th

 

 

 

 

 

 

itself

its reshaping:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Nextgumengiv an equivconditionalen syntactic form of what could

 

 

 

 

the

 

t),

 

 

could cause

 

 

 

 

 

 

-conditio

 

 

 

 

 

 

 

ost-condition

regardless of what

happens.

 

 

 

[expr1..blockPostCond....rWitexprN ] valueNowO..pos]reConditvalueOnUnwindDo:[ifTrue:tionSignonSignaal.

 

 

 

tions areAs wctive,subclassneed a ofewthecompandardwhenaiseRequest]p classclassis]in. We

whi

 

i

[Parsthe rser

 

 

 

 

 

 

with Pars

 

 

 

 

e/post

condis,

 

 

 

 

 

 

 

 

 

 

with the new

 

 

 

 

 

 

 

 

 

 

class throughassociatedredthe niti

 

 

of its pr ferr dParserClass

subcelassm

 

 

 

 

and itsclass

 

 

 

as

 

 

 

 

 

 

 

 

SmallhControlalk

1

 

 

 

 

 

. A paris

 

 

 

ee is

 

 

 

 

 

 

 

 

method

 

 

 

 

 

bta nedregularas

 

 

 

(cf 2.3.

 

 

 

 

 

 

 

 

 

pa se

 

 

 

rsedto

get

 

 

 

prev ou ly

 

de

 

 

 

P rse Wi hContaParsCompilerWithControl>>compilePreCondition .

 

 

-

 

 

 

 

(cf 2.3.1).

 

 

 

 

 

next

de cribe the steps that p

 

 

of the

rst step of the

 

itions:lation proc

s,

 

 

 

 

 

mov

scribmethod

 

 

rm

 

tion.

During

 

the

tranhapesforma-

 

pre/postransfcondition

 

 

 

des, if any.

 

,

 

sult

 

 

 

 

 

2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3. he pa

 

 

 

 

ee generates regular Smallted,alk code.

 

 

us,

 

 

testsactive, condinstanceo condi

a ect the run

free

 

 

regulparser,ser

 

(an

 

 

 

 

 

 

 

of theParser

 

class)

 

 

-

 

 

ion,

 

new

 

 

Pr

 

 

 

 

 

 

 

 

 

 

 

are

thecr

 

 

 

(cf

using

 

the

 

 

p

 

ser builde ,

 

aProgramNodeBuilder

 

ode A.1)

fromresultany

 

 

 

 

 

 

 

 

 

pr

/p

 

 

 

 

 

ions

are not

 

 

v .

3.4

 

Benchmarks

any condititons both (i) with

 

 

erformancewh h is free

from

 

 

 

 

 

major goal of this

 

xte

sion is

 

provide code

 

 

 

 

 

 

 

 

 

 

at

 

all.

 

 

When

 

 

 

 

their

 

 

 

 

is

ex

 

 

 

 

 

 

our extension, and (ii) using our

xtension withcutedhodn-

 

 

ditions activitaky

 

set

to

 

true. The

compilation time

accord ng to

 

 

 

 

c

 

 

de

 

wrapped ar undcode conditi ns,

Thw ich

of course

 

 

 

es

 

 

 

 

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

pilation process:

 

 

 

 

 

 

 

 

 

 

 

 

aken

 

compile

 

me

 

 

 

1.

 

W

 

parewhen time

 

 

 

 

 

-

 

 

 

 

akthe

 

 

 

 

 

ign

canctivbenchmarks

 

 

the o

4

 

writingfromequivConclusioneragealen9%factodequickhathandtheusingthansourcewritt(ii)tocondit.byparseThtheonsisresultssmallerextension. (i)mainlywheis .

W

hav

 

 

 

 

esc

 

 

the

curr

d

 

 

 

re ectiv

 

 

 

 

 

of

Small alk. Wibedhav presen

 

 

 

 

 

 

most impo

 

cur

r

 

 

aspects:

 

 

-

 

 

 

 

 

 

 

 

 

 

ion throughfacilities

 

 

endi

g

and behaviooperations,al pres the

 

 

 

scrib d an

 

 

 

 

 

f re

 

e use with

he introduction

 

 

 

 

 

of theexampleconditionstime stac

nk (Depende

 

 

 

 

 

 

 

 

 

 

mantics

conmetath ough he

 

 

 

i

 

 

compiler, mes age

 

 

 

 

As it evolves, Sm

ctivalkthe

 

 

 

to

 

 

 

 

 

 

 

mains,abilitmay be considered as

 

 

 

truly perennilanguagcyTransformeapplicflectionnguage

and

 

 

of

 

 

 

run

 

 

 

proc

ss

 

 

. W hav fullymodel,

 

 

 

 

 

 

re ectiv . In particular class/metaclassw quote the

ei -

grationmorexpressivthepo

 

. Becau

 

 

 

the

 

.

 

 

becomepossesseits

of pr /post

 

 

 

 

 

into Small

 

 

 

 

the

 

 

 

g

 

 

is the heart of Smallde nitionalk.

 

 

It

 

gives

 

 

R

 

 

 

(P rs rCompiler class),

 

 

 

of

in

itself.

 

 

 

eneratore

class),

 

 

 

and

 

 

 

 

 

 

 

 

 

 

alkparser

 

the

 

 

 

 

 

y to naturally adaptwrittenself to

 

w

 

 

 

 

 

 

do-

Acknowledgments

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I

 

 

 

 

of

 

 

he paper. Special thanks to Jacques Malenfant

 

wish to

 

hank all the review rs

 

for their

comments.

zationw spento time on the

elaboration of the inal version of

T

anks

 

 

 

 

Pierre Cointe who

 

 

 

lped me

 

 

 

the organi-

the paper.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

References

 

 

 

 

 

 

 

 

 

 

 

 

 

 

:

A

testbed

 

for

Bri89]

 

 

 

 

 

Je

 

 

Pierre Briot.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Cl ssifying and

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Languages in

 

 

 

 

 

 

 

 

 

 

malltalk-80. In ProActalkdi gs of

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

th

 

ObjVlisp ModDesigningl. In PrActorearengsECOOP'89,of

 

 

 

 

 

 

 

 

 

 

cember 1987. ACM

 

Sigplan

Notices.

 

 

[Coi87]

 

 

 

 

Nottingham, July 1989.

 

 

 

 

 

 

 

 

 

irst Class:

 

 

 

 

Pi rre Cointe.

 

 

ta-classes

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SLA'87, pages 156{167, Orlando, Florida,

De-

FM94]BW93]

Don90]M95]

FJ89]

GR83] ra89] HJ95] Ing78] [KdRB91] G76]

SLA/ECOOP'90RWhclassesDesming1993McottLA'94.Gdduri.gn. -.GabrielDanf,SpacCLOSTheIn.NicortlSOMMetarth,mpositionCLOS.land,inIn.DemersdCoIraOctoberObjeOregon,InersptextR.GPrfun.. Forman,BchiteOrictiv-Bobrow1990OctoberThefore/Aftedingsnte..ComparShapeMITHandlingProf1994Press,MetaOOPofgramtheirHari.J.L.

Forienfantudy.coistedRe -progrectiWorkshopin mmingin lpagesgic,: aaShortdtionalJacquesandtoMbjecttiven

Applicection.ationd 327{335,AI-LevelofA29{38,IJCAI'95grammingcturAugust: On1995R . ChristopheBrianndsynthObjootesis.-OrientedDony.In PrExceptionOctoberdings of OOPwardsdings OOPSLA'89,F andSmalltalkR lph 322{330,. JohnsonIn 1990. Re. ec tivTheofumeFacilities24, pdingsage in ACM Sigplan-80. Notices1989Pr c. , vol- son.icolasGWesleyldbergngu Rea ingOOPSLA'89,Dits. RobsonimpMassacImplemenementation. uCompatibiliSetts,alltalk1983Addi-80,. NIn1989ortticPrHeart. Graubevolumof. 24,Metacpages 305{315,ACMOctobDeepSig lanty.er B b julynkle and RalTheE. . Ini thep of1995Smalltalk. . In The Smalltalk R DmingG5th.HegorPOPL. System. IngallsKiczales,pagesDesign. 9{17Theand.Smalltalkuscon, Arizona,-76 tationProgr1978and. m. structionjeanielPr Gto. olBob. arc,CowmbridgGoldberg. JimAlto,desArtMITCalifornia,ofRPrvitheecss,res,Metaob1991. A.port,KaXeroxandManuPA. Palo/ SSL-76. -6Smalltalk. T hnical-721976.Inre-

MLP90]oo86]ey90]

Par94b]a] s86] C94] iv 6]5]

[RM93]

[Sie94]

06, 1992Rlk.

(v lume and1).

JohnPren

R

 

-PughHall .InIn ide

DavidWilfBertrand1990SmalterEdion .parEonsLalondeiti.MeyertirageMoonEnglewood- .v1991,rsionObjeeptionFrance,franClitice-Ors,1990iPrense.gr. ammJerseyternaIn

 

 

 

 

ing

with

 

FlavConc

.

In

Pr Newd ngsProf

grammSepte

 

A'86ns,pages 1{8, P

 

rtland, Ore on,

 

 

 

 

1986.

ACM Sigplan N

ices.

 

 

 

ObjectMemory

 

class

metaclass.

Description

of the StackSp

 

 

 

in VisualWorks2.0. Tech

 

nical

 

report,spaceDescriptioP rcPlace System,

August

ings

of

 

 

 

 

 

 

 

 

 

 

 

A

 

 

 

 

 

 

 

Inc, Notices,

OOPSL

 

 

.

Systems, Inc,

Sunnyvale. Visual

 

w

cPlace

 

 

 

 

in

 

allt

lk-

0.

Pr

 

d

 

1994.

 

 

 

scoe.

 

E capsulators:

 

A New S

ft

G.A.

 

 

 

 

 

 

Works

 

 

 

lease 2.0 of 4 August 1994 1994.

 

 

Clas

 

Rivaradigmand

Pierre

Cointe.

From Envy

 

 

 

 

 

 

 

to Ada9x -

 

 

 

 

Progress Report

pagre

 

341{346, Nov mber 1986

 

compilateur

 

 

 

Rivard.

 

 

 

Ext

 

ion

 

du

malltalkOOPSLA'86,ApplicationFinal

 

Sigplaram trisa

atifs,qu January

1995.

 

 

 

 

 

 

 

 

 

 

 

 

T

h

 

ical

 

 

eport, OTI-EMN, December 1994.

Journees ancophones

 

des Lang ges Appli

 

red

Rivard. Dynamic Insta

ce-Cl ss Link.

 

 

 

 

 

de l'envoi de me sage. In Actes des

Submis

 

 

 

 

 

 

OOPSLA'96

F bruary 1996.

-

F.

 

 

 

 

JFLA'95. INR

 

 

 

-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

J.

 

 

 

nfancollection. Brow ing

 

 

Explicit Me

 

 

 

 

La

 

 

 

En

 

 

: an Esdidacy

 

 

 

 

 

 

 

seau

 

 

 

 

 

 

 

 

 

 

 

 

.

 

 

Rebjeectiv-OrienteProgrammiand amming, OOPSLA'93,

Siemens. Simatic Object 5 O ine. Technical

on Rou ction

 

 

 

 

Metalevuagesl vironmencturA chite es

In

I

formal Pr aclassings of the Third Workshop

report,

 

Siemens,

 

1994.

 

 

 

 

 

 

 

 

 

 

 

 

October 1993.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

swapControlsBrowser\Changingome comp thelat on controlsof the or vice versto"get MetaclassswapContrand\I getexecutionmels compilationcontrols "

 

 

MetaclassWithConswapControlsexecution\I don't wancontr lsmpilationtrolany more"and

j

 

 

 

 

RequestsNj selfi ifTrue:[nonMetaClifFals1234]:[ 1234]. .

.

 

self toMetaclassWithControl

 

self toMetaclass

Cur

 

 

wait

showWhile:[ met

wapControl].

 

 

 

 

 

 

 

 

 

clelfssNhanged:= metaClassmebrowmetaclassingName.

 

 

 

 

 

 

 

 

 

 

compilerCBeh vior

 

 

#classN

to

Metaclass

 

c mpiler class to

 

 

\Answ

 

mpiler class to

 

 

 

er

 

 

" Compil r

 

 

 

metaClass" elf

mpil rClaclass"

 

 

 

 

 

" Compil

rWithCon

source

 

 

 

ds of this

 

 

source

thods of this class"

 

compilerClasssource

ds f his class"

\Answer an

 

 

compilerClass\Answ an

 

 

MetaclassWithConself classOnControlString

 

 

 

 

 

\Answ

an appropriate

Clas

Descripti n

 

MetaclassingNameelf soleI stanceappropriatenam

 

 

 

 

 

 

trol

"

elf

class

brappropriatewsingName

 

 

 

" (super browsingNa ,

bro

ingNmeth

 

 

bro

 

 

 

 

bro

 

 

 

 

browsing name."

 

 

browsing name."

 

 

 

browsingNamename."

 

arser

 

 

 

 

 

 

 

 

 

 

ars rW thControl

 

 

 

 

\Just forget about the preand post-conditions"

 

 

\

the pre and post condition if they are valid"

compilePrePostCondition

 

 

 

 

 

compilePrePostCondition

isNil

 

 

) asSymbol

 

 

 

 

 

 

ostCondition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

isN

 

reCondition].

 

 

 

 

 

 

 

 

 

 

 

 

 

ifFalse:[self compilePostCondition].

 

jifFalse:[block statemCompilerWithConj trol preConditionSignal

aiseRequest]"

 

preCondition := builder

 

 

selector:ction|||||rguments:#value#() .-

er:

 

 

receiver

 

 

 

 

 

 

 

error block

 

 

 

 

 

 

 

 

 

block := builder

 

 

 

(b

 

ilder

 

 

 

argumselnewMessageReceiver:or: ts:

( builder newVariableName: 'CompilerWithControl')

"|||-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

constrk con

 

truction|||{"

 

 

 

 

 

 

 

 

 

preConditionBl:= buildernewMessageReceivnewMessageReceivr: #preConditionSignal

 

 

 

 

 

 

 

 

 

 

 

 

 

selector:

#ifFalse:

 

 

#())builder

newBlockArgum ts: #()

 

 

 

 

 

 

 

 

 

 

 

 

arguments: (Array

 

 

p rseNode body statements addFirst:

statemenwith:.

 

 

statements: (Array with: block)))).

 

 

 

 

 

 

 

 

 

 

select

 

 

#raiseR qu

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

arguments:#().

 

 

 

 

 

 

 

 

 

 

 

 

 

statemensel umAOrderedCollgs time Rep at:[ws

nextPutAll: 'with:'].

body: (builder n wSequenceTemporaries: #()

Act

 

jCompound

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

newMj

 

 

 

 

 

 

 

 

 

 

 

 

 

er: rcvr selector: sel arguments: args].

 

False: ["gramNodeBuildersup

 

 

 

 

 

 

 

ssageRec iver: rcvr selector: sel

 

 

guments: args

 

 

 

.lkPrct

 

 

are asynchronous

 

messages"

 

 

 

 

 

 

 

 

 

sel

umAr

<= 5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

. 99.1 purcen

of the symbols "

 

"optimizi

 

 

fo

newMessageReceivthan 5

 

 

 

 

(tab :=

 

 

 

 

ction

 

 

ith:

 

(self newLiteralValue: sel selectorPart)) addAll: args.

 

ws

 

extPutAll: 'addM ssage:'.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

"self

 

 

argum

 

ts: tab asA

 

 

y].

 

 

 

 

 

 

 

 

 

 

 

 

 

 

newMessageRegeReceiver:

 

rcvrcvr

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

selector:

#addMessage:arguments:

Liter lV

ue: l selectorPart)

 

 

 

 

 

argumenewMessts: (Array

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ifTrue:[ j tab j

 

ew: 100)

 

 

 

iteSt eam.

 

 

 

 

 

 

 

 

 

 

 

:=

 

 

ing

 

 

 

 

 

 

 

 

 

 

 

 

 

"self

 

 

 

 

w: 100)

 

 

er:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ws := (String

 

 

 

 

eSt ea .

 

 

 

 

 

 

 

 

 

 

args size

tim sRepeat:[ wstenextPutAll: 'with:'].

 

 

 

 

 

 

 

 

 

 

selector

ws

on

 

with:

sSymbol

 

 

 

 

 

 

(self

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(self newMess geR ceiv

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

arguments: args))

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

newV

 

iableNam :'Array' )

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

selecto : ws conter:nts asSymbol