On the Semantic Diversity of Delegation-Based ... - CiteSeerX

1 downloads 0 Views 2MB Size Report
eit#lier in t,beir behavior. (e.g. Self's .... sage legs is sent to Fred, no corresponding ... a niessage to Fred, a method found in Clyde is applied in t,he con&A of t,hc.
On the Semantic Delegation-Based

Diversity

of

Programming

Languages

J. Malenfant * IXpar-ternent

cl’informatiyue

et. recherche

otxkationnelle,

Abstract ‘l%c

protot,ype-based

programming

IXWI difficult

t,o cliaract.erizr c-oilcvte ol3ject,s

a.d~orat~es

model

has

alwa.ys

precisely. Its basic principle a.s t,he only 1nea.u to model

coiicepts. yet curreut laugua.gcs proin0t.e u~et~l~odologies rriut~roduciug abskact. coiistruct~ioiis to manage effgroups

cieiit,lg pose

granuniug els going cluce

of similar

a. rat.ional

objects.

reconstructmioii

In t,liis paper,

of delegation-ba.srd mcl we discuss models,

which clarifies t liese t,ivr inerit,s. We finally and more

forming guages

pro-

languages that, identifies programming inodbeyond t,radit,ioiial pro1 ot,ypes. We also iiit,ro-

a 11ew classifica.tion

of more

we pro-

of delegat,ion-based

hriiig

struct,ured

t,o the

fore

the

delegat,ion-ba,srd

a continuum bet,weeu a.iid cla.ss-based oues.

pure

languages, their rela.exist,eiic-e languages

protot.ype-ba.sed

lan-

UniversitC

Prototype-based posed

more

t,liat, factors

st,ruct~ural

iuforniatioii

clone

i.e. a. group

family,

obt aiued

languages have been proago. yet it has been quite

a. drca.dc

OII coi1cret.e

oues.

only.

ohject,s puw

t.liey were attribut,ing a problem

ot.her iinportant

source

we dealt,

of confusion

gramming

t,ec-huiyues

age groups (e.g. Self’s

of similar traits ohjrct,s) A traits

Maps

If indeed

prot.otype-based

a much

richer

fact..

against, the very uoas it, has IXYW orig-

iut,roduce

stmructural

much

traik

aud

prograniniing,

more

st,audaloue are

from

t,liein

t,hat, delegation-based diversit~y

descrip lauguages

maps

notmion of dclqot?orl-bus&

we show

“prot.otype-leased” This

tmot,he same has been several

aud n~echauisms invented eit#lier in t,beir objects. or in their object

priiii-

wit.11 in [5]. But

1.0 inam behavior

represent,at,ioii

is a repository

anpro-

(e.g.

for met,l-

alieu

t,o

emerge

proyrumm

rng.

la.uguages

es-

t.liaii it first a.ppeared,

because programt,lie sauie

hat..

paper

proposes

delegation-based

fereiit

maps).

another.

while I>rot,otype-based tors a.!& t,o classes, were an at,teinpt. to build languages around

grail-uuiug

it,ive operat,ious,

iii a

objeck

identical

iually defined, for example by Lieberman [9]. Traits int,roduce a l&d of ahst,ra.ct object while prot,ot,ype-based languages a.dvoca.te a progranuniug style ha.& solely

classificatmioii

Self’s

out, of 0bject.s

Trait,s and maps are clearly going t.iou of prot,ot,ype-based programming

difficulty t,o clearly charackrize t,lieir exact, programming model. Part, of t,he difficult,y can he at~tributed to t,he difseinant,ics

applying Taot,he whole A map is a descript,oi

of st,ructurally

one

by cloning

CIANA4D.4

tSliese new mecha.iiisins impose sliglit.ly different. ining models, which can haidly be put, uuder

programming t.bau

Qu&ec.

variables) objects.

In

Introduction

Montrial.

ods (aud “semi-global” group of its delegat,iug

hibit

1

de Montrdal,

a.

prograiruniug

languages

defined

coniplrt~es

also t,lle one present,ed well as our previous

kinds

ent, kiiids

of links

parelit.-of

link

c-la.ssificat,ioii

in t,hr Treat,);

oue [5] dealiiig

of objett,s they

[lO].

of

of pro-

Our

uew

by \4Te%gi1f:r,hut

of Orlando

[iii] as

wit811t,he priiiiit~ives

of

We clmsify drlegat~ioiiaccording tmot,he number aud

t,he number

iiiauipulate.

of delegatmiou

a class

by Weguer

t,lic oiie proposed

protot,ype-based prograinming. based progra.tnmiug languages of different

iirw languages,

i s oue

For link

of differ-

example,

t.lir

niauipulat~ed

iu

all delegat,ioii-based prograininiug languages. Similarly, a t,rait-based programniiug language manipulates t,no kinds that Permission to make digital/hard copy of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage, the copyright notice. the title of the publication and its date appear, and notice is given that copying is by permission of ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. OOPSLA ‘95 Austin, TX, USA 0 1995 ACM 0-89791-703-019510010...$3.50

of ol,jects:

concrek

oues

t,lie number

of kiiids

of links

lat.ed iu a. language

bears

t.ure of it,s programming

and

trait,s. aud

We propose

0bjrct.s

niaiiipw

import~aut~ iusight,s

int,o t,he na-

model.

four classes

\Ve explore

of delegat,ious-based languages: languages with oue kind of ob.ject, aucl one kind of link. ones wit,11 two kinds of ob ject,s aud oue kind of link, oues wit,11 two kinds of ob,ject,s aud two kinds of links aud fiua.lly ones with oue kind of

215

object,

aid

But.

t,wo kinds

what

exactly

of links.

constitut,es

01

a new kind of object.

constitut,es

a link?

To answer

and what,

these

questions,

our a.pproach st,udies bot.11 t,he programming methodology and t,hr seina.ntics of four specific languages: a prototype-based la.nguage in t,hc line of Lieherinan’s first, proposal, and

a. trait,-ba.sed

language.

a descriptor-ba.sed

low us t,o point language

out, exact,ly

differences

subsets

of object,s.

participation

Our

al-

in the seniant,ics

of a

(or do not, appear)

also allow

languages

classification

of delegat,ion-ba.sed st,ructured

brings

to the

languages

programming

always

been

slots

criti-

forming

and

more

program

explicit,

a.u object-cent,ered a. st.ep

Inore

programming

by step

(possibly

without.

ruodel.

a.ut,oinatic)

The

rest

of t,hc paper

is organized

sacrificing

it, a.lso suggest.s

transforina.tion

protot,ype-based programs int,o cla.ss-based gra.mming met,hodology advocakd before

method for adding points

and

1: A point, example.

1, a point and add.

their

activat.ion

of

as the

t,wo clones

don’t.

these

forin

c9wtio9~-t291~~

value

of sharing

In Sec-

solely

But

there

not unique

modify

values.

the cloning

for this

by a tnrssage

sim-

wa.y t,o create

is cloning. i.e. slia.llow copying a.n exist,Cloning has the side effect, t,hat, as long

t,hey will share slot from

ob.jrct, 01 1la.s foul ,T. 1, The t,wo rust, SIOW

t,lie two last. ones conktin esecut,es the correspond-

The chief alt,hough

new prot#otypes ing prototype.

ones. a pro[I$), 151.

a.s follows.

values,

ing met,hod.

a cont,inuum

languages and class-ba.sed that, the organizat,ion of a

be nrade

method for displaying points

-+

For example, in Figure named x. y, display

contain

between pure protot,ype-ba.sed ones. Kot only this shows can

------a

ply ret8urns that value! while methods, and their activation

t,he existence

wit,11 a inore

model,

add

t,he

iii programs.

fore

20

Figure

of the langua.ge.

organization

Y display

between

us t,o ma.ke clear

ha.ve

lack of manifest.

10

language

observat,ions

of a liidi to the seniant.ics

for their new

Our

where

appear They

Prot,otype-based cized

a map-based

language.

X

t,he value sharzng.

until

of their

In [5] 1 we have since

slot.s,

Aled

this

it, la.st,s for a

one of t.he clones

changes

i6s

slot. is niore

concrete

t.o protot.ype-ba.sed

objects.

Inheritance

languages

t,han

is a.lso t,raded

for

tion ‘L. we coine ba.cli in inore details 011 t.he prototypebased programming model and just,ify t,he int.roduction

clelega,tion. a. nrechanisru by which an object, that. cannot answer a nressage can delegat#e it to it.s parent. Delega-

of a new t~erminology,

tion is to concrete ohject#s what, inherit,aiic-e is to classes: a mechanism for sharing information. For esa.mple, con-

t,o capt.ure ining, guages. In Sect,ion la.ngua.ges

with

nanrely

object,-cent,ered

t,he essence

3. we introduce

one kind

progran-

of delega.tion-ba.sed

of object

t,he basic

lair-

rat,egory

a.nd one kind

of

of links,

for which we propose a la.nguage based on Lieherman’s basic assumpt,ions. In t.his section, we develop the conplet,e syntax

aad

senrantics

of t,his language,

which

sider

the objeck

sage legs

in t,his object,, Clyde.

will

Clyde

is sent

As with

t,he nature

which

therefore

in our

receiver

and

develop

t,he senmntics

of three

conclusions

2

and

fut#ure work.

Object-centered

concrete

esaiuples

programnuning

(objects)

rather

than

In Lieherman‘s

propert,ies understand scriptions,

prot,otype-based

original

representa.tions.

abst,ra.ct.

model

and

so values

if t,he sta.te of Clyde

t,o languages t,hat, aba.ndon the t,radit,ional view of object,orient,ed progranuuing, nainely class-based languages, in favor of a.n object.-cent,ered model. Protot.ypes a.re ob jects t,hat, exist 011 their own. without. classes t,o describe

of Fred,

simply

and creat,e them. ing bot,h instance

delegation

philosophical

self.

statement.

They are collections of slot,s representvariables a.nd met,hods.

i.e. t,he receiver

proposal.

delega.-

use delegation

is dominated

by

t.he

because

Fred

of s1ot.s.

In our previous

is modified, shares

so is t,hc sta.rc

wit,h

Clyde

(and

with any other object, delegat.ing directly or indirect,ly t.o Clyde), t.he values of Clyde’s slot,s. Bemuse t.hjs forin of sharing la.& as long as t,lir t,wo objects exist, (if t,hr life-time

216

to

not, change

of delegat8ion. It is t8remenclously import.ant t.o that, wit,11 delegat,ion, we no longer share dea.s with class inheritance, but rat her c0ncret.e

example,

This

t,he niessagc does

sending a niessage to Fred, a is applied in t,he con&A of t,hc

led

(c-lasses).

delegat,es delega.tion

tion is used to snake Clyde act as 1.“~Otot~~cu1 i92sta92c~ of elepha.nt: using t.his prot,otypical insta.nce, we can c-reate Fred differentially by including ouly t,he slots t.1la.t

The

ating

Fred.

2. If a noesslot is found

differ from the prot,otypical inst,ance and to share Clyde’s defa.ult, charact,eristics.

Prot,ot,ype-based programniing [l, 18. 9, 8, 15, 131 puts forward t,he fundaii-ient,a.l principle t1ia.t. people’s nat,ural way t,o gra.sp new concepts is genera.lly t,o begin by credescript,ions

in Figure

of t,he pseudo-variable

of t,he niessage. When method found in Clyde

classification

Fred

no corresponding

inhcrit8ance,

serve as suMrat,e t,o derive t,hr three other languages. In Sect.ions 4, 5 and 6, we introduce the t,hree ot,her classes t,ypical languages illustrat,ing each of them. We suniniarize t,he classificat,ion in Section 7 and we fiually close on

and

to Fred,

link slm971~g.

cannot

be modified).

we have

ca.llcd

it.

object-centered ming paradigm

programming: a programwhere the main act,ivity during

progra.m

design

revolves

concrete

ol3jrct~s.

class-centered paradigm where design

2: Clyde

revolves

ceiit,ered

a.nd Fred

around

program

ohjeck Diversity

in delegation-based

i2notml~rr impoltant~ i.liaf. deserve5 any

notion

aspect.

a more

languages

of protlotype-based

cornp1rt.r

of group

of objects.

is t,lir lack

Because

there

classrs, we cannot, speak about t,lie instances so t,liere is no clear iiotioii of similar objects, t,heir behavior t,heir st,ructure

programming

coiisequeiicc

c-oiic-ref.e ohje&

obJcct,s \;eiif,s one from iiiiiiilnal

(somet~liiiig

based

of ohjccts

sucli a.s t,lie oiies crra.t,ed prot,ot~);pical

beeii

is

facing

such gap.

ha.s att,ract,rd

needs. Self,

nicely the rfcloiiiiig

t.he prototBypeiniplcmeii-

f,ation effort,s t.o dat.r. t,ackled t,hese ISSUPS by inventing f,rait.s and tiiapsI a,s we poiiitmetl out, earlier. Such coiist~ruc?ions

are

a threat.

t,o tradit~ioiial

is needed, why not going back to cla.ss-based I.;nfortuna.t ely, t,herc is soiiietJ~ing no class-

based

laiigua.ge

offers

wing

do. iianiely

the

jects.

Even

t.hough

t.he point.

among

progra.nicoilcrete

cla.ss-based

that,

with

to ensure a.bst,ractioiis preventing

absf ract

ing messages

or, creat,iiig

hem

more

wit,liout

granuning

model.

pro-

is simply st,ra.tegies

a sharing

mecll-

bef~wefn maps objecf,s froiii rrcciv-

autmonlatically.

it, l~rcoiiir~

iu dclegat sacrificing

iombased their

Iiceping

possible

to intro-

prograulmiug

ol~ject.-cmt,(~red

pro-

Languages based on one kind of object and one kind of link

Wegner

[10] clivicles

object-ceiit.ered

prograiiiining

lan-

object-based languages, of ohjert. and no link,

languages,

i.c.

and one kind of link (the cla.ssification undercst,imates prograniiniiig

d/rcYs

‘~clmslf

he

We

per a.s its super.

correspoud

The

two result,iug

componeut.s

are t,hcn

combined in such a way t,hat a message uot answered by 01’s uow ground wrapper will be forwarded t,o 02’s

to self and super. Creusiug a. clone-expression

(clone P) ~ which shallow copies t,he object. denot,ed by 6 a.ud returus the iiew object. as result. An alt,eruat,ive wa.y t,o create 0bject.s is the newInitials-expression

ground geuerat’or. Wrapper application is defiurtl II\; t IIf> operation D taking a wrapper and a genrrat,or aud rct,uriiiiig a geiierat,or, while left-biased ohjert. coinbiuat.iou is

(newInitials

defined

f

(m*)

oh.iectm wit811 slot, names deiiot~ed

by t,lie expressions

ret,urued ject

as t,hr result

clenotled

ret,urus syst,eiri

(P’) 1, which denot,ed

r* : this

by c a.s parrut.

Fina.llg.

The root-expression

akin

(root)

t,o lambda-

For more information curious reader cau refer Denotational

In t.hr following,

we propose

a denotational

t,his

la.uguage.

For

the

wmpper

seinautics

idea

t.hat,

introduced

models

objects

01~jer.t. 01 be a fuiict,ioii from defiuecl lat,er) ( whose semantic The

is

semantics

[4], which

is t,o obt,aiu

(~1:

root.. t,he first, object, iii t,he root, of the delega.tiou tree.

for

ject.

which

t,o creat#e nirt~llods.

nlinirnal

by t,he operat,ion

values

will have t,he ob-

we ha.ve method-espressious,

Wrapper

berg

a new

slot

new object,,

of t,he expression.

as result t,he object which serves a.s the

expressions.

creat,es

by m* and

semaut.ics

mat.ter.

by Cook using

md

fixpoints.

selectors doniaiu

to values is defined

01 by ta.king

(t.0 be

posure

as Oh-

the fixpoint,

to deuotat,ional

ou senlaut,ic

of

t,echnical

issues

det,a.ils

is writmteu in direct

a few import~ant

In the followiug we a.ssunle concept,s of object orient.ed

an

semantic

a fa.mi1ia.rit.y progrmnnriug

semant,ics.

relevant

scniaut,ics.

wit.h t,hc basic aud some es-

We have t.ried t,o focus

to our classific-atiou.

t,hat, ca.u be skipped

dcferiug

over at. first. rcatl-

iug t,o t,he appeudis. Valuat,ion (see Fig. 5) take au esprcssiou,

as a function of the form syer argument corresponds

let*-bouud variables aud niet.hod forinal pa.rainet.ers. object memory which si.ores w1la.t. we call uieniory

a. function

is called

is Object --+ Object t,he sernautic domains

t,he

objecf

+ Object for objects).

~rtrpper, (Figure

noting

.), where the object.. Such whose

t,he current8

ject,s a.nd niethods,

don-ra.in

4 summarizes

object,

funct.ions for expressiotis a self and a snpw de-

coutmest , ai

and finally

st,yle

tlomaius.

an oijyct yene,mtor, a function of t,lie form (Abe/f. .). whose domain is Object + Object. Wheu inherit.ance or delegatiou comes iut,o play, t,he child object, is modeled (XsrlfA~su~m~. t,o the pareut,

t,hc

of LIEBERMAN

our seinaut,ics

aud it, is built, a.rouud

PalsLet

semantics

In its broa.d lines,

we use

about, wrapper tSo [4, ‘il.

a store

eiiviroiiiiic~iil.

foi an

ob

for ol.licr storable

values. The store aud enviroumeut~ algebras are pret,ty staudarcl (see [la]). Self aud super are va.lws of t,lre

CI~1~u(IyyFI. nyyllcatzon creates an object 01 witch parent, 02. The wrapper of 01 is applied to the generator of 02

domain rnaiitic

218

Object introduced before. The cloinaiii is the object. incmory.

1~1, unusual

SC-

Syntactic k

Domains:

E

C’olr.stallts

E

,‘7’PlCCtOl~S

1)

E

Irlcntif

F

E

E.cprrssionh

111

f

irrs

::z A- 1 11 / (send

c IIIe*) 1 (self

(newInitials

F’ (~77~) (F*))

um A* ::= #t / #f 1 II; Semantic Domains

String

domains:

for lit,erals E T /I E Nun Char (’ E

and

charactJerist8ic semantic doma.ins: = {I,, true, false}

T

=

zrnsyccifird

=

w?31)Pcifird 7lnsYFcifif=d

s

E

String

Y

E

syn1

= =

I’

E

rr7l.specififd

v

=

T $ Num $ Char 3 String % Sym

17 E I E

RV LV

=

v+oop

6

DV

= =

Lot EV

Semant.ic t v I’

1

E

Semant,ir

E

Lot

=

Pointer-+

= =

Ide-+ Lot t

s

domains

=

SV

=

RVrjLV

Selector

A

E

Diet

f 7

E E

0 r

E E

Full Met11 Object

R

E

= = = = =

Selector

=

Object

-+ Object

Wrapper

=

Object

+

domains

for t,lie object.

E

oop

n10

E

MObject

n

E

/!l

E

OlllV 0111

Figure

t,o share

012ject. inemory,

Syin Synl -+ (Lot + T) (Onv~~S)-+PV* t(EV~~0n~?) (Object I;# Object) + Fun

Generator

Q

t,o implement,

0

(Loc+T) (SV i T)

for ohject.s:

E

In order

PV

Env

Ill

Semantic

=

domains for environmenk a,nd st,ores: E 0 = {lo, Tl z trnspwijied E Ide Pointer = unspwtfied E

P E (T E

firrs

1 C'har 1

YR t") 1 (super 171F*) 1 (method (I/*)e*) 1 (clone e) 1 (v f> 6-1 1 (if e e e> 1 (set! I/ e) / (root) / ,S,yni

1 (let

ob.ject.

them

vvliich

vvliose domain

Object

Fun) + 0) +

=

MObject

=

Oop -+ (OmV

ot.her objects

is a function

Object

memory: Pointer $ 0 Object x Generator

among

is Oop,

((T +

= =

4: Syntackic

idemities.

t

x

Lot’

x

Generator

6 T)

and semant,ic

domains

ohject,s, hut, also a.re st.ored in an

from

int,o ohjert,

x Sym’

+ Met11

object niemory

able

to share

ory cont,ains

ident-

MObject,

va.lues.

Hence.

whosc~ domain is OmV. The domain of object memory i.s 0111 (see Sect.ion D). Because we also want to be

219

LIEBERMAN.

for the language

methods

among

objects.

t,he object

not- only

memory

objects.

whose

methods.

whose

domain

but

object,

also

memory

values

are

in t,he sum

01nV = MObject + Meth. Not.ice vided st,orable values among t&he object,

t.hat. w memory

mem-

domain

is

is Meth. doma.in have diand t,he

st,ore

in order

which

are

l-values.

Figure

.5: \‘alua.tion

to clea.rly

distinguish

(st,orable) This

r-values,

from

is an important,

functions

object. locations

distinct,ion

for t,lle la.nguage

spoiidiiig

ideuhfiers, which

loca.tioiis

oft.ell skipped

in V, or an object

Consider now t,lle denot,ational model sides he wrapper sema.ntics, we need of t,he object.

t,lir stow.

s1ot.s.

and t.he mapping

Slot, va.lues from

are allocat,ed

is made

by a d/c,flonclq,

identifier

in Oop.

The object, wrapper is build by the following t,a.king a. dictionary A and rrtwning a wra.ppw:

of objects. BPa denot,at,ional

slot names

iii the st.ow

10)

i.e. a function from symbols (slot, nanles) to locat,ions (see Sect,ion A.l). A slot, value can be eiher a cnk+laiit

a.re

over.

model

LIEBERMAN. (see a.lso Figure

in

t,o the corre-

220

funct,ion

case tnfp =

met.hod) t.he new

At,m) of

ZSLOC‘? =+ case I =

Imp ILor of

is0 ! j

corresponding

in( (T -+ Fun) + 0 )(

The

Xr.X(p. a).X?r*.icE”,,o,,,l3s))

I

in( (T -t Fun) + 0)(

evant

XT. if T then case 0 = i.sOopP *

a(l) lsv lRV of

inverses)

case Q =

t,ion.

/1(29 loop) lo”,”

isMetll?

+

GMObject endcase isV:L’+

of

which

the object,

(

/-I, storc( !, 7r*11 Sa))

) + O)(lo)

tion

endcase the purpose

bind the self and t,he super in t.he model. denot.ation

na.mely

of a wrapper

wit,hin

t,here

is no slot

and after

in which

from

au object,

selectors

which

is iklf

into

corresponding

select,or

The

return

valuation

valuation

evalua-

ident.ifier,

memory is ‘set,

ca.se the

object,

then

name

in

we have

of t,he slot

valuat)iou

or apply

as receiver function

t,lie

in Figure

-5.

a.nd

super-

self-

t.hat instead

t,o get, t,hr receiver,

self or super

In the

for

except

t,lieii we pass to get a func-

value

is given

functions

memory

argument

t.he slot

function

are similar.

the object

the

a function.

t,o the

must’ be

their

tmo an object

If the select.or

message,

expressions

The object obt,ained from t,he above wrapper will respond to a select,or iii t,hr following way. If the selector is unkiiown. hott~oni is ret,urned (things can go wrong if either

before

arbitrary

(which

t,o get, the corresponding

t,liat, will either The

is to correctly

what, denot,es

a funct,ion

of slot, applimtion.

[3] by applying

unyemnute

must, evaluate

memory.

method. R.ecall that

and

in t,he st.ore. If t,lie select,or is not, ‘set. the selector and then true t.o 6he object

1 F-w)

is t,he following.

to be mut,at,ed is t,he result, of t,hc first, actua.1. We pass t,his first act,ual to the object and then we pass false t,o get, a function t,hat. will mutate t.hr value of t,he slot,

endcase

?n((T 3

we follow

pe,rm&

is used

expression

the arguments and t,he receiver of the the order of evaluation should be irrel-

receiver

a mut,ation

(inEV(0)./~,v)

else X(~L,a)X7r* .( unspecifi4

I.sT?+

The

Y+

b. a)

ident,ifier.

t.o t,he arguments

c)’ IMuleth (4. q)(p, g)(r*). (inEV(i)).

memory. Mnk~-metI? allocates object, memory a.nd ret.urns it’s

of a send

(unspecified).

permut,atmions

X(p. a).Xx’.

endcase

object.

semantics

First, we evaluate message. Because

7.sPointer ‘2 *

endif

and an object, method in the

of accessing

we use either

(see Fig.

the

5).

for send-expressions.

t(hP

careful rea.der may have noticed t,hat, we first. project. a memory object, on its first, component before passing it. t,he select,or.

01

containing

In fact,,

an object

a memory

(value

object.

is a record

Object)

of domain

in its first,

if. for some reason, the location recorded in the dictionary is invalid). If the selector corresponds to a valid lot-at,ion. t,he ob.ject, ret,urns a function T + Fun. This

coniponent~. It. also contains it,s own generat,or, the list. of its slot names, the list, of the corresponding locations in

funtXion iniplenieiits niut.at,ion of objects: is pahsed true. then a function applying

the st#ore and the gcnerat,or a memory object is a. value

but, if false is passed,

is ret,urned, ing the rrturned

it is a function

updat,-

(0111)

a.nd a st,ore a new

Au updat,ing sponding

object.

funct,ioli

actua.1 (est,ra,cted

from

t.o the slot.

(S)

(PV’)

a. list of actuals

of the message.

ant1 rrt,urns

a funct,ion

and

ret,urning

memory

aud

f st,ores

the

the

result

hand,

of the

sole

obJect. (in MObject).

denot.4

by mlues a

of domain

self and a sz/yer

Meth, and

Met,hods

which

returns

it, the

object

memory.

t.he store

and

A m&od

value

f’orltlal para.meters,

(see

from

Met11 is creat.ed

Se&on

A.‘L), which

f in

a list of expressions

(t,he body

and

new-ob.lecf ta.kes ject,,

t,he ac-

values

x Sym’

the fa.ct. t,hat, an ob-

t,o messages.

object,.

which

LVe must

We must

n1ea.m that,

also be able

t#hat we can get its slot (through

the

locat,ions

t,o creak

parent. to creak

object,

and

call

t,o clone

an

names,

its

in the

the clone.

t,lie new object,.

t,he ol>Ject. ideut.ifier a list of slot, iia.iiirs.

a function

be

we need

store) For esslot,

ollorok-

.-lllocatr-rzP,~a-o~Ject

of t,hr parent, a list of slot

of t,he new oilvalues,

an object.

nirniory and a st,ore. It first allocates t.he slot values iii the st.orc, t,hen it. crrat,es t,he new object. a.nd allocat,rs it iu the object memory. It fina.11~ ret urns t,he object. iden-

by the functakes

slot

names

t.uals. t.ioil mokc -mrtlt

current,

means

from

Hence

ample, t,he valuatmioii fuiict,ioii for newInitial-expressions (see Fig. 5) evaluates t,he new object,‘s slot, values,

are

FUR. When a slot va.lue is a method. it. is applied by passing it. the self. t.he super t.o get f, which is esecuted by pa,ssing

which

respond

a child

generator.

object),

comes

only

and use it.s pa.rent, generat,or

are functions

a fun&on

x Generator

not

the object

a non-updat,ing

V)

x Generator

x Lot’ representat,ion

does

of its parent. object). of t,he domain:

= Object

able t.o creat,e

corre-

returns t,he value or the object) idenwhen the slot, value is a constant (in

or a menlory

ject

a. new store.

the list, 7r’) in the location On t#he other

This

result.

fun&on f simply tifier respect,ively

t.aking

MObject

slot. value t,hat is ret,urned. In both cases. the function ,f is ill domain Fun. f takes an object,

nlmiory taking

if this function t,he slot. value

a list of

tifier,

of t,he

along

(see Se&on

221

wit.h t,hc upda.ted A..?).

object.

niemory

and

store

The

function

clone,

for clone-espressions,

called also

by t,he valuat(ion

looks

up t,lie object,

function

supported

memory

it,s strengt,h.

to ret.rieve the object to be cloned. It colleck the ues in the store corresponding to the cloned ollject,

valand

then

oh-

calls t,he function

using

creuk-objet

the cloned

a. new object

idemifier

(see Sect,ion

level

also become

in order

The t,rait,-based

A.3).

programming

model

and

should

he self-describing.

all t,heir

part

A la.st.

will consist

or constant.

of slok

values,

holding

and

t.o

in t.MQ parts: the “cst.ernal”

prot,oc-ol part, con while the int,ernal

either

but. t,liis need

wit,11 a

[I Y] proposes

object.

protocol part. Typically, the ext,erna.l sists of slots holding method values

t,he semant,ics of our first. la.nguage. functions are given in Figure 5: they are

standard

have

when

of laugttngcs

segregat,e the slot,s of a. prot10t8ypical t,he “int,ernal“ represent,at,ion part,

This complet,es Other semantic

to

escept.ional

pa.rents. We illustra.te this ca,tegory t,ra.it-based programming language:.

Observations

pret,ty

They

“first-classness” is severely restrickd. such as being immut,a.ble or abstract (in t,he sense t.hat. they cannot au swer messages). They may not, be cloned or used as

ject,‘s slot names, current slot values and parent. generat,or. The new object, is t,hen st)ored in the object) memory using

at. t,he la.ngua.ge

otlject

ideut.ifiers lw

not, t,o always

t,lic

point. worth mentioning concerns t,lie run-time representat.ion of objects in t.his semant,ics. The preservat.ion of

ca,se. In our first, example (Figure 1) ( t#he inkrual part of a point, object. would include the slot,s x and y. while t,hc

object

external

generators

at. ruin-time

portam a.spect,l. t,he pseudo-variable vidual

object.s,

a.11imporba.nt,

ject.s in class-based chss-bed

difference

languages.

languages

to inst,ances of their Wit,liin one specific

arises defining object,

and an implement8at~ion of space

is an unsurprising

yet im-

In pract’ice, it. in&s on t#lie fa.ct, t#liat, self cannot. be bound wit,hin indi-

obviously)

compared

The late-binding because

to ob-

copies

of self in

methods

can apply

may copy

t,o pay t,he price into individual

inverned

(in terms

objects

the

run-time

has

been

used

optimisations

t,ion of met,hods property. Even

though

Iat,+binding languages, dent, object.

(look

[Z]). they

in protot,ype-based

several

times

at. Self’s

Protot,ypes are at,tached

languages

compila-

la.& t,his known to objects,

ret,a.in

the

self

kind

of

self,

but. the method. self (this

is the Self a.pproach t,o mult,iplr compilat.ion). the object itself has no bound self. The self

However. is rat.her

to the receiver

recept,ion

4

t.o ot,hers. a. part,icular

basis.

some Objects

can

programming

become become

exceptional t,hat

way:

operations

languages

of Siniula

may

for delegation-based

be defiued

languages.

and tiiore

\‘irt.ual

:

virtual eration)

resource (operation) : A resource (op named and specified in an ancest,or whose will

be

13,\: a descent-

provided

t,hese

methods

never

cut..”

must.

be

Rut

t,hey

can

t,liat dren

ancest,ors themselves objeck by the very

since presun-

t,he receiver

(self)

lie should

also

have

added

a.re also linked to their chilsa.me umbilical cord! 111 fact,.

for t$rait,-based programming t,o work properly, t,raits obAnd we propose t.hat, ject*s must never receive messages. the language

must

So our example of

to send

1la.s it.s costs in object, aut,onomy. It is as t~hough objects are connected to ancestors by an umbilical cord which

compared beca.use

add or display

will try

messages x and y which will fail. Weguer noted that.: “The dynamic resource sha,ring provided 1,~. dclegat.ion

at, message

exceptional

of virtua.1

represenktl

[19, p. 1731 had already

scendant

ably

one kind of link

met,hodology

not.ion

class-based

(t,liemselves

in t.he following

will fail if sent. the message

with one kind of object. a.nd one t,owards one wit,11 two kinds of oh-

objects

aucl add.

However, what Weguer as well a.s t.hc Self tcani forgot. t,o insist on is t,hat,. in prot,ot,ype-based programming, while a.ssumed t,o be a concret,e object,. t,he t,rait,s ot,.iect,

t,ime.

Two kinds of objects,

when

to bind

on a per message

Typically, a language kind of link will evolve jects

t,hem

display

dant .”

object, ends up having t’wo copies of the same one with an “open self” and one with a bound

bound

copy

“The

part

6). Wegner

defined

implement~at~ion

of their references t,o self as in class-based because they can apply t,o any (new) descenYou can

trait,s

other

met,hods

sa.me

the slots

operat,ions arise when a.11 ancest,or specifies rcsources that will lx impleniented later iii a tlc-

t,o implement

multiple

include

see Figure

generally

methods a.pplying t#o t,hem. In ea.41 copy. all references t,o self ca.n be bound t,o t,he object’s self. While it is not, t,he st.a.ndard way t,o implement references t,o self, t,his observation

would

of t#lie represent,ation

as objects.

class or any of its subclasses. the self is perfect,ly known

willing

part

A t.raits object is an oll.ject. holdiug t.he ext.ernal part,, the idea being that. t,his object can be shared among several

make

sure

t,liat, it, l~appfms

of a language

with

like t,hat,.

t,wo kiuds

of ob-

jects and one kind of link is a trait-based prograinming language whose seniainics is given below. 111 t,his lau-

‘This has been independently brought t.o the fore by Steyaert, and De Meuter [16] whose discussion is enlightening.

222

guage, messages.

tra.it.s

a.re abstract

As an interest,ing

object,s

t,hat, caunot

side-effect,,

prrvent,iug

receive t.raits

Figure 6: A point

t,o answer

also enforce

inessages

in 501iie

sense

esa.~nple

a traih

object

Object)

domain

objectb

the

using

iii heir

In fact,

representmat,ion.

our

cmlt,eretl progra.inmiug model of he resulting language. Nevertheless, we admit. t,lia.t. t,rait-baaed programining ~nodel is a.t 1lif extreme a.llrst,l.act.joit-cellteled end of the

language imposes two rest,rict,ioris t.ra.it,s cannot, be sent, a. message,

on t,lir use of t,raits: and t,licy munot. he

created

olljec-t..

spec-t~ruin amoiig The hit.-based

one is dehat.able.

ages

t#lle oiies present.ed here. programming met,hodology

t,he crcahon

like an inheritance At the leaf. we iiist anccd

of delegation

hierarchies

one in it,s higher levels made concret,e ol,ject,s. son1rwha.t

find

in class-lxsrd

prograinniing.

this

eucourwhich

hie.

of traits. like the

of a concret,e

but

This

the previous he introduced

look

Trait,-based

as c-liildren

leads

Cloning

st at,us of t,llr cloned he

clo~ied

T11e

Two and

must

object.

one is conmete

it a.t

minor

niodificatioiis

different.

funct,ions

crea.te

cl

scoops

is t,hr way we mvisaged

to a few

semantics. to alloca.te

t,rait,s ol,jects.

pro-

this

in must,

pitmher concret,e

or

also t#ake iutmo account8

the

to create

a concrete

or, iri he

cont,ra,ry.

object

if

t,o creaW

gramming lra.ves more flcsibilit~y iii the creat,ion of ohjrc-l,h. but, t,rait,s are not, classrh: t,lit=y are less flexible and alx;tBra.ct.. Our t.rait,-based la,nguage is minimal; we do

a t.ra.it,. We also ahsuni~ t,he l,oot 0bjcc.t t.0 he a trait.. ‘1‘lle section R provides the definitions of the valuat,ion

not, iiicludc

fuiictioiih

C’XillllJIl?,

The valuat.ion function cepts only coiic’rc%r ohjerts

operat,ioiis hking aclva.nt,age of traih. For WP sl~ould add an operat,ion traitof rct)urning for an o\,ject it,s first parcut traits object,. ‘I?est,iiig wliet~lier then

two

objects

lmil do~1

t,raits

arc the satnf

SPIMV. trait,-based

support

t,o test

the

whether

or lia.ve a parent. programming

of trait-based

We ohtaiii previous

a hait,-based by adding

me

the

concret,c

oues,

Tile

In this

aiiiong

013jrc4.s

pm3gramining

programming

language

011~ llrw kind

essenhal

t,llr, doma.in

t,wo subdoinaiiis:

from

of esprcssions:

idea

of he

of memory objects

a domain

oui t,hc

of c-0ncret.c

semant.ics

is t,o

(MObject) objects

Act,ually. t,lle object) This

in

TObject

(COh-

5

= Object x Lot”

x Generator x Sym’ x Generator = Generator x Sym” x Lot* =CObject

Not,icc, t,liat, i~musr her?

is 110 nerd

and

hat,

we ol>ta.in

is rsplicit~ly

proje(Tt,ed

that, everything with

errors

goes in his

T,anguages

right,

13,~ looking

up

into CObject. siucrc we don’t,

seinaiitmics

t.0 keep

it

iiior(~ coinp~elieiisit~le.

Two kinds of objects,

delegation.

two kinds of links

wit,11 om

kind of link will Qpically or parent-of link. which iniplcmriit,s

have

a

shar-

iiig akin suggcst,s

t,o inlicrit aiice. Adding a second kind of link int,roducing a ht,ructural descript.ioii link siniilar to he class-of link. In tradit.ional p’.ot,ot.S;pe-l,a~:rtl

I+ TObject t,rait,a will never

t.0 keep t,lie object

assumes

siniple

x Generator MObject

t,lic object memory

dea.l cspliritml?;

.ject) and a domail of t,rait,s objehs (TObject). Hmcc~, WC replace=thr old domail MOhjmt by tjhc following: COhject

uow ac-

a n~ctllodol-

nenTrait,s expressions, wllich creat,ca hai& o1~jcct.s. The original nen-Initial 5 expressions are preservrcl t,o crea.te segrcgatr

iiewTraits-espressioiis.

for send-expressions as receivers:

would

in common.

I)eliavior

and

t.wo ol>ject.‘s

em‘ourages

ogy where the iiot.ion of siinilar l~econics very inlport,ant Seiilantics

sanic~ prot,ocol

or not

for newInit,ials-

itself

receive

messages.

(t,lie value of t.lie

languages:,

223

each

object

being

one-of-a-kind.

ii, gct,s hot11

point map X

1

Y

2

display

3

add

4

01 --------_______ 4 < -; I ------

IO

02

20

method for displaying points ) method for adding points

Figure

it.s slot

~mmes

of st~ructurally

and slot,

values.

identita.1

object,s

t.enipt,ing

to share

reasoning

t.hat pushed

the

t#he object. values. map

now

In fact, the

in Figure

values

number a line

of

7na;os [a].

t,o standard

merely beyond

of immutable

as a vect,or

of slot,

by putt,ing

in t,he

that

slots,

an existing

an object. receives

When

if a met,hod receiver:

is found,

if an index

it, is applied 92

slot. is retrieved

is found.

and

t,he cont,ent

eit)her

or applied if it, is a method. aut80mat,icallp behind the scene

in t,he cont,ext,

ret,urned Self, and if

In

will share

the same

efficiency

in the representation

space

as the one of class-based .i\ map-based maps true objeck. t.o be reint,erpret,ed

map.

is const,ruct,ed

vainage

as objects. of them

it becomes

in the

possible

progrannning

add or delet,e

a slot, t,o all objeck be implemented.

readily

in a clone

of map-based

st,ores

maps.

for a map-based

language

we nlust

first, have a notion

of contiguous

X(q‘.

A

1) cont,iguous

loca-

wscrwfions

and

by the funct,ions

we (‘au crea.tc

slot,s by alloca.t.ing

n

automatically

when

a

II cout,iguous

an ol,ject,

Maps

is cre-

are very siinilai

Object)

of the domain

they

dou’t

don’t,

have

have

parent,s.

t,o answer Also,

into

since

t,he im-

real

niessages

a ma.11 iii our

lan-

indices: =

a).

let* I?*= crente-indicts(q*)(O) and (I*, g1 ) = allocat~-s10t-7:r~17~es(

n*)(

a)

in ( let A = make-objwt-dict(y*)(I*) in

X?JL.

case

tmp

=

isLoc?

t.he function

IJI)

of + O)(

hr,.m(hP /I&c) Is”lR”l”lNllrlli in((S -+ Num) + O)(lo)

endcase

en-.

A(

=+ irl((S -+ Num)

isT?*

ret,urn

o1 )

ta.kes a.n integer

c9,t-ate-indices

the list. of integers

.

from

1 t,o

I? and

91..

A concrete object. on t,he other lra.nd needs t,he full wrapper semantics. However, the fun&on wukc- wrqq I’

t,o be inrplement.ed, locations

smce

build-map

to t,ake ad-

prograrnnhg

In order

returns

with

(values

t,hey

where Semantics

c’ou

locatrons

guage contains only indices giving t,hc posit,ion of t 11~1 corresponding slot, value in t.he concrete ol,Jrc-t.. :I\ iiia.1) is viewed as a function from select,ors int,o funct.ions of

iudices

fa.mily,

c~ortf~~uou~s-

t,he necessary

by a. newInitials-expression.

and

map-based language encourages a programming met8hodology where the notion of structurally similar objects beconies very iniporta.nt,. Iii such a langua.ge, we can spea.k about a group of structurally identical objects. Our laugua.ge is a minimal one, but. map-based operations t.o could

a.nd

algebra

are used

object.

mantics

making

niet~lioclology.

rt..st’w~t~~w~

to The

store

(see S&ion C). t.his augment,ed st,ore algebra..

to objerts

as objects, cannot, answer messages. So we make t,hem abstra.ct objects unable t#o answer messages. Wit,11 maps represented

which

of slot va.lucs.

plenienta.tioii will query them with a. select.or t.0 obt.ain a value. We therefore implemeut them using similar kchexcept that, there is no need for a wra.pper seniques.

give Self

by

t,ions.

ated

of the

of objects

B ecause t,heir slots contain in t.he cont.est of the receiver,

The function

tiguous locations. Maps are iufered

languages.

language

cepk.

t.hat. will allow

as vect,ors

Also. when c-loniug au existing loca.tioiis in the st,ore. object,, we can collect. the currents slot, values iii )I cou-

t.he

of receiver’s

They

t,o our

Using

if it is a value

t,he same

locc~Jior~s:

allocatrons

add

arithniet.ic

objects

t81iree funct,ions

concret.e

maps are creat,ed an object. is cloned,

the t,wo clones

concret,e

co9Jtiy~uous-rrllocut~o9~~

coucept

a message.

maps.

as well as a loca.tioii

inrplement~

that, the slot values are replaced by relat,ive posit,ion of the slot, values in

represented

using

store

it becomes

infornia~tion. 7, a.re similar

point. example

is used t,o look up t,he map to find a slot index. or a method. If a value is found. it, is returned;

selector a value

nth

st,ructural

Self goes

in this language.

a la.rge

are created,

the Self t,eain to invent,

Maps. illustrated prototypes. except indexes giving the

When

7: The

in the

is slightly

224

different

from

what

we had

in t.hr previous

lallg~ag~

berausc

t,~onar,v

n’p have

mrrkt- ~r~ruppt I~ talcs 1he ollject I)lied

t,o replace

by t,he ~irap t,o which the

is act,ivat,rd

t,o it.

map xitli

If t,lie wlwtor

t,hey

the are

=

t,he map

=

Map MObject=

is apa

~t/r slot value in the concret,e ol,Ject. This value is t,hen uwd as iii t,lir prwious version of ri?uke-w7VpyF1-:

of contiguous

rs(S i

11( 7n) of

if r

XT.

then

in((T+

+

object

-+ Num)

+

0)

Map

rout airis it,s object,

(uscxl to answer

or (used t.0 create child objects) ( it,s first, locat,ioii, the iiuiiiber identifier,

object

locat,ioiis

iii the

object,

and

for message

(send- ( self- and super-expressions)

(mapof

f)

object,‘s

map,

which

X(/L, U).XT’.

~.sO?+

((S

which

tesk

rrt,rirves

arid

by test,iiig

objert.

ident,ifier.

two

object

objc,cts

t,he equalit>The

l)assiug

espres-

ident,ifier

of an

(clone?

are clones

of t,lieir

valuat.ion

parent’s

presented earlier. a ,~~u~~~f-~.r‘~~,~~.r.s~o/l

a rlolltP-~1~l~l~ssi~?1

whether

0Uier

the

the

are esa.ct ly t,he

sanir as in t.hc t,rait-ba.sed language Wr simply add t,wo new expressions:

-+ Funt + 0)I

rn((T

+

generator (used for cloning). ‘The yaluat,ioii fuiict~ioiis

NIII~I)? =+

Lot

x

1 it,s generat

its map

sions

Oop

x

x Generator

Selector

A concrete messages)

Generator

x

CObject

function \vliic-h is applied t,o t,he current st.ore to get, t,lle corresponding index 11. This index is used t,o rrt.rieve t,hr

case tr,rp =

Object x Num

When

t,he 1na.p returns

knowii,

CObject

dicHence

as first. paranlrt.er. a selwlor.

is

ollject’s

liuked.

of

t

61)

one

a.n-

resp&ive

nap’s

functions

are:

object

ident,ifier

Fun)+O)(l,,)

endcase

‘The new

function

allocal~-l~r~?v-oCjtct

first, creat,es

a

for the olIJect>, allocates t,lie map in t,he ob,ject, 1nen1or!; and calls t,he fuiiction crmk-oO,lfct tSo creak the concrcW object,. This latkr funct~ioii allocaks t,he slot, va.lmap

ues, calls dlocat~rs

wc~k~- crwy~y~er- t,o creak t,lir concrete

object,

t,he new

wrapper

iii t,lie obje(.t,

iliernory:

and

111 t,he first,, map

we ret,rieve

iii the object.

the

of t,hr

Iii t,lie second.

represeiit,ation.

we t,est

wliet,lier two objects are clone by t,est,ing if they have t lie saiiie ii1a.p. Iii fact, t,lie propert,\ t.liat, we t.rst, is not, st,ruct,ural

cquivaleiice

have been

obtained

011 t,lie same

origiiiat,ing

6

but, whether

through

a series

or not, two of cloning

0lIjects

operations

ohject~.

Two kinds of links, one kind of object

Typically. a language wit,11 two kinds of links and oue kind of ob.ject, can Ix obt.ained by some rationa.lization of a language wit,11 t,wo kinds of oh,jecw (md of links). For esanlple, consider t,hc map-bawd proposed let

(I’.

17, ) =

in ( let rl =

n//occctr-1,-.slot-1~~~~~/f.~(~*)(a) lf?nkf-lulrrpp~1.(n)(

in ir~MObject((fix(r,).r,, kleiiloq

lowing

object,5

seniaiit~ic

are now

doniains:

I* Ji

)

b r

Q. /*J,.#E*.~))

represented

using

.al)

t,lie fol-

earlier.

make

t,hem

sages

without,

Can

st,andard

we transform

ob.jects

inipa.iring

the

answer is yes. me send t,henl

The probleln nlessages whose

ta.tion

c~outest

225

in the

ca.pabl~

inaps

of a coucrek

language iii order

of answering

progra.niiiiiiig with result

t.wo kinds

inaps needs object

t,o KK~-

~iiotlel?

The

begins when a rrint,erpr+ in order

t,o

desc. desc.

point desc.

01 __-_-_---_--

I --

0

slots diet. for desc.

0 method for displaying poinls Z- method for adding points

Figure

makr

But, maps

sense.

don’t.

need

8: The

point. esanlple

using

descript,ors.

sponding

to be in~plemented

to Wegner’s

he classifies

Ada

object,-based

[6].

The

like standard prototypes. A siinple idea, illustrated in Figure 8. is to replace the map by a descriptor object wit.11 one slot called slotsDict, which points to an ob-

each class is by no niean pa.t.h t.owards a 1angua.ge

ject

one kind

implementing

nary

a slots

is not, an ordinary

not, identica.1

aspect.

swering

round

8). but

methocl

dict,iona.ry.

corners

a Sniallt,alk The

sekcto~$

rat,her

ret,urning

put : (some

a.11 object,

We draw

it. a.s

an object

its associated value)

anvalue

inessages

like

advant,age

of this

legit,inlate as well

descript80rs

look

nlessages

as to slots

pretty

be creat,ed descriptors

nanlely

In fact,

our

classes.

A

like Sinallt,alk

programming

model.

aut,omat.ically, are

like

so much

clescrip-

maps

feature

tha.t

niakes

the

programming

language model

were.

like cla.sses

we a.re a.t t,he frontier bet,ween abstraction-centered object-centered progra.mming here. An inlport,ant, object,-centered

now

sinlilar t,o t,he previous mapvery simply. In order to pre-

a.11 object-cent,ered

Nonetheless,

to descriptors. dict,ionary.

much

descript,or-ba.sed language based one can be designed t,ors should

is that

representation

still

t-hat. a.nd miss-

proinotSe

an

is the lack of a shar-

ing mechanism bet,weeu descript,ors that. would have a senla.nt,ics sinlilar t.o inherit,ance. By t#aking ra.re not. t,o introduce such a link between descriptors, we don’t. encourage programmers to design t,heir applicat,ions mainly around descript,ors. Due to t.he la.& of space, we don’t, provide

a fornial

gramming

langua.ge

sema.nt,ics

for a descript,or-based

pro-

(see [l 11).

(Clyde is the prototypica. jects of t.he same concept, t,ies. Because clelega.ting

The

Figure

9 summarizes

classification.

represeut,ecl five mtegories of languages: here wit.b one esanlple language in ea.&,

We have

four described a.nd one corre-

considering

t,he sta.t.us of

first.

proposal.

111

wvay to reprrsrnt. a COINinst,anc.e of t,his couc-ept.

a, prot,ot,ypical

undesirable,

tmo it,. we ca.ii make

object

1la.s an in)-

effect

on all other

t,heni

iiiiinut~abl~

obj&s object,s,

hence stressing their particular role. In t,hP Clyde--Fred esa.mple. Clyde would no longer be mutabic~, t.1rerefol.c making it, impossible t.o indirectly modify Frc~d by mut,ating Clyde. A safe version of such a language desigurd in this

line provides

two kiuds

anot,her

of objects

esamplc

of a la.ngua.gc

with

and oue kiucl of link.

It, is also worth noting t,hat, t#hr c-lass&-at ion t,he number of kinds of objects and links needs

using not. to

be restrictSed to object-centered la.nguages. \Vr have already not,ed t,hat our descriptor-based language is a.t t#he frontier

of abstraction-cent,ered

t,his language scriptors,

aud

add

programming.

an inherit.ance

we end up having

link

a la.ugua.gc

If WP t.ake between

dr-

wit.h 011~’kind

of

objeck but t.hree kinds of links (pareukof. tlcscriptor-of and descript,or inherit,ance) which cannot, lx> c.ha.rac.t.erized a.s object,-centered. Moreover, consider a langua.gc~ where inet,a.cla.sses a.re fir&class 0bject.s a.s Coiiik’s Ol)j\‘lisp.

Such

stances

and cla.sses,

a. la.nguage

instances and

object-centered. our

in

elephant) t,o which ot,her obcan delega.te for defa.ult, proper-

modifying

and often

sta.nt.iat.ion

The classification

when

in Lieberman’s

Liebernlan’s niind, the st8andarcl cept. is t,o provide a protot,ypicad

whose

7

objects

in which

languages

closed. For esaniple. anot,hrxr wit.11 t,wo kinds of objec.t,s bllt.

of link appears

prot,ot,ypical

porta.nt,.

slotsDict.

ing

yet,

dictionary.

we can send

serve

slot,s dictioa similar

and it is act,ually

at : (SOUP se/&o?.)

a.nd at : (sonzF

The (despit,e

in Figure

simi1a.r t.o Smallt,alk’s a. box with

dictionary.

prototype

languages

list of possible

act,erize

An int,eresting

226

metaclasses

are classes) inherit,auce.

and

of ohjcct,s

are simply

t,wo kinds

However,

programming

to t,his class work

now

(in-

cla.ssrs

of lit&s:

in-

it is cert.ainly

We ha.ve used our cla,ssific.at.iou

object-cent,ered

is uot rest,rict,ed

1la.s t,wo kiiids

since

not

to char-

la.uguages.

but

it

of languages. is to

assess

csist,iug

1a11-

In his

2 kinds of objects - 2 kinds of links bp-hased

paper,

we have

t.er underst,anding

gua,ges

by int,roducing

cpnt,ered

progmmmi&

stract,

2 kinds of links

have

(Descriptor-based

(Trait-based

a uew

ent,ities

his

of nlore

around

this

niore

of abthat,

t 11~ creat,ion

into delegation-based

classifhtion

and more

brings

new programming

languages

of prodifferent,

pure

models

Classes

versus

la,nguages

protot,ype-based

lan-

hnguages iii t,lW niore thoroughly

int,roduced paper.

In-

the esisknce

delegation-based

in this

proposed

we

programming.

to t,he fore

st,ruct.ured

of

notion,

of clelegat-ion-based

Our fut,ure work is t,o assess rsist8ing light, of his classification and t,o study he

kinds provided

general

classification

forming a continuum bet.ween guages and class-based ones.

1 kind of object - 1 kind of link

solne

nmps.

lan-

of object-

primarily used t,o show he diversity models we ca.n oht ain by inhoducing

abstract,

deed,

not,ion

a.dniit,s aud

revolves

Using

proposed

a het-

is still dominated by t,he ohjec-tb language, i.e. t,lle niaJor appli-

act.ivity

objects.

languages. gramming

towards programming

general

as traih

niodel of the

design

c-oncret,e

inore

which

such

t,he progrannning crnt,ered subset,

1 kind of link

he

progranlming, devices.

cat,ion

cont,ribut,ed

of delegation-based

by the different

References [I]

A.

BOKNING,

Orientccl Joint Figure

!I: 1‘11~ cla.ssificat,ion

with

rsan~pk

[z]

languages

Languages.

Corh,fewnce

(I%%).

C.!

CHAMBERS.

guages

in the

light,

of our

cla.ssificat,iou.

3GGIO.

UNGAR,

D.,

AND LEE,

of Self,

a D!,rlarnicallv-t:1,ed

prcseiikd

.j(%s

ciilianc-ed. iutroduce to make ~.ript~ors hetl

here,

Our

t.lie design

preferred

of upgrade

object,?;

maps fir&c-lass objeech (Section 6). This wonlcl

prograniming

iit~d t,wo kiuds

language

[:s] CLINGER.

would

[-I] COOK, tics

be to

Not. ‘4.

[s]

in the line of our demake Self a dc>lrgat,ion-

W..

OOPSL‘4

of links.

Proposals

.J.

[G] ICHBIAH,

(Ed.)

partment

Conclusion [7]

Iii 111~ cwwnt,

iiiiilg

classifications

lang~qes.

there

tlel~gat,ion-l,asrtl

and

sa11ie.

In fact.,

this

siou over t.lie nieaning

of object-orirnt,ecl

is an underlying prototype-hased

assurnpt,ion

prograin-

assuinptioii languages

has

of prot,otvpe-ba.srtl

int,roduccd

owfirnl

t,ha.t. are

t,lie

confu-

rea.1 protot,ype-hased feattires going

language

W.

of C’ornpter

Designing

ing Examplars.

A C’M

Sgptrn~.s 11, 2 (April [9] LIEBERMAN, plement Proc.

ah-

227

H.

Shared of OOPSLA

214-223.

D.C..

semantics with stat.e.

P. Proc.

201&21i. Languf~ge. Office.

De-

1983.

of an object

oriented

Iii Int.

or2 The-

Sqftruurt-.

Conf.

T,3 P,S’.Of

(Sep.

54X~Fi68.

[8] LALONDE.

prograinnling.

programniing languages have a.gainst, t.liis basic principle.

pp.

Program

Washingt,on,

A. V. Wrapper :1specf.s

1991),

Iii the first papers proposiug t,lie I,rot,ot,ype-l,nsed approach. aut.liors insist, on a prograniniing niodrl adniitt iug oiily c-oncrek obj&s. On the other hand. sfveral strac’t

HENSE.

programming

1992).

Prog,nmn2zng

Ada .Joint

of Defense,

Valitlat,ion.

27. 10 (Oct.

A&

COINTE,

a New ‘Taxonom>

ancl Their

‘9”. .sigplcrr~ Not.

of OOP-

433-443.

AND

From

Seman-

Pwr.

1989).

.T..

ou

1991).

.J. .\ Denotational

Languages:

t,o Const.ructive

of OOP-

R~r!i.serl? Report (Nov.

and its Correctness.

MALENF.~NT,

Prot,otype-Based

of ohjec%s

.J.. EA. Schernr

~~NSI/MIL-STD-181.5a.

8

49-x.

.~ND PAL~BERG.

c.,

Object,-

10 (Oct..

1989).

Full

An Efficient

Proc.

‘8.9. ,sigjllo72 !VOf. 24, 10 (Oct.

DONY,

E.

Object.(‘,\I

on Prototypes.

AND REES.

of lnherit~ance

SLA

like iii Srct~ioil 4 but

wit Ii t,wo kinds

W.,

Based

fhe .4lgor~t/zrnic Long~tge

of Self can be positively

pa01

t.rait,s as ahract

Language

SL.4 ‘89, Sigplan

For example,

in our view Self is uot prot,ot,ype-l,asetl but it. is cert,aiuly ot,jcc,t-c-eiit,rrerl. It is our opinion t,liat using the not.ion of ol~j~(.t-(-riit.er~~l prograinming wit,h a.hst,ract oh-

in

o.f the IEEE/A

pp.

Implernentat,ion Orient.ed

Protot,ypes

In Proc.

Families

Tmn.s.

1989). Using

Behavior

on

of Dat.a Plog.

Types

Lnnguuges

L!scrud

211’-X3. Prot,otypical in Object,

‘86, ,Sigph

Yof.

Ohjrcts Orient,ed ‘1.

to

In-

Syst.ems.

11 (No\:. 19%).

LF

MALENFANT.

[Ill

MALENF.WT.

gramming [l”]

MOSSES.

P.

[1:3]

C:ompufer

Semantics.

.Scitnct.

MIT

In Hadbook Press.

in (i/lEV(inRV(e)).

1900~ ch. 11,

1F3+200. u.

for langunge STEIN.

Virw

fkrzofrctiond

s?emmtics.

(I mcfhodo~ogy

19%.

L.. LIEBERMAY, H.. AND L~NGAR. D. A Shar~l of Sharing: The Trrat.y of Orlando. III Ub~tct-

ol.7PntPrl

(‘072“Ppt.s.

ad

PI::. Iiim

nnd

:1pp/iccrtr0n.s

F. Lochovosk~.

natu1m.se.s(1988).

IUs., :4ddison-\Y&ey.

STEYAERT, P.. .AND DE MEIJTER. W. A Marriage of Class- ancl Ohjrct.-Based Inheriknct: Without, Unwanted Children. III Proc. of ECOUP’9$ (.4ugust. 19%).

[la [lil

D.. (~ARLBERS. c'.. &.4NG, B.-W.. %I,E. II. Organizing Programs without. Classes. ITNGAR.

Sy7nbolzc

Conplfntzorl,

P81 CTXGAR. D..

AND

AiYD I.I6L-

Li.sp and

“23P”‘l”.

SMITH.

R. Self: The Power of SimLisp 01~1 ,Symbolic (7ompzrtcltion, -1 (1991).

plicity.

\vEGKER, [I91

Design. cember

P. Dimensions of Object,-Oriented Proc. o,f OOP.SL.4 ‘87. .Sigplrrn ,Vot. 198T). IGX~IXZ.

Additional

A

-I (1991).

functions

Language 22. 12 (De-

The reader

we don’t,

local

Object

empfy-d%cf =

dictionaries Xq.in(Loc

=

Xq.Xl.XA.Xq,.

and

in which

break

if q =jym q1

endif

it can

a.pply

insist,.

following

k’.Xa.

t,lie iiw inc‘t llotl m. 02; an activat~ioii of on t,llc, slot,s of 01 inskad

the nat8ural

among Object

first

object

that,

looks

up t81ie object.

which

wrapper

and

then

illlocate-llew-olject

a new object. is finally

alloc.atcs returns

obtains

identifier st.orrd

t,lic slot a nlwlory

froni

vaob-

t,he current

for t.his new nieln-

in t.llr ol,jwi,

nlcinory:

=

let*

(0,r.

4’1, /*.rl)

= ki(E lr~vlo~~,)

and (~20, ~1) = create-ohjtct(

if q* = () then

empty-rlrct t l)(l*

t 1))

crentt-ohlect

IOrnV/MOhjerf

y’% E*, C-J.I‘)

))

=

let (I’! ~7, ) = nllocnte-.slot-unl~te.s(e*)(

creation

iIi(fix(Tl),rl,g*,I’,I‘) clone =

=

e*,p).

let, -, = ir10mV(X(Q.

p).X(p,.

)

(~1)

X(q*.e’.cT,r). ill ( let 1‘1 = make-wcrpper(

x(l)*,

fat

and (Q. p1 ) = nllocclte-oop(p)

else c~rld-.~/ot(~*~~)(/*~~)(f(g*

mwke-met12

nieniory

A(&. q*.E*./L,a).

in (znEV(inRV(,n)),pz,

Method

br

lt calls in turn

and p2 = brrcd-objrct( Q)( znOnlV( nw))(p,

A.2

can

and cloning

create-object,

which

We also of niet,hotls

a iiietliod

and get,s its grnera,tor.

the new

nlrmory

d~sceiitlant.s.

objet-t,s.

creation

rrllocote-rlel~-object

in (r. as.sign(l*,e*)(ul))

endif

of mf%hods

iiiipleIneiit.cit~ioli

programming,

several

Allocate-llclu-o~;~:ct

let (1’. crl ) = ct//ocntzor~s(#~*)(rr)

flx(Xg.XI’.

of cre-

t,o wlf t,o access

t)he rqxeswt.ation

t,o all of t,lie latter’s

in object,-orient,ecl shared

=

clllocrrtt-.slot-ccrllle.s

is

be awaw

ted in t.lif, coiit,est Building a c~losurc~

Therefore,

Second,

local

t,lle slot.

If a c-losurc

wt‘ Inust

for m, we rely on referenws slots.

slots

only

needs to be passed the self and super in the tront wt. of its applicat,ion. We cannot, bind them in t,liP niet~liod. since

ory object,,

else a( qI )

tinle,

as

clioic-c lx-

over

accesses

it. is held.

it.s encapsula.tion.

the owner’s

object

zn(Lot ;F T)( /)

is our

niet~liods

normally

m’s creat#ion

t,lie function

then

t,o closr

at, nlethod

at,e a closure

c-rpa.trl c-losurw

This

t,hat, the inet hod expression is eswu of aiiot81ier esist,ing object,. sa.y 01. would niake 01’s slots visible inside wliic+ will lw 1lPld 1)y i~.llOt~il~~ ol,jec? m in 02 could t,llcn result, in side-rffect,s

ject. cdrl-n/of

want

A met,hod

poit1t.s ~onwrn-

do not

t,o t,he objects

crea.ted

ues, builds

+ T)(false)

two important,

unethods

lambda-espressiolis.

the parent, A.1

First,

traditional cause

not,iw

should

ing lnethods.

A.3

for LIEBERMAN

hjrlrl-o6~~cf(~‘)(-,)(~(,))

Observations

t,o an object.

clt wlopn~w~~f. Wm. C. Brown.

1

of

hIYERS, B. A.. c+II:SE. D. A., AND ZANDEN. B. v. Declarative Programming in a Pr-otot,ype-InstaIlce S.vstern: Object-Oriented Programming Without Writing 5Iethods. Proc. OOPSL.-? ‘9’. Szgplun Not. 27, 10 (Oct.

D-II %~llhllDT,

I’)

i~~7:‘U~‘l(i,~)(P,C~1,~2) in let (Q, pi ) = allocate-oop(p)

1995.

375-631.

WE),

[15]

Denotational

and p = hrnrli~~gs(v’~

Pro-

J. :iernantics of Delegation-Based Languages. fort,licon~ing kch. report,.

Theorcticul pp.

and cr2 = a.wi!/n(l'.i~*)(u, !

J. Split 0hject.s: Taming value sharing in la~~guages. submitted. August 19921.

object-oriented

a).Xn*.

let* (/*, gTi) = cll/occltiolls(#x*)(a)

228

CT)

nrn6e-o6~tcf-rl?[,~(

,I~I)

(I’)(/*))

b 1‘

Fiqlrc 0

10: Some

ut,ilit,im

for t,lle va.luation

functions

in Fig.

criloccltt-rfezll-cone-o~,jcct X(E.

5

=

q*,c*,p.a).

let.* r = purest-yen(p(E

IRV/Oop)

IO,“)

alld (mo. CT~) = create-couc-object( = () then () else (0(1*111) ISv)Sf(r’~ ettdif A.4

Initial

object

in (inEV(z7tRV(~)),~r?,

znOtnV( nzo))(/~t) r~)

rool

obdcc-t, in t,li~‘ system

identifier

is I~oruid

risc~l t,o I,ind

and 1-12= hind-object(p)(

t 1)

)( I* )

-I‘ll? first also

y*. E*. cr. I‘)

and (Q, ,uI ) = nllomtr-oop(~l)

ifl’l

X(/*,a).fix(Xf.XI’,.

t,o the thp

Illf’lllOl’\‘. /fJitK//-O/JJ,

is the

variable

root

roof object,

root-ooy.

ohjm.1, in the

t,O bf? llSf’C] t.0 PVdUatf?

root-oop init,ial

let*

whose

!C = O~ZI(P(E IRVIOop) IOrnV IMObject

and (mo.

is

object,

and

CT*) = create-traits-object(

(g. ~11 ) =

ITObject )

q*, E*, g, r)

rrlloccrte-ool,(~1)

and ~12 = bind-object(

Q)( inOtnV(

mo))(~~~ )

in (iltEV(irzRV(_o)),~12,al)

]IrO@XllS:

We also Ilaw &ion

t,o introduce

of new ob,jects,

two functions

one for concrete

for the rre-

oll.jects,

the oher

for t,rait,s: crrntr-cone-obj~(~t

=

x(y*.E’.u.r). (ir,Ot11V(

(fix{

root-gtn).

0.

root-gen.

(),

let

L;,,,,,,,,,.)))

(11)

B

are

in hMObject((fix(ri),

Trait-based

:\l/omtr

and

creutt-tmit.+objtct

programming

-II~ w-roar.-obpcf

respwt.iwly

nfvIiiitials

(1’. CT1) = allocate-.slot-~~~nlues(E’)(o)

in ( let 1‘1 = make-zumpper-( make-oblect-dict(

railed newTraits

and

q*)( I’))

Dr

, al)

=

A(~*,~*. u,r). let (P, 0-t) = allocccte-slot-onllLes(E’)(a)

ollocnfe-llew-trnitti-objtct

13~’ t,lie valuat,ion

rl. q*. I’. r))

functions

for

expressions:

in ( let r1 = make-torapper{ in inMObject((r,,

The function when a concrete

q*)( I’))

D r

,gI)

clone now creat,es a concrete object, one is cloned. and a trait,s if it,‘s a traits

hat, is cloned. Also, empty Vaits object,:

229

make-object-dict( y*, l’.r))

t,he first, object

root, will now be an

clone

A(=.

allocates collects

Allocate-/2-slot-ualrles

=

j’.

store

a).

while

t,igrtous

collect-72-uulrles

n ~101~valrtes in t,ltc, t,lie villute

=

mitin1-ant

(zrzOmV( zn.MObject(

(fix( root-yen), .L,“C,O,

D C

Map-based

‘I‘~P three

following

t lie concepts /ocrrtzor2

programming functions

of c~ont,iguous

Y( 12. 0 ) =

add

to our

root-germ, I,,,,

Lenerarori)))(P)

Object memory functions adapted from the store algebra of [l2]

empty-07~s

store

ol)jtac?:

=

X,o.in(OmV

+ T)(false)

reserve-oop =

algebra

[email protected].

locat,ions:

if e =OOp C,Ithen

unspecified

hind-object

in( OmV

+i T)(true)

else p( ~1) endif

=

XQ.Xa.Xp.XQl. rF.sf).l’utloIl.s

=

fix(Xj.X/‘.fix(Xg.Xa.

if e =OOp ~1 then in(OmV

if(* = () then cr endif

= XQ.XC(.case

bound-object

else j( 1’ t l)( reservc6tion(l* $1. u))

@ T)(m) else p( ~1) endif trnp

r.sT P q c~orltlgrlo7l.s-clllor~ltlo~2.s An.

=

isOrr1V f =+

)j

=

p(o) of t1up

IO,““,

i,,,,,

endcase

if r2 = 0 then Xv.((). a) else Xa. let* F = locntion.s( r), a) and ‘~1 = ~e,s~~~rl:c~tion.s(I*)(a) in (1*, g1 )

12FW-oop(ji) =

w2.specijkl

alloccdc-oop

Xp. let g =

=

r2fwoop(j6)

in (Q. reser~~+oop( p)(p))

endif

230