• Aucun résultat trouvé

A Comparison of Record- and Name- Calculi

N/A
N/A
Protected

Academic year: 2022

Partager "A Comparison of Record- and Name- Calculi"

Copied!
14
0
0

Texte intégral

(1)

Book Chapter

Reference

A Comparison of Record- and Name- Calculi

DAMI, Laurent

Abstract

This paper compares several lambda-calculi extended with records and/or operations on names. An operational semantics framework based on the observation of error generation is used to formalize (in)equational laws about record operation in a common setting. The calculi studied here are classified in two clearly distinct groups. The richest structure is exhibited by both the calculus of extensible records and the "λ-calculus with names", which are closely related but not equivalent. By contrast the calculi of record concatenation and weak record extension have a simpler structure, and in particular do not support width subsumption (the fact that a record with more fields can replace a record with fewer fields); both can be translated into the former calculi.

DAMI, Laurent. A Comparison of Record- and Name- Calculi. In: Tsichritzis, Dionysios. Objects at large = Objets en liberté . Genève : Centre universitaire d'informatique, 1997. p. 71-83

Available at:

http://archive-ouverte.unige.ch/unige:155396

Disclaimer: layout of this document may differ from the published version.

1 / 1

(2)

A Comparison of Record- and Name- Calculi

Laurent Dami

Abstract

This paper compares severa.1 lambda-calcul i ex1cnded wi1l1 records and/or operations on names. Ao operational semantics framework based on 1he observation of error generaiion

1s used 10 fom1alize (in)equational Jaws about record operation in n common sening. The calculi studied here are classified in two clearly distinct groups. The richest structure 1s exhibited by both the calculus of extensible records and the ",\-calculus with names". which are closely rclaced bu1 nol equival.:nl. By contrast the calculi of record concate.nation and weak record extension have a simpler srructure. nnd in par1icular do not suppon w1d1h subsumption (the fact that a record with more fields can replace a record with fewer fields):

both can be translated into the former calculi.

1 Introduction

This paper compares several lambda-calculi extended with records and/or operations on names.

As previously argued in [9], names are an essential means to flexibly bootstrap the communica- tion between coordinated components, esp. in a distributed or modular environment: services offered or required by a particular component are advertised along distinct channels labelled by names, and then the coordinating system can use these names to bind communication chan- nels together. What makes names different from more traditional positional channels is the fact that they are unordered, and therefore a given set of names can easily be extended in several directions. This has been acknowledged in a number of recently proposed coordination mod- els [2, 19, 3, 10], in which agreements on names play an important role in the communication constructs. Admittedly, naming schemes are just a partial aspect of these models; nevertheless a thorough understanding of name-based operations, isolated from other coordination aspects such as concurrency, can be helpful for the comparison and design of coordination models. We started such a line of study in [9) and [8] and proposed

>.N,

a lambda-calculus extended with names for dynamic binding. Here we pursue this work and go through a detailed comparison of

>N with severaJ record calculi, which rely on very sim.ilar ideas and were originally designed to study the foundations of object-oriented programming. In panicular, we take the calculus of extensible records studied by [20) and [ 17], another, new ca.lculus of extensible records with a different form of record extension, and the calculus of record concatenation of [ 18]. The ref- erences just cited relied on an informal (but obvious) understanding of the meaning ofrecords;

here, instead, we give a precise operational semantics from which several (in)equational laws for the calculi under consideration can be derived; such laws were often implicitly understood but to the best of our knowledge were not formally shown before. Moreover, the operational semantics is useful to study translations between the calculi, not only in terms of preservation of reduction rules, but also in terms of preservation of semantic laws.

71

(3)

72 A Comparison of Record- and Name-Calculi

I

name operator field absent field preseni reference J

symmetric concat

II

y' c [12)

overwrite concat

« J

y' [18)

weak add ffi y' - this paper

weak update ~ - y'

weak cancel

\

- ..j [4)

strong add

m

y' E [4]

strong update !E E y' [1]

strong cancel }]

.

y'

extend <@ y' y' [17, 20)

Figure 1: Record Modification Operations

2 Record Calculi

The common operations of interest in all name or record calculi are:

• build a collection of associations between names and values

• extend or modify such a collection

• access the value stored under a given name

Main variations between calculi appear in the operations for extension or modification. A wide range of possi bi Ii ties is mentioned in ( 4]; however lhc discussion mostly concentrates on typing issues. By contrast, this paper is primarily concerned with semantic (in)equalilies in untyped calculi.

A first possibility for dynamic record modification is a concatenation operator, which merges fields from its two operands into a single record. 1n case of confllcting fields between the operands, various actions can be taken, like forbidding the concatenation operation [ 12), or giving preference to one of the operands. In this paper we wil.I study a right-preferential op- erator like the one of [18), which we write «. The other possibility for record modification is to take individDal actions on specific fields; Figure I is an attempt to list all possible such operators. Addition operators try to add a new field to a record, update operators try to mod- ify an existing field, and cancel operators try to remove a field. The distinction between weak and strong operators becomes apparent when the modification fails: weak operators just ignore the failure (hence the modification attempt is a nil operation), while strong operators generate an error. The extension operator @, which always puts a new value i.nto a field disregarding whether Ibis field is absent or present, never fails, and therefore has no weak or strong version.

The @ operator is probably the most frequenr in the literature, because it directly corre- sponds to object-oriented inheritance, where methods can be either added OR overridden. The with operator of[20] and [ 17J exactly corresponds to our @. [4] do no! introduce this operator directly, but rather derive it from other, more primitive operators: extension is encoded as a weak cancellation \ immediately followed by a strong addition

B

(4)

L. Dami 73

II .. - .r1

I

A;r.n

I

a :-: ! b i a!

I •

(Ax.a) 2:1 b --+ >..r.a[:r1 :== b]

(AJ·.a)! --+ a[x. :== c:J

:?-1 b --+ ~ .o! --+ A:c.E --+

.

Figure 2: >.-calculus with names (A.I\' )

The weak addition operator~ intuitively seems to be a minor variation from <@;however it has quite different properties, as will be shown below. The strong update operator ig is essen- tially the one used in the object calculi of[!]: field modification is allowed but field addition is forbidden. Other operators, such as weak update or strong cancellation, were apparently never studied.

Unfortunately the technical developments below do not cover all these operators. The main reason for this shortage, apart from obvious space limitations, is that some results1 rely on modular record construction, where multiple fields are added one at a time to an initially empty record. With such a modular approach, reduction rules for records can be expressed as a stan- dard rewrite system. However, strong addition or strong update are not adapted to these tech- niques: in order to check whether a strong addition yields an error it is not su'fficienl to know the next field of the record; the whole record must be known as a single unit. Therefore this paper only concentrates on the four calculi displayed in Figures 2,3 .

The first calculus ).N is the one studied in (9], except that we write o 01b instead of a( l == b ), for better consistency ofnotation with respect to other calculi below, We briefly recall the main idea: each >.-abstraction opens multiple communication channels, labelled by names. Accesses to variables use a name index in order to specify which channel should be read; conversely, parameter passing is done by fi lling one channel at a time through the bind construct a 0 1 b.

At some point (ideally when all used channels have received a parameter) the filling process is

"closed" by the a! construct, and the corresponding >.-abstraction is removed. Channels which received no parameter before the closing operation carry an error value E. The classical ..\-cal- culus is embedded into >.JV by choosing an "invisible" name i for all places where indices are needed: so the translation is T[x] ==

x,,

T[A.t.a] == >.x.T [a] and T[(ab)] == (T[a)0, T [b])!. For convenience we someiimes mix ,\-calculus syntax with )JI/ syntax, assuming this translation to be implicit. The reduction rules ofFigure2 use the notation a[x1 :== b] to denote the substitution of b for all free occurrences of x1 in a, and a[x. :== b] to denote the subs6tulion of b for all free occurrences of variab'le .t in a at any index. Observe tba! "bind'' reductions perfonn a single substitution without removing the A-abstraction, while "close" reductions remove the A after having substituted all remaining occurrences of the corresponding variable by the error term c:.

1 in particular the proof ofLenuna 3.4

(5)

74 A Comparison of Record- and Name-Calculi

Kernel for record calculi ( >R)

a ::= x

I

.Ax.a

I

ab

i {} I

a.I

i ::

(.Ax .a )b --+ a[x := b]

(.>.;r.a).I --+ £

f, u --+ c {}.I --+ 10

({}a) --+ £ .>.x.£ --t £

Calculus of extensible records ( >R@) a ::= ... I a.@1b

(.>.x.a)~1b --+ £ ({}-@1b).I --+ b

(a{fi1b).l' --+ a.I' if/=/'. I' ((a<@1b){fi11c).l1 --+ (a@l'c).I' Calculus of conditional extension ( >Rtl!)

a ::= ...

I

aEB1b (.>.x.a) Ef!i b --+ £

({} EEl1 b).I --+ b (a ffi1 b ).l' --+ a.I'

((affi1b)ffi11c).l' --+ { (a ffil' c).I' if I -;t. I' (a ffi1 b).I if I:= I' Calculus of record concatenation ( >R«.)

a ::= ...

I

{l=a}

I

a«b

{l=a}.l' --+ { a ifL :=I'

£ otherwise (a«{l=b}).l' --+ a.I' if/~ l' ({l=a}«{l'=b}).l' --+ b

((a« {I= b}) « {l' = c}).I' --+ (a« {I'= c}).I' a« (b « c) --+ (a« b) « c

Figure 3: Record calculi

(6)

L. Dami 75 The second calculus >R@ is the calculus of extensible records of [20] and ( 17]; however the precise formulation of reduction rules as given here is new. Records with multiple fields do not belong to the syntax, but are easily encoded as a sequence of extensions to the empty record: for example { l1 = '.3.12 = .5} corresponds to {}<@1, 3@1,5. Observe that reductions of the form (a1§1b) ./ ~ b for arbitrary a, which would perhaps seem quite natural, are not allowed, since they would destroy confluence: this can be seen easily for example when a= e:, where the result could be either ,; or b. The third calculus >Rrfi is very similar, apart from a subtle difference in record extensions: the Efl operator adds a new field to a record if that field is not already present, but does nothing otherwise (conditional record extension). To the best of our knowledge this calculus was never studied before, the reason probably being that this calculus lacks a number of important properties of the other calculus; nevertheless we do include it here for the interest of the comparison. Finally, the last calculus >R« is the calculus of record concatenation presented in [ 18]. Here records with multiple fields are obtained through concatenation of several one-field records. Note that in this calculus the empty record has no interest and therefore was not included in the syntax.

By convention all record operators are considered left-associative, so a

«

b

«

c means

(a

«

b)

«

c and a@1b@1'c means ( a'*1b )@1,c.

Proposition 2.1 For >R@, AR+ and >R« , the record reduction systems (i.e. excluding the ;3- rule) are confluent and strongly terminating.

Proof.(sketch) All three systems are orthogonal (rules are left-linear and without critical pairs) and therefore are confluent. Furthermore all record reduction rules decrease the size of terms, so the reduction systems are terminating.

Theorem 2.2 All calculi o_f Figures 2,3 are confluent.

Proof.( sketch). For >JVthis was proved in [9]. Forall other three calculi, use the previous propo- sition to reduce to a unique record-normal form and then compose with the known confluence of /3-reduction, using Hardin's "interpretation method" (see for example [13]).

3 Operational subsumption

Record systems usually consider the order of fields to be irrelevant; furthermore, a record with

"more" fields is often considered "better" than a record with fewer fields. This will be formal- ized through an operational subsumption relation on terms, comparing their error generation bebaviour first in arbitrary contexts, and then in applicative contexts (applicative bisimulation).

Jn both cases, a statement a !;;; b can be read intuitively as "a is better than b", or "a gener- ates less errors than //'. Following comm.on definitions, a comext is obtained by extending the syntax with[-] (a hole). For any context C[-], C[a] is the term obtained by plain syntactic substitution of a for every occurrence of the hole in C [-], i.e. with possible capture of free variables of a.

(7)

76 A Comparison of Record- and Name-Calculi

Definition 3.1 The COlllt!Xlual subsumptionpn1order i:;:;ctxt is defined as:

a i;;;ctxt b ~ \IC[-] E C.[C[a]..; c ~ C[b] _.; t:]

Because of the quantification over arbitrary contexts, proofs of subsumption may sometimes be difficult. The applicative order defined below, which only considers a restricted class of contexts, is much more amenable to formal demonstrations.

Definition 3.2 For each calculus of Figures 2,3, the corresponding set cappl of applicative com exts is deji11ed inductively as:

• [-) E cappl

• C[-]ECappl =o? (C[-]a)ECapplforanycloseda

• C[-J E cappl =o? C[-].1 E C"PP1

C [-J E cappl =o? C[-J <@1 a E c~rrl for any closed a

C [-] E C•PP1 =o? C[-J $1 a E c•ppl for any closed a

• C[-J E cappl =o} C[-] «{I= a} E c•PP1foranyclosed a

Definition 3.3 A closing substitution u for terms a and bis a.finite lis£ of atomic substitutions such that both acr and bu are closed. 171e11 the applicative subsumptioo preorder ~·~P1 is defined as:

i) for closed a, b ii) for arbitrary a, b

a i;;;appl b ~ \IC[-) E cappl.[C[a]..; E =o} C[b]..; t:]

a i;;;•ppl b ~ \lcr.acr i;;;•ppl bcr

Lemma 3.4 (Context lemma, Operational extensionality) Jn all calculi:

\la, b. a i;;;ctxt b ~ a i;;;•ppl b

Proof.(sketch). For >..N see [9]. For the other calculi, we rely on a result of [14) who showed that the context lemma holds for all "PCF-like" systems, i.e. systems in which the additional 6-reduction rules are "ground linear" (the left-hand sides of the rewrite rules only consist of ground constants or distinct metavariables). Given our modular approach to record construc- tion, it is immediate to check that the reductions rules satisfy the condition of ground linearity.

Since both orderings are the same, we will omit the superscripts in the following and simply write i;;; for the preorder, and ~ for its reflexive closure.

Proposition 3.5 a;;,b =o? a~b

\la,

n

i;;; a i;;; c, where

n

is any divergent term.

(8)

l. Dami 77

l - ---

field permutation (if l1

1- /

2)

I

>..N a '~''• b1 :=:.·12 b2 ~ a ·:; 12 b2 ·::::1, b1

,\R..i. a<@'i1, b1 @1,~ :;,, a<ifn,b2€>1,b1

,\fi,,_ a .:811 b1 ':!112 b2 :;,, a ~I~ b2 E&t, b1

AR< {11 ==bi}

«

{12

=

b2} ~ {12 =b.}« {11 =bi}

[ - multiple bind elimination

I

>..N a. ·81 b1 81 b1 ~ a '21 b1

>R@ a@1b11!l1b2 ~ a@1b2

>R.fj; (} 8"1 bi e 1 b2 ~ a

,z.,

bi

>R~ {I== b1 }

«

{I== b2} ~ {I==~}

[ strict subsumption - - --

J

I

~ >..NI (a81b)! {}-@1b !;;;; !;;;; {} a!

I

I

ignore error field

I

I ~

>..N

I

a {}<@1c :;,, {} 01 c!

~

a!

I

I

extensionality J

>..N ifx <f.FV(a): a!;:; ,\:i;.(a 0 1,x11 •• • 0 10 .t1.)!

>R. if x <f. P\1(<1 ): a

c

,\:r.«.:i;

Figure 4: (In)equational laws

(9)

78 A Comparison of Record- and Name-Calculi rrnof. Direct from definitions

Theorem 3.6 The calculi satisfy the (in)equational laws displayed in Figur!! 4.

Proof.(sketch) For >N, see the full development in [9]. For the record calculi. first assume a closed and usc induction on the shape of applicative contexts; then extend to the general case by quantifying over all closing substitutions.

Some comments are of order. Laws for field pennutation and multiple bind elimination are quite obvious, given the semantics of record operations, and. hold in all calculi. By contrast what we call strict subsumption, which somehow says that addition ofa new field is a harmless operation, is only valid in

>.N

and Ml@; this is discussed below. ,Functional extensionality, i.e. the well-known 11-equality rule of the >.-calculus. is here only an inequality fo r the record calculi: 11-contractions can be safely performed. but not !'}-expansions, because these would be meaningless on record terms. For >.N, the inequality comes from another reason: a finite term like ).;i:.(a 01, ~:1, • , , 8 1., X 1,. )! cannot bind all fields possibly present rn a.

Subsumption and Subtyping "Strictsubsumption" laws are only valid in').../\' and >J?@because these calculi have no intern.al way to separate a record with "more" fields from a record with

"fewer" fields. In

>.Re

and >Jt< the extension operators can partially check for presence of a field. Consider for examples the~ context ([-) @r, fl ) .12.L~ and >Jt« context ( {/2

=

fl}

«

[-J).12.1,,: both will diverge when filled wi th {11 =a}, but will yield an error when filled with { 11 = n, 12 = { 13 = b}}. For the same reason. the "ignore error field" laws only hold for >J? ~;

and >.R«, where an absent field or a present field contai ning ~ can be distinguished. while in

>J1q, and >.N the difference cannot be observed internally.

Even witboui displaying complete type system, it is easy to show that strict subsumption has an impact on types. Record systems are often associated to a notion of subtyping relation S on types, and a corresponding typing rule saying Lhat whenever a : T and T S U, then a : U.

The most common (and most useful) subtyping relation on record types is expressed by the following ru'les:

Vi,T; ~ U; (depth)

{I, : 1\,Li: Ti}~ {Ii : Ti} (width) {11 :

'l;}

~ {I;: U;}

The depth law says that subtypes can replace supertypes within record fields; the width Jaw says that a subtype can have more fields than its supertype. Now the point is that for record calculi which do not have strict subsumption laws, the width subtyping rule is unsound: since

- - } -

{I;= a;,/j

=

b;

g

{I; = a;}

there are contexts which generate an error when filled with the left-hand side, and generate no error when filled with the right-hand side (examples of such contexts were just given in the previous paragraph). Hence it is unsound to use a larger record when a thinner record is expected. In [I 8), the argument that record concatenation can be typed "for free" through a

(10)

L. Dami

m«-+ m..,

T!.r] = l'

T(.-\.r.aj

=

,\.r.T[a]

T[(ab)] = (T[a]T[b]) T({I =a})

=

.-\.r.1:@1a

T(a.l] = (T[a){} )./

T[a

«

b) = .-\:i:.T[bj{T(aji') )J\! -t >R'*

T[xi) = .r.l T[.-\.c.a] = ,\,i:.T(a]

T[a ''."'1 b] = h.T(a](.r@1T(b]) T[a!J = T(aj {}

)JI.If! -t AR.@

T[:r]

=

T[.-\1.·.a) = .-\.r.T(a]

T[(ab)] = (T[a)T(b]) T[{}] = ,\x .. r

T[a.I] = (T[a]{} ).I T[a $1 Ii] = .-\.r . T[ a](.r~1 T[l1j)

Ml'* -t kV T[x] = .1:,

T(.-\:r.a] = ,\:r.T[a) T[(ab)j = (T[aj .:.1 T[b])!

T[{}] = .-\:c.x,!

T(a.IJ = (T[aj ::'.), (,\x.x1))!

T[a~1b] = .-\x.(T[a.J ,~, (.r :J: T[li]))!

Figure 5: Translations of record calculi

79

translation into the >Jl<fi' calculus forgets to mention that there is actually a hidden cost, which is to lose width subtyping.

Finally, it is worth noting that there is a subtle difference between the "strict subsumption"

laws in A!V and >..n<t>. ln the first case (a 01 b)! i;;: a! for any a: this informally says that passing some i.nforrnation on channel I j 11s1before 11sillg a component a is betcer than accessing lhe component directly. By contrast the ,\R4Jl law (}@16 i;;: {} says that stai·ting with some information on field I is belier than starting with nothing. Hence the >.N law can compare software components by considering the latest extensions which have been done, while the

>R<fi' law considers the early extensions.

4 Translations

This section explores comparative expressive power of the calculi through several translations, all displayed in Figure S. The translation )..~ -+ AR~ was given in [ 18}; 1J1e translacion

>J?q; -t

>..N

was first given in [7); other translations are inspired by discussions with Didier Remy.

4.1 Faithful translations

Proposition 4.1 The translation >R« -+ >R<ff! is faithful, in the sense that it preserves both the reduction relation and the semantic laws.

Proof. Analysis of the reduction rules and semantic laws. We only display the reduction niles;

the only two laws for field pennutation and multiple bind elimination are easy consequences:

(11)

80 A Comparison of Record- and Name-Calculi

• {1-a}.1 >a:

T[{I = a}.l] = ((,\x.x-@1T[a]){}).l -+ ( {}<@1T[a)).I -+ T[a]

• {I= a}.I'-+ c: idem.

(a« {I= b} ).l'-+ a.I' if l

f=.

l':

T[(a «{I= b}).l'] = ((,\.x.(,\y.y@1T[bj)(T[a):r)){} ).I'

~ ((T[a){} )@1T[bj).I' -+ (T[a]{} )./'

- T[a./1

({l =a}« {l' = b}).I'-+ b:

T[({I =a}« {I'= b}).l'] = (( ,\y.(A:r.x{P.1•T[b))((,\x.x-@1T[aj)y)){})./1 ..; ({} <1i11Tja)<fi1•T[b]).I'

..; T[bJ

• ((a« {I= b}) «{I'= c}) .l' -t (a« {I'= c}).I':

T[((a « {l = b}) « {l' = c}).1') ..; ((,\x.(T[a]x)~1b@1•cl{}).l' ..; ((T[a]{} )1iil'c).1'

_ T[(a «{I'= c}).I')

a« (b

«

c) -+(a« b)

«

c:

T[a « (b « c)) ..; ,\x.T[c)(T[b)(T[a)x)), 'f[(a « b) « c) ~ ,\x.T[c](T[b](T[a)x)) Proposition 4.2 The translation >RID -+ >R@ is also faithful.

Proof. Similar computations.

The fact that both translations are faithful is not surprising, since both AR< and >J7.6 have a simpler structure (fewer interesting semantic laws) than

,\f4.

By contrast, we will show below thai ~and AN, although closely related, have some subtle differences.

4.2 Unfaithful translations

Both translations >R@ -+ ,\N and ,\N -t >R* are not faithful. However, the failure cases are quite marginal. In particular, it is worth observing that most >R* reduction rules are directly preserved through the >R@ -t ,\N translation:

(12)

L. Dami

• {}./ _, c:

T[{}./] = ( >.x . .r')(>.y.yi) _, (>.y .yt) ! --+ E:

• ({}@1b).I--+ b:

T[( {}@1b).I] = ( >.y.( >.x.x!)(y <~1 T[b)) )( >..r.xi) --+ (>.x . .r!)((>.x . .rt) ::;; T[b)) --+ ( >.x.x1) '::'1 T[b]!

-> ( >.:r.T[bJ)!

--+ T[b)

(a<@1b).l1--+ a.I' ifi jE l':

T[(a@1b).l'J = (>.x.a(a· 81 b))(>.x .. 7:1•) --+ a((>.2:.x1•) t)1 b) --+ a(>.J:.xl') := T[a.I']

((a@1b)@1•C).L'--+ (a@1•C).l1:

T[((a@1b)@11c).l'J = (Ay.(,\l:.a(x 81b))(y01• c))(.Ax.x1•) --+ (.Ax.a(x 81 b))((.Ax.xl') 81• c)) --+ a((((.Ax.xl') 81' c)) 81 b) --+ a((.Ax.c) 01 b)

--+ a(.Ax.c)

T[(a@l'c).i'J = (.Ax.a(x 01' c))(.Ax.xl') --+ a(.Ax.c)

Furthermore all >R'<J algebraic laws from Figure 4 are also preserved in >N:

a<@1,b1@12b2 R:: a@1,b2@1,b1:

T[a{'!l1,b1@12b2] = >.y.(.Ax.T[a](x 81, T[b1]))(y 812 T[b2]) --+ .Ay.T[a]((y 812 T[bi]) 811 T[b1])

R:: .Ay.T[a]((y 811 T[b1]) 812 T[b2]) _ T[a-@12b2@1, bi]

a@1b<$1c R:: a@1c: idem .

• {}@1b

r; {}

T[{}@1b] = >.y, (>.x.x!)(y 81 b) --+ >.y, (y 01 b)!

r;

.Ay, y!

=: T[{}]

81

(13)

82 A Comparison of Record- and Name-Calculi

a~ >.x.ax:

T[a] [;;; T[>.x.ax]

=

>.x.(T[a] ?;, x,)!

This shows that the essential operations of

>J4

are preserved in >JV. Neverthe.less, the tranlations fails for the two error generating rules (>1.<r..a).I -+ t: and (>.x.a)@1li -7 6 : the translation of (>..'1:,a,).I is (>.:t .T[<t])(>.y.y1) , which is not equivalent to c:. In particular if :r. ~

FV(a), then this reduces to T[a) which is better than c:. Similar examples can be drawn for the record extension operator. The reason for the failure is that

>R@

internally distinguishes between two kinds of values: records and functions. Operators such as field selection, record extension or functional application can immediately detect if the operand is of the wrong class of values. By contrast, al! values in )N are functions with named parameters: hence errors are only generated when actually using a value, and not by externally inspecting .it.

Let us consider now the reverse translation >N --+ >.R.,_, starting with the reduction rules:

• (>.J:.a)! --+ a[x. := t:]: T (( ,\;~ . a)!J = (,\x.T(a]){} --+ T[aj[l· := {}]. Equality with T[a[x. := t:]] is shown by induction on a, inspecting the translation at each step.

(Ax .a) 0 1 b--+ ,\x.a[x1 := b]: Here this leads to the equation T[a[x1 := b]J = T[a][x := (l'@1b)j

which obviously does not hold, esp. when x is a divergent or an erroneous term.

A simple example illustrating the failure of the translation is (>.x.:r.1) 0 1 !1, where fl is a diver- gent term. In '>N this reduces to ,\x.n , which never generates any error, while the translation

>.x.(x@1ft).I gene.rates an error in context

I-Jc:.

Here the problem comes from lhe facl, already mentioned, that equation ( a ~1b). l = bis not valid in the record calculus. because <1 could be a djvergent or erroneous term.

5 Conclusion

We have explored four >.-calculi extended with record and name operations, giving precise reduc1ion rules and semantic laws. The riohesl structure is exhibited by both >.R.<!,. the calculus of extensible records of[20, 17), and >N, the >.-calculus with names proposed by the au1hor.

Both calculi enjoy the property of "strict subsumption", which is a basis for a type system involving both "depth" and "wid.th" subryping on record types; by contrast, the calculus of record concatenation and the calculus of weak extension do not enjoy this property. >.RitlJ and

>.I\f are very closely related in expressive power, but the mutual translations are not faithful, the main reason being that

>N,

much like the classical >.-calculus, treats all values as functions, while~ distinguishes between funo1ional values and record values.

References

(!] Martin Abadi and Luca Cardelli. A Theory of Objects. Springer-Verlag, Monographs in Computer Science, 1996.

(14)

L. Dami 83

[2] Jean-Marc Andreoli. Coordination in LO. In [6], pp 42-64.

[3] Mario Banville. Sonia: an Adaptation of Linda for Coordination of Activities in Organizations. In [5], pp 57-74.

(4] Luca Cardelli and John Mitchell. Operations on Records. In (I I], pp 295-350. First appeared in Math. Structures in Comp. Sc., 1991, pp 3-48.

(5] Paolo Ciancarini and Chris Hankin, eds. Coordination languages and Models "96. First Interna- tional Conference. Springer-Verlag. LNCS 106!, 1996.

[6] J.-M. Andreoli, C. Hankin and D. Le Metayer. Coordination Programming: Mechanisms, Models and Semantics. Imperial College Press, l 996.

[7] Laurent Dami. Functions, Records and Compatibility in the Lambda N Calculus. ln Object- Oriented Software Composition, 0. Nierstrasz and D. Tsichritzis (Ed.), Prentice Hall. 1995. pp.

153-174.

[8] Laurent Dami. Type inference and subtypingfor higher-order generative communication In [6], pp 98-138.

[9] Laurent Dami. A Lambda-Calculus for Dynamic Binding. To appear in Theoretical Comp. Sc., spe- cial issue on Coordination, 1997, Currently available at http://cuiwww. unige. eh;- dami.

(10] Gert Florijn, Timo Besamusca, Danny Greefhorst. Ariadne and HOPLa: Flexible coordination of collaborative processes. In (5], pp 197-214.

[ 11] Carl A. Gunter and John C. Mitchell, eds. Theoretical aspects of object-oriented programming:

types.semantics. and language design. MIT Press, Foundations of computing series. 1994.

(12] Robert Harper and Benjamin Pierce. A Record Calculus Based on Symmetric Concatenation. In Proceedings 18th ACM Symp. on Principles of Programming languages, pp 131-142. ACM Press, 1991.

(13] Eta-conversion for the languages of explicit substitutions. In Proceedings Agebraic and Logic Prag '92, pp 306-321, Springer-Verlag, LNCS ()32, Sept. 1992.

(14] Trevor Jim and Albert R. Full Abstraction and the Context Lemma. SIAM J on Computing 25(3):663-696, June 1996.

(15] John Lamping. A Unified System of Parnmeterization for Programming Languages. In Proceed- ings ACM Conf. 011 LISP and Frmctionof Programming, pp 316-326, 1988.

(16] Shinn-Der Lee and Daniel P. Friedman. Enriching the Lambda Calculus with Contexts: Towards A TI1eory of lncremental Program Construction. In Proc!ledings ACM /111. Conf. on Functional Programming, ACM SIGPLAN Notices, 31(6):239-250, 1996.

(17] Typechecking records and variants in a natural extension of ML. In Proceedings ACM POPL'89, pp 242-249. Also in (11], pp 67-96.

(18] Didier Remy. Typing Record Concatenation for Free. In Proceedings ACM POPL '92, pp 166-176.

ACM Press, 1992. Also in (11], pp 351-372.

(19] Robert Tolksdorf. Coordinating Services in Open Distributed Systems with LAURA In (5], pp 386-402.

[20] Mitchell Wand. Type Inference for Record Concatenation and Multiple Inheritance. Information and Computation 93(1), pp 1-15, 1991.

Références

Documents relatifs

As for toric Fano manifolds, Galkin, Golyshev and Iritani([8]) proved Gamma con- jectures I, II modulo Conjecture O, and then Galkin ([6]) has made some progress on Conjecture O

Spectral Analysis and Scattering Theory for Sch¨ odinger Operators with an Interaction Supported by a Regular Curve, in “Ideas and Methods in Quantum and Statistical Physics”,

First edition limited to 600 numbered copies all accompanied by a 10 x 14,6 cm sticker... The Future

Figure 2: Illustrating the interplay between top-down and bottom-up modeling As illustrated in Figure 3 process modelling with focus on a best practice top-down model, as well

It has often been noted that, on a certain conception of essence at least, answers to the question what it is to be the morning star may not themselves answer the question what it is

It cannot be generally the case that what is produced or founded has less reality than what produces or founds it, because both relations may hold between a thing and itself..

contingent grounding, if there is such a thing, the answer is less than clear-cut: certainly, the mixture is something over and above its ingredients, it does not owe its existence

Instead, Peterson’s theorem should (only) be interpreted in the following way: it formally shows that, given two other technical premises, the Archimedian condition and (as I argue